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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 "Use INSTALL_MASK to shrink the resulting image." | 63 "Use INSTALL_MASK to shrink the resulting image." |
64 DEFINE_integer jobs -1 \ | 64 DEFINE_integer jobs -1 \ |
65 "How many packages to build in parallel at maximum." | 65 "How many packages to build in parallel at maximum." |
66 DEFINE_boolean statefuldev ${FLAGS_TRUE} \ | 66 DEFINE_boolean statefuldev ${FLAGS_TRUE} \ |
67 "Install development packages on stateful partition rather than the rootfs" | 67 "Install development packages on stateful partition rather than the rootfs" |
68 DEFINE_string to "" \ | 68 DEFINE_string to "" \ |
69 "The target image file or device" | 69 "The target image file or device" |
70 DEFINE_boolean factory_install ${FLAGS_FALSE} \ | 70 DEFINE_boolean factory_install ${FLAGS_FALSE} \ |
71 "Build a smaller image to overlay the factory install shim on; this argument \ | 71 "Build a smaller image to overlay the factory install shim on; this argument \ |
72 is also required in image_to_usb." | 72 is also required in image_to_usb." |
73 DEFINE_boolean dev_install ${FLAGS_FALSE} \ | |
74 "Build a smaller image to overlay the dev recovery install shim on" | |
75 DEFINE_integer rootfs_partition_size 1024 \ | 73 DEFINE_integer rootfs_partition_size 1024 \ |
76 "rootfs partition size in MiBs." | 74 "rootfs partition size in MiBs." |
77 DEFINE_integer rootfs_size 850 \ | 75 DEFINE_integer rootfs_size 850 \ |
78 "rootfs filesystem size in MiBs." | 76 "rootfs filesystem size in MiBs." |
79 # ceil(0.1 * rootfs_size) is a good minimum. | 77 # ceil(0.1 * rootfs_size) is a good minimum. |
80 DEFINE_integer rootfs_hash_pad 8 \ | 78 DEFINE_integer rootfs_hash_pad 8 \ |
81 "MiBs reserved at the end of the rootfs image." | 79 "MiBs reserved at the end of the rootfs image." |
82 DEFINE_integer statefulfs_size 1024 \ | 80 DEFINE_integer statefulfs_size 1024 \ |
83 "stateful filesystem size in MiBs." | 81 "stateful filesystem size in MiBs." |
84 DEFINE_boolean preserve ${FLAGS_FALSE} \ | 82 DEFINE_boolean preserve ${FLAGS_FALSE} \ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 fi | 135 fi |
138 info "No blacklisted packages found." | 136 info "No blacklisted packages found." |
139 } | 137 } |
140 | 138 |
141 check_blacklist | 139 check_blacklist |
142 | 140 |
143 # TODO(petkov): Remove along with the --move_to_etc flag support once the | 141 # TODO(petkov): Remove along with the --move_to_etc flag support once the |
144 # transition dust settles. | 142 # transition dust settles. |
145 "${SCRIPTS_DIR}"/set_shared_user_password.sh --move_to_etc | 143 "${SCRIPTS_DIR}"/set_shared_user_password.sh --move_to_etc |
146 | 144 |
147 # Verify user didn't specify incompatible flags for dev install shim | 145 # TODO(vlaviano): validate flags |
jrbarnette
2011/03/16 01:01:46
What's this about? If the comment is actually rel
Vince Laviano
2011/03/16 01:21:16
The code that I deleted from here was examining a
| |
148 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] && | |
149 [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then | |
150 die "Incompatible flags: --factory_install and --dev_install cannot be \ | |
151 both set to True. Please specify one or none." | |
152 fi | |
153 | 146 |
154 INSTALL_MASK="" | 147 INSTALL_MASK="" |
155 if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then | 148 if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then |
156 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" | 149 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" |
157 fi | 150 fi |
158 | 151 |
159 # Reduce the size of factory install shim. | 152 # Reduce the size of factory install shim. |
160 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] || | 153 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
161 [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then | 154 # Disable --withdev flag when --factory_install is set to True. Otherwise, the |
162 # Disable --withdev flag when --*_install is set to True. Otherwise, the | |
163 # dev image produced will be based on install shim, rather than a pristine | 155 # dev image produced will be based on install shim, rather than a pristine |
164 # image | 156 # image |
165 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then | 157 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
166 info "Incompatible flags: --withdev and --dev_install or --factory_install \ | 158 info "Incompatible flags: --withdev and --factory_install cannot both be \ |
167 cannot be both set to True. Reset --withdev to False." | 159 set to True. Resetting --withdev to False." |
168 FLAGS_withdev=${FLAGS_FALSE} | 160 FLAGS_withdev=${FLAGS_FALSE} |
169 fi | 161 fi |
170 | 162 |
171 # TODO: Build a separated ebuild for the install shim to reduce size. | 163 # TODO: Build a separated ebuild for the install shim to reduce size. |
172 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" | 164 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" |
173 | 165 |
174 info "Fixing the rootfs size at 300 MiB for install shim" | 166 info "Fixing the rootfs size at 300 MiB for install shim" |
175 FLAGS_rootfs_size=280 | 167 FLAGS_rootfs_size=280 |
176 FLAGS_rootfs_partition_size=300 | 168 FLAGS_rootfs_partition_size=300 |
177 info "Fixing the statefulfs size at 140 MiB for install shim" | 169 info "Fixing the statefulfs size at 140 MiB for install shim" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 | 213 |
222 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 214 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
223 | 215 |
224 # If we are creating a developer image, also create a pristine image with a | 216 # If we are creating a developer image, also create a pristine image with a |
225 # different name. | 217 # different name. |
226 DEVELOPER_IMAGE_NAME= | 218 DEVELOPER_IMAGE_NAME= |
227 PRISTINE_IMAGE_NAME=chromiumos_image.bin | 219 PRISTINE_IMAGE_NAME=chromiumos_image.bin |
228 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then | 220 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
229 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin | 221 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin |
230 DEVELOPER_IMAGE_NAME=chromiumos_image.bin | 222 DEVELOPER_IMAGE_NAME=chromiumos_image.bin |
231 elif [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ]; then | 223 # Rename pristine image for factory install shim |
232 # Rename pristine images for install shims | |
233 PRISTINE_IMAGE_NAME=dev_install_shim.bin | |
234 elif [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then | 224 elif [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
235 PRISTINE_IMAGE_NAME=factory_install_shim.bin | 225 PRISTINE_IMAGE_NAME=factory_install_shim.bin |
236 fi | 226 fi |
237 | 227 |
238 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" | 228 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" |
239 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" | 229 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" |
240 | 230 |
241 BOARD="${FLAGS_board}" | 231 BOARD="${FLAGS_board}" |
242 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" | 232 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" |
243 | 233 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 info "Fixing python symlinks for developer and test images." | 470 info "Fixing python symlinks for developer and test images." |
481 local python_paths="/usr/bin/python /usr/local/bin/python \ | 471 local python_paths="/usr/bin/python /usr/local/bin/python \ |
482 /usr/bin/python2 /usr/local/bin/python2" | 472 /usr/bin/python2 /usr/local/bin/python2" |
483 for path in ${python_paths}; do | 473 for path in ${python_paths}; do |
484 sudo rm -f "${ROOT_FS_DIR}${path}" | 474 sudo rm -f "${ROOT_FS_DIR}${path}" |
485 sudo ln -s ${python_path} "${ROOT_FS_DIR}${path}" | 475 sudo ln -s ${python_path} "${ROOT_FS_DIR}${path}" |
486 done | 476 done |
487 fi | 477 fi |
488 | 478 |
489 # Check that the image has been correctly created. Only do it if not | 479 # Check that the image has been correctly created. Only do it if not |
490 # building a factory install image and not a dev install shim, as the | 480 # building a factory install shim, as the INSTALL_MASK for it will make |
491 # INSTALL_MASK for it will make test_image fail. | 481 # test_image fail. |
492 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ] && | 482 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then |
493 [ ${FLAGS_dev_install} -eq ${FLAGS_FALSE} ] ; then | |
494 "${SCRIPTS_DIR}/test_image" \ | 483 "${SCRIPTS_DIR}/test_image" \ |
495 --root="${ROOT_FS_DIR}" \ | 484 --root="${ROOT_FS_DIR}" \ |
496 --target="${ARCH}" | 485 --target="${ARCH}" |
497 fi | 486 fi |
498 echo "Developer image built and stored at ${image_name}" | 487 echo "Developer image built and stored at ${image_name}" |
499 | 488 |
500 trap - EXIT | 489 trap - EXIT |
501 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 490 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
502 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 491 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
503 } | 492 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 enable_rootfs_verification="--enable_rootfs_verification" | 653 enable_rootfs_verification="--enable_rootfs_verification" |
665 fi | 654 fi |
666 | 655 |
667 ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ | 656 ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ |
668 --arch=${ARCH} \ | 657 --arch=${ARCH} \ |
669 --to="${ROOT_FS_DIR}"/boot \ | 658 --to="${ROOT_FS_DIR}"/boot \ |
670 --boot_args="${FLAGS_boot_args}" \ | 659 --boot_args="${FLAGS_boot_args}" \ |
671 --install \ | 660 --install \ |
672 ${enable_rootfs_verification} | 661 ${enable_rootfs_verification} |
673 | 662 |
674 # Don't test the factory install shim or the dev install shim | 663 # Don't test the factory install shim |
675 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ] && | 664 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then |
676 [ ${FLAGS_dev_install} -eq ${FLAGS_FALSE} ]; then | |
677 # Check that the image has been correctly created. | 665 # Check that the image has been correctly created. |
678 "${SCRIPTS_DIR}/test_image" \ | 666 "${SCRIPTS_DIR}/test_image" \ |
679 --root="${ROOT_FS_DIR}" \ | 667 --root="${ROOT_FS_DIR}" \ |
680 --target="${ARCH}" | 668 --target="${ARCH}" |
681 fi | 669 fi |
682 | 670 |
683 # Clean up symlinks so they work on a running target rooted at "/". | 671 # Clean up symlinks so they work on a running target rooted at "/". |
684 # Here development packages are rooted at /usr/local. However, do not | 672 # Here development packages are rooted at /usr/local. However, do not |
685 # create /usr/local or /var on host (already exist on target). | 673 # create /usr/local or /var on host (already exist on target). |
686 setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" | 674 setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 # cros_make_image_bootable. | 743 # cros_make_image_bootable. |
756 create_boot_desc | 744 create_boot_desc |
757 | 745 |
758 if [[ -f ${PRISTINE_IMG} ]] ; then | 746 if [[ -f ${PRISTINE_IMG} ]] ; then |
759 update_base_packages ${PRISTINE_IMAGE_NAME} | 747 update_base_packages ${PRISTINE_IMAGE_NAME} |
760 else | 748 else |
761 create_base_image ${PRISTINE_IMAGE_NAME} | 749 create_base_image ${PRISTINE_IMAGE_NAME} |
762 fi | 750 fi |
763 | 751 |
764 USE_DEV_KEYS= | 752 USE_DEV_KEYS= |
765 if [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] || \ | 753 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
766 [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then | |
767 USE_DEV_KEYS="--use_dev_keys" | 754 USE_DEV_KEYS="--use_dev_keys" |
768 fi | 755 fi |
769 | 756 |
770 # Place flags before positional args | 757 # Place flags before positional args |
771 ${SCRIPTS_DIR}/bin/cros_make_image_bootable "${OUTPUT_DIR}" \ | 758 ${SCRIPTS_DIR}/bin/cros_make_image_bootable "${OUTPUT_DIR}" \ |
772 "${PRISTINE_IMAGE_NAME}" \ | 759 "${PRISTINE_IMAGE_NAME}" \ |
773 ${USE_DEV_KEYS} \ | 760 ${USE_DEV_KEYS} \ |
774 ${crosbug12352_flag} | 761 ${crosbug12352_flag} |
775 | 762 |
776 # FIXME Test x86 image, and test arm image if enabled; | 763 # FIXME Test x86 image, and test arm image if enabled; |
777 # should unconditionally test an image after crosbug12352 is fixed | 764 # should unconditionally test an image after crosbug12352 is fixed |
778 if [[ "${ARCH}" = "x86" ]] || | 765 if [[ "${ARCH}" = "x86" ]] || |
779 [[ "${ARCH}" = "arm" && | 766 [[ "${ARCH}" = "arm" && |
780 "${FLAGS_crosbug12352_arm_kernel_signing}" -eq "${FLAGS_TRUE}" ]]; then | 767 "${FLAGS_crosbug12352_arm_kernel_signing}" -eq "${FLAGS_TRUE}" ]]; then |
781 BOOT_FLAG= | 768 BOOT_FLAG= |
782 if [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] || | 769 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
783 [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then | |
784 BOOT_FLAG="-b 1" # BOOT_FLAG_DEVELOPER value defined in load_kernel_fw.h | 770 BOOT_FLAG="-b 1" # BOOT_FLAG_DEVELOPER value defined in load_kernel_fw.h |
785 info "--dev_install set, pass BOOT_FLAG_DEVELOPER flag to load_kernel_test" | 771 info "--factory_install set, pass BOOT_FLAG_DEVELOPER flag to \ |
772 load_kernel_test" | |
786 fi | 773 fi |
787 | 774 |
788 # Verify the final image. | 775 # Verify the final image. |
789 load_kernel_test "${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" \ | 776 load_kernel_test "${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" \ |
790 "${DEVKEYSDIR}/recovery_key.vbpubk" ${BOOT_FLAG} | 777 "${DEVKEYSDIR}/recovery_key.vbpubk" ${BOOT_FLAG} |
791 fi | 778 fi |
792 | 779 |
793 # Create a developer image based on the chromium os base image. | 780 # Create a developer image based on the chromium os base image. |
794 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then | 781 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then |
795 if [[ ! -f ${DEVELOPER_IMG} ]] ; then | 782 if [[ ! -f ${DEVELOPER_IMG} ]] ; then |
(...skipping 24 matching lines...) Expand all Loading... | |
820 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 807 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
821 fi | 808 fi |
822 | 809 |
823 print_time_elapsed | 810 print_time_elapsed |
824 | 811 |
825 echo "To copy to USB keyfob, do something like:" | 812 echo "To copy to USB keyfob, do something like:" |
826 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 813 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
827 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 814 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
828 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 815 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
829 echo "from the scripts directory where you entered the chroot." | 816 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |