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 command line flags. Check for conflicting flags and |
148 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] && | 146 # reconcile them if possible. Exit with an error message otherwise. |
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 | 147 |
154 INSTALL_MASK="" | 148 INSTALL_MASK="" |
155 if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then | 149 if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then |
156 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" | 150 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" |
157 fi | 151 fi |
158 | 152 |
159 # Reduce the size of factory install shim. | 153 # Reduce the size of factory install shim. |
160 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] || | 154 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
161 [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then | 155 # 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 | 156 # dev image produced will be based on install shim, rather than a pristine |
164 # image | 157 # image |
165 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then | 158 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
166 info "Incompatible flags: --withdev and --dev_install or --factory_install \ | 159 info "Incompatible flags: --withdev and --factory_install cannot both be \ |
167 cannot be both set to True. Reset --withdev to False." | 160 set to True. Resetting --withdev to False." |
168 FLAGS_withdev=${FLAGS_FALSE} | 161 FLAGS_withdev=${FLAGS_FALSE} |
169 fi | 162 fi |
170 | 163 |
171 # TODO: Build a separated ebuild for the install shim to reduce size. | 164 # TODO: Build a separated ebuild for the install shim to reduce size. |
172 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" | 165 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" |
173 | 166 |
174 info "Fixing the rootfs size at 300 MiB for install shim" | 167 info "Fixing the rootfs size at 300 MiB for install shim" |
175 FLAGS_rootfs_size=280 | 168 FLAGS_rootfs_size=280 |
176 FLAGS_rootfs_partition_size=300 | 169 FLAGS_rootfs_partition_size=300 |
177 info "Fixing the statefulfs size at 140 MiB for install shim" | 170 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 | 214 |
222 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 215 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
223 | 216 |
224 # If we are creating a developer image, also create a pristine image with a | 217 # If we are creating a developer image, also create a pristine image with a |
225 # different name. | 218 # different name. |
226 DEVELOPER_IMAGE_NAME= | 219 DEVELOPER_IMAGE_NAME= |
227 PRISTINE_IMAGE_NAME=chromiumos_image.bin | 220 PRISTINE_IMAGE_NAME=chromiumos_image.bin |
228 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then | 221 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
229 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin | 222 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin |
230 DEVELOPER_IMAGE_NAME=chromiumos_image.bin | 223 DEVELOPER_IMAGE_NAME=chromiumos_image.bin |
231 elif [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ]; then | 224 # 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 | 225 elif [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
235 PRISTINE_IMAGE_NAME=factory_install_shim.bin | 226 PRISTINE_IMAGE_NAME=factory_install_shim.bin |
236 fi | 227 fi |
237 | 228 |
238 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" | 229 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" |
239 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" | 230 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" |
240 | 231 |
241 BOARD="${FLAGS_board}" | 232 BOARD="${FLAGS_board}" |
242 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" | 233 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" |
243 | 234 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 info "Fixing python symlinks for developer and test images." | 471 info "Fixing python symlinks for developer and test images." |
481 local python_paths="/usr/bin/python /usr/local/bin/python \ | 472 local python_paths="/usr/bin/python /usr/local/bin/python \ |
482 /usr/bin/python2 /usr/local/bin/python2" | 473 /usr/bin/python2 /usr/local/bin/python2" |
483 for path in ${python_paths}; do | 474 for path in ${python_paths}; do |
484 sudo rm -f "${ROOT_FS_DIR}${path}" | 475 sudo rm -f "${ROOT_FS_DIR}${path}" |
485 sudo ln -s ${python_path} "${ROOT_FS_DIR}${path}" | 476 sudo ln -s ${python_path} "${ROOT_FS_DIR}${path}" |
486 done | 477 done |
487 fi | 478 fi |
488 | 479 |
489 # Check that the image has been correctly created. Only do it if not | 480 # 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 | 481 # building a factory install shim, as the INSTALL_MASK for it will make |
491 # INSTALL_MASK for it will make test_image fail. | 482 # test_image fail. |
492 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ] && | 483 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]; then |
493 [ ${FLAGS_dev_install} -eq ${FLAGS_FALSE} ] ; then | |
494 "${SCRIPTS_DIR}/test_image" \ | 484 "${SCRIPTS_DIR}/test_image" \ |
495 --root="${ROOT_FS_DIR}" \ | 485 --root="${ROOT_FS_DIR}" \ |
496 --target="${ARCH}" | 486 --target="${ARCH}" |
497 fi | 487 fi |
498 echo "Developer image built and stored at ${image_name}" | 488 echo "Developer image built and stored at ${image_name}" |
499 | 489 |
500 trap - EXIT | 490 trap - EXIT |
501 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 491 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
502 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 492 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
503 } | 493 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 enable_rootfs_verification="--enable_rootfs_verification" | 654 enable_rootfs_verification="--enable_rootfs_verification" |
665 fi | 655 fi |
666 | 656 |
667 ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ | 657 ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ |
668 --arch=${ARCH} \ | 658 --arch=${ARCH} \ |
669 --to="${ROOT_FS_DIR}"/boot \ | 659 --to="${ROOT_FS_DIR}"/boot \ |
670 --boot_args="${FLAGS_boot_args}" \ | 660 --boot_args="${FLAGS_boot_args}" \ |
671 --install \ | 661 --install \ |
672 ${enable_rootfs_verification} | 662 ${enable_rootfs_verification} |
673 | 663 |
674 # Don't test the factory install shim or the dev install shim | 664 # Don't test the factory install shim |
675 if [ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ] && | 665 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. | 666 # Check that the image has been correctly created. |
678 "${SCRIPTS_DIR}/test_image" \ | 667 "${SCRIPTS_DIR}/test_image" \ |
679 --root="${ROOT_FS_DIR}" \ | 668 --root="${ROOT_FS_DIR}" \ |
680 --target="${ARCH}" | 669 --target="${ARCH}" |
681 fi | 670 fi |
682 | 671 |
683 # Clean up symlinks so they work on a running target rooted at "/". | 672 # Clean up symlinks so they work on a running target rooted at "/". |
684 # Here development packages are rooted at /usr/local. However, do not | 673 # Here development packages are rooted at /usr/local. However, do not |
685 # create /usr/local or /var on host (already exist on target). | 674 # create /usr/local or /var on host (already exist on target). |
686 setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" | 675 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. | 744 # cros_make_image_bootable. |
756 create_boot_desc | 745 create_boot_desc |
757 | 746 |
758 if [[ -f ${PRISTINE_IMG} ]] ; then | 747 if [[ -f ${PRISTINE_IMG} ]] ; then |
759 update_base_packages ${PRISTINE_IMAGE_NAME} | 748 update_base_packages ${PRISTINE_IMAGE_NAME} |
760 else | 749 else |
761 create_base_image ${PRISTINE_IMAGE_NAME} | 750 create_base_image ${PRISTINE_IMAGE_NAME} |
762 fi | 751 fi |
763 | 752 |
764 USE_DEV_KEYS= | 753 USE_DEV_KEYS= |
765 if [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] || \ | 754 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then |
766 [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ]; then | |
767 USE_DEV_KEYS="--use_dev_keys" | 755 USE_DEV_KEYS="--use_dev_keys" |
768 fi | 756 fi |
769 | 757 |
770 # Place flags before positional args | 758 # Place flags before positional args |
771 ${SCRIPTS_DIR}/bin/cros_make_image_bootable "${OUTPUT_DIR}" \ | 759 ${SCRIPTS_DIR}/bin/cros_make_image_bootable "${OUTPUT_DIR}" \ |
772 "${PRISTINE_IMAGE_NAME}" \ | 760 "${PRISTINE_IMAGE_NAME}" \ |
773 ${USE_DEV_KEYS} \ | 761 ${USE_DEV_KEYS} \ |
774 ${crosbug12352_flag} | 762 ${crosbug12352_flag} |
775 | 763 |
776 # FIXME Test x86 image, and test arm image if enabled; | 764 # FIXME Test x86 image, and test arm image if enabled; |
777 # should unconditionally test an image after crosbug12352 is fixed | 765 # should unconditionally test an image after crosbug12352 is fixed |
778 if [[ "${ARCH}" = "x86" ]] || | 766 if [[ "${ARCH}" = "x86" ]] || |
779 [[ "${ARCH}" = "arm" && | 767 [[ "${ARCH}" = "arm" && |
780 "${FLAGS_crosbug12352_arm_kernel_signing}" -eq "${FLAGS_TRUE}" ]]; then | 768 "${FLAGS_crosbug12352_arm_kernel_signing}" -eq "${FLAGS_TRUE}" ]]; then |
781 BOOT_FLAG= | 769 BOOT_FLAG= |
782 if [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] || | 770 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 | 771 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" | 772 info "--factory_install set, pass BOOT_FLAG_DEVELOPER flag to \ |
| 773 load_kernel_test" |
786 fi | 774 fi |
787 | 775 |
788 # Verify the final image. | 776 # Verify the final image. |
789 load_kernel_test "${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" \ | 777 load_kernel_test "${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" \ |
790 "${DEVKEYSDIR}/recovery_key.vbpubk" ${BOOT_FLAG} | 778 "${DEVKEYSDIR}/recovery_key.vbpubk" ${BOOT_FLAG} |
791 fi | 779 fi |
792 | 780 |
793 # Create a developer image based on the chromium os base image. | 781 # Create a developer image based on the chromium os base image. |
794 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then | 782 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then |
795 if [[ ! -f ${DEVELOPER_IMG} ]] ; then | 783 if [[ ! -f ${DEVELOPER_IMG} ]] ; then |
(...skipping 24 matching lines...) Expand all Loading... |
820 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 808 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
821 fi | 809 fi |
822 | 810 |
823 print_time_elapsed | 811 print_time_elapsed |
824 | 812 |
825 echo "To copy to USB keyfob, do something like:" | 813 echo "To copy to USB keyfob, do something like:" |
826 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 814 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:" | 815 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
828 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 816 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
829 echo "from the scripts directory where you entered the chroot." | 817 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |