OLD | NEW |
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 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 error "Can't find ${KERNEL_IMG}" | 93 error "Can't find ${KERNEL_IMG}" |
94 exit 1 | 94 exit 1 |
95 fi | 95 fi |
96 | 96 |
97 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image" | 97 STATEFUL_IMG="${IMAGEDIR}/stateful_partition.image" |
98 if [ ! -s ${STATEFUL_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then | 98 if [ ! -s ${STATEFUL_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then |
99 error "Can't find ${STATEFUL_IMG}" | 99 error "Can't find ${STATEFUL_IMG}" |
100 exit 1 | 100 exit 1 |
101 fi | 101 fi |
102 | 102 |
| 103 OEM_IMG="${IMAGEDIR}/partner_partition.image" |
| 104 if [[ ! -s ${OEM_IMG} ]]; then |
| 105 error "Can't find ${OEM_IMG}" |
| 106 exit 1 |
| 107 fi |
| 108 |
103 ESP_IMG="${IMAGEDIR}/esp.image" | 109 ESP_IMG="${IMAGEDIR}/esp.image" |
104 if [ ! -s ${ESP_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then | 110 if [ ! -s ${ESP_IMG} ] && [ ${FLAGS_recovery} -eq $FLAGS_FALSE ]; then |
105 error "Can't find ${ESP_IMG}" | 111 error "Can't find ${ESP_IMG}" |
106 exit 1 | 112 exit 1 |
107 fi | 113 fi |
108 | 114 |
109 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM | 115 # We'll need some code to put in the PMBR, for booting on legacy BIOS. Some ARM |
110 # systems will use a U-Boot script temporarily, but it goes in the same place. | 116 # systems will use a U-Boot script temporarily, but it goes in the same place. |
111 if [[ "$ARCH" = "arm" ]]; then | 117 if [[ "$ARCH" = "arm" ]]; then |
112 PMBRCODE=/dev/zero | 118 PMBRCODE=/dev/zero |
113 else | 119 else |
114 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) | 120 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) |
115 fi | 121 fi |
116 | 122 |
117 # Create the GPT. This has the side-effect of setting some global vars | 123 # Create the GPT. This has the side-effect of setting some global vars |
118 # describing the partition table entries (see the comments in the source). | 124 # describing the partition table entries (see the comments in the source). |
119 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG \ | 125 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG \ |
120 false $FLAGS_recovery $FLAGS_rootfs_partition_size | 126 false $FLAGS_recovery $FLAGS_rootfs_partition_size |
121 | 127 |
122 if [[ "$ARCH" = "arm" ]]; then | 128 if [[ "$ARCH" = "arm" ]]; then |
123 # assume /dev/mmcblk1. we could not get this from ${OUTDEV} | 129 # assume /dev/mmcblk1. we could not get this from ${OUTDEV} |
124 DEVICE=1 | 130 DEVICE=1 |
125 MBR_SCRIPT_UIMG=$(make_arm_mbr \ | 131 MBR_SCRIPT_UIMG=$(make_arm_mbr \ |
126 ${START_KERN_A} \ | 132 ${START_KERN_A} \ |
127 ${NUM_KERN_SECTORS} \ | 133 ${NUM_KERN_SECTORS} \ |
128 ${DEVICE} \ | 134 ${DEVICE} \ |
129 "${FLAGS_arm_extra_bootargs}") | 135 "${FLAGS_arm_extra_bootargs}") |
130 sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \ | 136 sudo dd bs=1 count=`stat --printf="%s" ${MBR_SCRIPT_UIMG}` \ |
131 if="$MBR_SCRIPT_UIMG" of=${OUTDEV} conv=notrunc | 137 if="$MBR_SCRIPT_UIMG" of=${OUTDEV} conv=notrunc |
132 fi | 138 fi |
133 | 139 |
134 # Emit helpful scripts for testers, etc. | 140 # Emit helpful scripts for testers, etc. |
135 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" | 141 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" |
136 | 142 |
137 sudo= | 143 sudo= |
138 if [ ! -w "$OUTDEV" ] ; then | 144 if [ ! -w "$OUTDEV" ] ; then |
139 # use sudo when writing to a block device. | 145 # use sudo when writing to a block device. |
140 sudo=sudo | 146 sudo=sudo |
141 fi | 147 fi |
142 | 148 |
143 # Now populate the partitions. | 149 # Now populate the partitions. |
144 echo "Copying stateful partition..." | 150 echo "Copying stateful partition..." |
145 $sudo dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 \ | 151 $sudo dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
146 seek=${START_STATEFUL} | 152 seek=${START_STATEFUL} |
147 | 153 |
| 154 echo "Copying OEM partition..." |
| 155 $sudo dd if=${OEM_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_OEM} |
| 156 |
148 echo "Copying kernel..." | 157 echo "Copying kernel..." |
149 $sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} | 158 $sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} |
150 | 159 |
151 echo "Copying rootfs..." | 160 echo "Copying rootfs..." |
152 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ | 161 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
153 seek=${START_ROOTFS_A} | 162 seek=${START_ROOTFS_A} |
154 | 163 |
155 # TODO(tgao): write a script to populate ROOT-B and KERN-B with user-specified | 164 # TODO(tgao): write a script to populate ROOT-B and KERN-B with user-specified |
156 # rootfs and kernel. Do NOT remove if block below until then (otherwise | 165 # rootfs and kernel. Do NOT remove if block below until then (otherwise |
157 # chromeos-installer will fail b/c it expects to install from partition B) | 166 # chromeos-installer will fail b/c it expects to install from partition B) |
158 if [ ${FLAGS_recovery} -eq $FLAGS_TRUE ]; then | 167 if [ ${FLAGS_recovery} -eq $FLAGS_TRUE ]; then |
159 echo "Copying kernel B..." | 168 echo "Copying kernel B..." |
160 $sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 \ | 169 $sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
161 seek=${START_KERN_B} | 170 seek=${START_KERN_B} |
162 | 171 |
163 echo "Copying rootfs B..." | 172 echo "Copying rootfs B..." |
164 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ | 173 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
165 seek=${START_ROOTFS_B} | 174 seek=${START_ROOTFS_B} |
166 fi | 175 fi |
167 | 176 |
168 echo "Copying EFI system partition..." | 177 echo "Copying EFI system partition..." |
169 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP} | 178 $sudo dd if=${ESP_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ESP} |
170 | 179 |
171 # Clean up temporary files. | 180 # Clean up temporary files. |
172 if [[ -n "${MBR_IMG:-}" ]]; then | 181 if [[ -n "${MBR_IMG:-}" ]]; then |
173 rm "${MBR_IMG}" | 182 rm "${MBR_IMG}" |
174 fi | 183 fi |
OLD | NEW |