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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) | 137 PMBRCODE=$(readlink -f /usr/share/syslinux/gptmbr.bin) |
138 fi | 138 fi |
139 | 139 |
140 # Create the GPT. This has the side-effect of setting some global vars | 140 # Create the GPT. This has the side-effect of setting some global vars |
141 # describing the partition table entries (see the comments in the source). | 141 # describing the partition table entries (see the comments in the source). |
142 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE | 142 install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE |
143 | 143 |
144 # Emit helpful scripts for testers, etc. | 144 # Emit helpful scripts for testers, etc. |
145 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" | 145 ${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}" |
146 | 146 |
147 sudo= | |
148 if [ ! -w "$OUTDEV" ] ; then | |
adlr
2010/04/01 22:47:07
maybe [ -b "$OUTDEV" ] is better?
-b means "it is
| |
149 # use sudo when writing to a block device. | |
150 sudo=sudo | |
151 fi | |
152 | |
147 # Now populate the partitions. | 153 # Now populate the partitions. |
148 echo "Copying stateful partition..." | 154 echo "Copying stateful partition..." |
149 dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_STATEFUL} | 155 $sudo dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 \ |
156 seek=${START_STATEFUL} | |
150 | 157 |
151 echo "Copying kernel..." | 158 echo "Copying kernel..." |
152 dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} | 159 $sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A} |
153 | 160 |
154 echo "Copying rootfs..." | 161 echo "Copying rootfs..." |
155 dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A} | 162 $sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A } |
156 | 163 |
157 # Clean up temporary files. | 164 # Clean up temporary files. |
158 if [[ -n "${MBR_IMG:-}" ]]; then | 165 if [[ -n "${MBR_IMG:-}" ]]; then |
159 rm "${MBR_IMG}" | 166 rm "${MBR_IMG}" |
160 fi | 167 fi |
OLD | NEW |