| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 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 # Script to build a bootable keyfob-based chromeos system image from within | 7 # Script to build a bootable keyfob-based chromeos system image from within |
| 8 # a chromiumos setup. This assumes that all needed packages have been built into | 8 # a chromiumos setup. This assumes that all needed packages have been built into |
| 9 # the given target's root with binary packages turned on. This script will | 9 # the given target's root with binary packages turned on. This script will |
| 10 # build the Chrome OS image using only pre-built binary packages. | 10 # build the Chrome OS image using only pre-built binary packages. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 "The target image file or device" | 41 "The target image file or device" |
| 42 DEFINE_boolean factory_install ${FLAGS_FALSE} \ | 42 DEFINE_boolean factory_install ${FLAGS_FALSE} \ |
| 43 "Build a smaller image to overlay the factory install shim on; this argument \ | 43 "Build a smaller image to overlay the factory install shim on; this argument \ |
| 44 is also required in image_to_usb." | 44 is also required in image_to_usb." |
| 45 DEFINE_string arm_extra_bootargs "" \ | 45 DEFINE_string arm_extra_bootargs "" \ |
| 46 "Additional command line options to pass to the ARM kernel." | 46 "Additional command line options to pass to the ARM kernel." |
| 47 DEFINE_integer rootfs_partition_size 1024 \ | 47 DEFINE_integer rootfs_partition_size 1024 \ |
| 48 "rootfs parition size in MBs." | 48 "rootfs parition size in MBs." |
| 49 DEFINE_integer rootfs_size 720 \ | 49 DEFINE_integer rootfs_size 720 \ |
| 50 "rootfs filesystem size in MBs." | 50 "rootfs filesystem size in MBs." |
| 51 DEFINE_integer statefulfs_size 1024 \ |
| 52 "stateful filesystem size in MBs." |
| 51 DEFINE_boolean preserve ${FLAGS_FALSE} \ | 53 DEFINE_boolean preserve ${FLAGS_FALSE} \ |
| 52 "Attempt to preserve the previous build image if one can be found (unstable, \ | 54 "Attempt to preserve the previous build image if one can be found (unstable, \ |
| 53 kernel/firmware not updated)" | 55 kernel/firmware not updated)" |
| 54 | 56 |
| 55 # Parse command line. | 57 # Parse command line. |
| 56 FLAGS "$@" || exit 1 | 58 FLAGS "$@" || exit 1 |
| 57 eval set -- "${FLAGS_ARGV}" | 59 eval set -- "${FLAGS_ARGV}" |
| 58 | 60 |
| 59 # Only now can we die on error. shflags functions leak non-zero error codes, | 61 # Only now can we die on error. shflags functions leak non-zero error codes, |
| 60 # so will die prematurely if 'set -e' is specified before now. | 62 # so will die prematurely if 'set -e' is specified before now. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 DISK_LABEL="C-KEYFOB" | 353 DISK_LABEL="C-KEYFOB" |
| 352 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${LOOP_DEV}" | 354 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${LOOP_DEV}" |
| 353 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" | 355 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" |
| 354 | 356 |
| 355 # Create stateful partition of the same size as the rootfs. | 357 # Create stateful partition of the same size as the rootfs. |
| 356 STATEFUL_LOOP_DEV=$(sudo losetup -f) | 358 STATEFUL_LOOP_DEV=$(sudo losetup -f) |
| 357 if [ -z "${STATEFUL_LOOP_DEV}" ] ; then | 359 if [ -z "${STATEFUL_LOOP_DEV}" ] ; then |
| 358 echo "No free loop device. Free up a loop device or reboot. exiting. " | 360 echo "No free loop device. Free up a loop device or reboot. exiting. " |
| 359 exit 1 | 361 exit 1 |
| 360 fi | 362 fi |
| 361 dd if=/dev/zero of="${STATEFUL_FS_IMG}" bs=1 count=1 seek=$((ROOT_SIZE_BYTES -
1)) | 363 STATEFUL_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_statefulfs_size})) |
| 364 dd if=/dev/zero of="${STATEFUL_FS_IMG}" bs=1 count=1 \ |
| 365 seek=$((STATEFUL_SIZE_BYTES - 1)) |
| 362 sudo losetup "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_IMG}" | 366 sudo losetup "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_IMG}" |
| 363 sudo mkfs.ext3 "${STATEFUL_LOOP_DEV}" | 367 sudo mkfs.ext3 "${STATEFUL_LOOP_DEV}" |
| 364 sudo tune2fs -L "C-STATE" -U "${UUID}" -c 0 -i 0 \ | 368 sudo tune2fs -L "C-STATE" -U "${UUID}" -c 0 -i 0 \ |
| 365 "${STATEFUL_LOOP_DEV}" | 369 "${STATEFUL_LOOP_DEV}" |
| 366 | 370 |
| 367 # Mount the stateful partition. | 371 # Mount the stateful partition. |
| 368 sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_DIR}" | 372 sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_DIR}" |
| 369 | 373 |
| 370 # Turn root file system into bootable image. | 374 # Turn root file system into bootable image. |
| 371 if [[ "${ARCH}" = "x86" ]]; then | 375 if [[ "${ARCH}" = "x86" ]]; then |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 580 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
| 577 fi | 581 fi |
| 578 | 582 |
| 579 print_time_elapsed | 583 print_time_elapsed |
| 580 | 584 |
| 581 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 585 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 582 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 586 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 583 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" | 587 echo "To convert to VMWare image, OUTSIDE the chroot, do something like:" |
| 584 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" | 588 echo " ./image_to_vmware.sh --from=${OUTSIDE_OUTPUT_DIR}" |
| 585 echo "from the scripts directory where you entered the chroot." | 589 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |