Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: src/scripts/build_gpt.sh

Issue 2133006: fix for issue 2610 (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: use stateful parition image size for the partition itself Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform/installer/chromeos-common.sh ('k') | src/scripts/build_image » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 # 6 #
7 # Load common constants. This should be the first executable line. 7 # Load common constants. This should be the first executable line.
8 # The path to common.sh should be relative to your script's location. 8 # The path to common.sh should be relative to your script's location.
9 . "$(dirname "$0")/common.sh" 9 . "$(dirname "$0")/common.sh"
10 10
11 # Load functions and constants for chromeos-install 11 # Load functions and constants for chromeos-install
12 . "$(dirname "$0")/chromeos-common.sh" 12 . "$(dirname "$0")/chromeos-common.sh"
13 13
14 # Script must be run inside the chroot. 14 # Script must be run inside the chroot.
15 restart_in_chroot_if_needed $* 15 restart_in_chroot_if_needed $*
16 16
17 get_default_board 17 get_default_board
18 18
19 # Flags. 19 # Flags.
20 DEFINE_string arch "" \ 20 DEFINE_string arch "" \
21 "The target architecture (\"arm\" or \"x86\")." 21 "The target architecture (\"arm\" or \"x86\")."
22 DEFINE_string board "$DEFAULT_BOARD" \ 22 DEFINE_string board "$DEFAULT_BOARD" \
23 "The board to build an image for." 23 "The board to build an image for."
24 DEFINE_string arm_extra_bootargs "" \ 24 DEFINE_string arm_extra_bootargs "" \
25 "Additional command line options to pass to the ARM kernel." 25 "Additional command line options to pass to the ARM kernel."
26 DEFINE_boolean recovery $FLAGS_FALSE \
27 "Build GPT for a recovery image. Default: False."
26 28
27 # Usage. 29 # Usage.
28 FLAGS_HELP=$(cat <<EOF 30 FLAGS_HELP=$(cat <<EOF
29 31
30 Usage: $(basename $0) [flags] IMAGEDIR OUTDEV 32 Usage: $(basename $0) [flags] IMAGEDIR OUTDEV
31 33
32 This takes the image components in IMAGEDIR and creates a bootable, 34 This takes the image components in IMAGEDIR and creates a bootable,
33 GPT-formatted image in OUTDEV. OUTDEV can be a file or block device. 35 GPT-formatted image in OUTDEV. OUTDEV can be a file or block device.
34 36
35 EOF 37 EOF
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 esac 72 esac
71 fi 73 fi
72 74
73 # Only now can we die on error. shflags functions leak non-zero error codes, 75 # Only now can we die on error. shflags functions leak non-zero error codes,
74 # so will die prematurely if 'set -e' is specified before now. 76 # so will die prematurely if 'set -e' is specified before now.
75 set -e 77 set -e
76 # Die on uninitialized variables. 78 # Die on uninitialized variables.
77 set -u 79 set -u
78 80
79 # Check for missing parts. 81 # Check for missing parts.
82 # For recovery image, only populate ROOT-A and KERN-A
83 # TODO(tgao): write a script to populate ROOT-B and KERN-B
80 ROOTFS_IMG="${IMAGEDIR}/rootfs.image" 84 ROOTFS_IMG="${IMAGEDIR}/rootfs.image"
81 if [[ ! -s ${ROOTFS_IMG} ]]; then 85 if [[ ! -s ${ROOTFS_IMG} ]]; then
82 error "Can't find ${ROOTFS_IMG}" 86 error "Can't find ${ROOTFS_IMG}"
83 exit 1 87 exit 1
84 fi 88 fi
85 89
86 KERNEL_IMG="${IMAGEDIR}/vmlinuz.image" 90 KERNEL_IMG="${IMAGEDIR}/vmlinuz.image"
87 if [[ ! -s ${KERNEL_IMG} ]]; then 91 if [[ ! -s ${KERNEL_IMG} ]]; then
88 error "Can't find ${KERNEL_IMG}" 92 error "Can't find ${KERNEL_IMG}"
89 exit 1 93 exit 1
90 fi 94 fi
91 95
92 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image" 96 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image"
93 if [[ ! -s ${STATEFUL_IMG} ]]; then 97 if [ ! -s ${STATEFUL_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then
94 error "Can't find ${STATEFUL_IMG}" 98 error "Can't find ${STATEFUL_IMG}"
95 exit 1 99 exit 1
96 fi 100 fi
97 101
98 ESP_IMG="${IMAGEDIR}/esp.image" 102 ESP_IMG="${IMAGEDIR}/esp.image"
99 if [[ ! -s ${ESP_IMG} ]]; then 103 if [ ! -s ${ESP_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then
100 error "Can't find ${ESP_IMG}" 104 error "Can't find ${ESP_IMG}"
101 exit 1 105 exit 1
102 fi 106 fi
103 107
104 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM 108 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM
105 # systems will use a U-Boot script temporarily, but it goes in the same place. 109 # systems will use a U-Boot script temporarily, but it goes in the same place.
106 if [[ "$ARCH" = "arm" ]]; then 110 if [[ "$ARCH" = "arm" ]]; then
107 PMBRCODE=/dev/zero 111 PMBRCODE=/dev/zero
108 else 112 else
109 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) 113 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin)
110 fi 114 fi
111 115
112 # Create the GPT. This has the side-effect of setting some global vars 116 # Create the GPT. This has the side-effect of setting some global vars
113 # describing the partition table entries (see the comments in the source). 117 # describing the partition table entries (see the comments in the source).
114 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG 118 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG \
119 false $FLAGS_recovery
115 120
116 if [[ "$ARCH" = "arm" ]]; then 121 if [[ "$ARCH" = "arm" ]]; then
117 # assume /dev/mmcblk1. we could not get this from ${OUTDEV} 122 # assume /dev/mmcblk1. we could not get this from ${OUTDEV}
118 DEVICE=1 123 DEVICE=1
119 MBR_SCRIPT_UIMG=$(make_arm_mbr \ 124 MBR_SCRIPT_UIMG=$(make_arm_mbr \
120 ${START_KERN_A} \ 125 ${START_KERN_A} \
121 ${NUM_KERN_SECTORS} \ 126 ${NUM_KERN_SECTORS} \
122 ${DEVICE} \ 127 ${DEVICE} \
123 "${FLAGS_arm_extra_bootargs}") 128 "${FLAGS_arm_extra_bootargs}")
124 sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \ 129 sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \
(...skipping 20 matching lines...) Expand all
145 echo "Copying rootfs..." 150 echo "Copying rootfs..."
146 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A } 151 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A }
147 152
148 echo "Copying EFI system partition..." 153 echo "Copying EFI system partition..."
149 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP} 154 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP}
150 155
151 # Clean up temporary files. 156 # Clean up temporary files.
152 if [[ -n "${MBR_IMG:-}" ]]; then 157 if [[ -n "${MBR_IMG:-}" ]]; then
153 rm "${MBR_IMG}" 158 rm "${MBR_IMG}"
154 fi 159 fi
OLDNEW
« no previous file with comments | « src/platform/installer/chromeos-common.sh ('k') | src/scripts/build_image » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698