Add a --to option to build_image

That way we can directly build an image onto a usb stick/sd card without a separate step.
Also, add mounting of /sys into the chroot that is needed by build_gpt on a block device.

Review URL: http://codereview.chromium.org/1521012
This commit is contained in:
Antoine Labour 2010-04-01 15:57:57 -07:00
parent cd78944051
commit e9e585f330
3 changed files with 21 additions and 5 deletions

View File

@ -144,15 +144,22 @@ install_gpt $OUTDEV $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE
# Emit helpful scripts for testers, etc.
${SCRIPTS_DIR}/emit_gpt_scripts.sh "${OUTDEV}" "${IMAGEDIR}"
sudo=
if [ ! -w "$OUTDEV" ] ; then
# use sudo when writing to a block device.
sudo=sudo
fi
# Now populate the partitions.
echo "Copying stateful partition..."
dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_STATEFUL}
$sudo dd if=${STATEFUL_IMG} of=${OUTDEV} conv=notrunc bs=512 \
seek=${START_STATEFUL}
echo "Copying kernel..."
dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A}
$sudo dd if=${KERNEL_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_KERN_A}
echo "Copying rootfs..."
dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A}
$sudo dd if=${ROOTFS_IMG} of=${OUTDEV} conv=notrunc bs=512 seek=${START_ROOTFS_A}
# Clean up temporary files.
if [[ -n "${MBR_IMG:-}" ]]; then

View File

@ -37,6 +37,8 @@ DEFINE_integer jobs -1 \
"How many packages to build in parallel at maximum."
DEFINE_boolean statefuldev $FLAGS_FALSE \
"Install development packages on stateful partition -- still experimental"
DEFINE_string to "" \
"The target image file or device"
DEFINE_boolean withtest $FLAGS_FALSE \
"Include packages required for testing and prepare image for testing"
@ -69,7 +71,7 @@ IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}"
OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}"
ROOT_FS_DIR="${OUTPUT_DIR}/rootfs"
ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image"
OUTPUT_IMG="${OUTPUT_DIR}/chromiumos_image.bin"
OUTPUT_IMG=${FLAGS_to:-${OUTPUT_DIR}/chromiumos_image.bin}
BOARD="${FLAGS_board}"
BOARD_ROOT="${FLAGS_build_root}/${BOARD}"

View File

@ -84,6 +84,13 @@ function setup_env {
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/sys")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then
sudo mount none -t sysfs "$MOUNTED_PATH" || \
die "Could not mount $MOUNTED_PATH"
fi
MOUNTED_PATH="$(readlink -f "$FLAGS_chroot/dev/pts")"
if [ -z "$(mount | grep -F "on $MOUNTED_PATH ")" ]
then