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

Side by Side Diff: build_image

Issue 3155025: build_image: make sure the factory_image size is propagated (Closed) Base URL: http://src.chromium.org/git/crosutils.git
Patch Set: rebasing Created 10 years, 4 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 | « no previous file | no next file » | 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) 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 DEFINE_string to "" \ 43 DEFINE_string to "" \
44 "The target image file or device" 44 "The target image file or device"
45 DEFINE_boolean factory_install ${FLAGS_FALSE} \ 45 DEFINE_boolean factory_install ${FLAGS_FALSE} \
46 "Build a smaller image to overlay the factory install shim on; this argument \ 46 "Build a smaller image to overlay the factory install shim on; this argument \
47 is also required in image_to_usb." 47 is also required in image_to_usb."
48 DEFINE_boolean dev_install ${FLAGS_FALSE} \ 48 DEFINE_boolean dev_install ${FLAGS_FALSE} \
49 "Build a smaller image to overlay the dev recovery install shim on" 49 "Build a smaller image to overlay the dev recovery install shim on"
50 DEFINE_string arm_extra_bootargs "" \ 50 DEFINE_string arm_extra_bootargs "" \
51 "Additional command line options to pass to the ARM kernel." 51 "Additional command line options to pass to the ARM kernel."
52 DEFINE_integer rootfs_partition_size 1024 \ 52 DEFINE_integer rootfs_partition_size 1024 \
53 "rootfs parition size in MBs." 53 "rootfs partition size in MiBs."
54 DEFINE_integer rootfs_size 720 \ 54 DEFINE_integer rootfs_size 720 \
55 "rootfs filesystem size in MBs." 55 "rootfs filesystem size in MiBs."
56 # ceil(0.1 * rootfs_size) is a good minimum. 56 # ceil(0.1 * rootfs_size) is a good minimum.
57 DEFINE_integer rootfs_hash_pad 8 \ 57 DEFINE_integer rootfs_hash_pad 8 \
58 "MBs reserved at the end of the rootfs image." 58 "MiBs reserved at the end of the rootfs image."
59 DEFINE_integer statefulfs_size 1024 \ 59 DEFINE_integer statefulfs_size 1024 \
60 "stateful filesystem size in MBs." 60 "stateful filesystem size in MiBs."
61 DEFINE_boolean preserve ${FLAGS_FALSE} \ 61 DEFINE_boolean preserve ${FLAGS_FALSE} \
62 "Attempt to preserve the previous build image if one can be found (unstable, \ 62 "Attempt to preserve the previous build image if one can be found (unstable, \
63 kernel/firmware not updated)" 63 kernel/firmware not updated)"
64 DEFINE_boolean fast ${DEFAULT_FAST} \ 64 DEFINE_boolean fast ${DEFAULT_FAST} \
65 "Call many emerges in parallel" 65 "Call many emerges in parallel"
66 66
67 DEFINE_string usb_disk /dev/sdb3 \ 67 DEFINE_string usb_disk /dev/sdb3 \
68 "Path syslinux should use to do a usb boot. Default: /dev/sdb3" 68 "Path syslinux should use to do a usb boot. Default: /dev/sdb3"
69 69
70 DEFINE_boolean enable_rootfs_verification ${FLAGS_FALSE} \ 70 DEFINE_boolean enable_rootfs_verification ${FLAGS_FALSE} \
(...skipping 19 matching lines...) Expand all
90 # so will die prematurely if 'set -e' is specified before now. 90 # so will die prematurely if 'set -e' is specified before now.
91 set -e 91 set -e
92 92
93 if [ -z "${FLAGS_board}" ] ; then 93 if [ -z "${FLAGS_board}" ] ; then
94 error "--board is required." 94 error "--board is required."
95 exit 1 95 exit 1
96 fi 96 fi
97 97
98 if [ "$((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad))" -gt \ 98 if [ "$((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad))" -gt \
99 "${FLAGS_rootfs_partition_size}" ] ; then 99 "${FLAGS_rootfs_partition_size}" ] ; then
100 error "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MB) is \ 100 error "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MiB) is \
101 bigger than partition (${FLAGS_rootfs_partition_size} MB)." 101 bigger than partition (${FLAGS_rootfs_partition_size} MiB)."
102 exit 1 102 exit 1
103 fi 103 fi
104 104
105 # Verify user didn't specify incompatible flags for dev install shim 105 # Verify user didn't specify incompatible flags for dev install shim
106 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] && 106 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] &&
107 [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then 107 [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then
108 error "Incompatible flags: --factory_install and --dev_install cannot be \ 108 error "Incompatible flags: --factory_install and --dev_install cannot be \
109 both set to True. Please specify one or none." 109 both set to True. Please specify one or none."
110 exit 1 110 exit 1
111 fi 111 fi
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 446
447 # Create and format the root file system. 447 # Create and format the root file system.
448 448
449 # Check for loop device before creating image. 449 # Check for loop device before creating image.
450 LOOP_DEV=$(sudo losetup -f) 450 LOOP_DEV=$(sudo losetup -f)
451 if [ -z "${LOOP_DEV}" ] ; then 451 if [ -z "${LOOP_DEV}" ] ; then
452 echo "No free loop device. Free up a loop device or reboot. exiting. " 452 echo "No free loop device. Free up a loop device or reboot. exiting. "
453 exit 1 453 exit 1
454 fi 454 fi
455 455
456 # Create root file system disk image to fit on a 1GB memory stick. 456 # Create root file system disk image.
457 # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes . 457 ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size}))
458 # Minimize rootfs size for dev install shim and factory installer
459 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ||
460 [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then
461 ROOT_SIZE_BYTES=$((1024 * 1024 * 300))
462 else
463 ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size}))
464 fi
465 458
466 # Pad out for the hash tree. 459 # Pad out for the hash tree.
467 ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) 460 ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024))
468 info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data" 461 info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data"
469 462
470 dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \ 463 dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \
471 seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1)) 464 seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1))
472 sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" 465 sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}"
473 # Specify a block size and block count to avoid using the hash pad. 466 # Specify a block size and block count to avoid using the hash pad.
474 sudo mkfs.ext3 -b 4096 "${LOOP_DEV}" "$((ROOT_SIZE_BYTES / 4096))" 467 sudo mkfs.ext3 -b 4096 "${LOOP_DEV}" "$((ROOT_SIZE_BYTES / 4096))"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 cp ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR} 641 cp ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR}
649 642
650 # Copy forward the developer image, if we already copied forward the base. 643 # Copy forward the developer image, if we already copied forward the base.
651 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]] && \ 644 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]] && \
652 [[ -f ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ]] ; then 645 [[ -f ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ]] ; then
653 cp ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ${OUTPUT_DIR} 646 cp ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ${OUTPUT_DIR}
654 fi 647 fi
655 fi 648 fi
656 fi 649 fi
657 650
651 # Minimize rootfs size for dev install shim and factory installer
652 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} -o \
653 ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then
654 info "Fixing the rootfs size at 300 MiB for the factory installer"
655 FLAGS_rootfs_size=300
656 fi
657
658 # Create the boot.desc file which stores the build-time configuration 658 # Create the boot.desc file which stores the build-time configuration
659 # information needed for making the image bootable after creation with 659 # information needed for making the image bootable after creation with
660 # cros_make_image_bootable. 660 # cros_make_image_bootable.
661 create_boot_desc 661 create_boot_desc
662 662
663 if [[ -f ${PRISTINE_IMG} ]] ; then 663 if [[ -f ${PRISTINE_IMG} ]] ; then
664 update_base_packages ${PRISTINE_IMAGE_NAME} 664 update_base_packages ${PRISTINE_IMAGE_NAME}
665 else 665 else
666 create_base_image ${PRISTINE_IMAGE_NAME} 666 create_base_image ${PRISTINE_IMAGE_NAME}
667 fi 667 fi
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" 716 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}"
717 fi 717 fi
718 718
719 print_time_elapsed 719 print_time_elapsed
720 720
721 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" 721 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:"
722 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" 722 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX"
723 echo "To convert to VMWare image, INSIDE the chroot, do something like:" 723 echo "To convert to VMWare image, INSIDE the chroot, do something like:"
724 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" 724 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}"
725 echo "from the scripts directory where you entered the chroot." 725 echo "from the scripts directory where you entered the chroot."
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698