| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 # Only now can we die on error. shflags functions leak non-zero error codes, | 89 # Only now can we die on error. shflags functions leak non-zero error codes, |
| 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 # Verify user didn't specify incompatible flags for dev install shim | 98 # Verify user didn't specify incompatible flags for dev install shim |
| 99 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] && | 99 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] && |
| 100 [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then | 100 [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then |
| 101 error "Incompatible flags: --factory_install and --dev_install cannot be \ | 101 die "Incompatible flags: --factory_install and --dev_install cannot be \ |
| 102 both set to True. Please specify one or none." | 102 both set to True. Please specify one or none." |
| 103 exit 1 | |
| 104 fi | 103 fi |
| 105 | 104 |
| 106 INSTALL_MASK="" | 105 INSTALL_MASK="" |
| 107 if [ ${FLAGS_installmask} -eq ${FLAGS_TRUE} ] ; then | 106 if [ "${FLAGS_installmask}" -eq "${FLAGS_TRUE}" ] ; then |
| 108 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" | 107 INSTALL_MASK="${DEFAULT_INSTALL_MASK}" |
| 109 fi | 108 fi |
| 110 | 109 |
| 111 # Reduce the size of factory install shim. | 110 # Reduce the size of factory install shim. |
| 112 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] || | 111 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] || |
| 113 [ ${FLAGS_dev_install} -eq ${FLAGS_TRUE} ] ; then | 112 [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then |
| 114 # Disable --withdev flag when --*_install is set to True. Otherwise, the | 113 # Disable --withdev flag when --*_install is set to True. Otherwise, the |
| 115 # dev image produced will be based on install shim, rather than a pristine | 114 # dev image produced will be based on install shim, rather than a pristine |
| 116 # image | 115 # image |
| 117 if [ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]; then | 116 if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
| 118 info "Incompatible flags: --withdev and --dev_install or --factory_install \ | 117 info "Incompatible flags: --withdev and --dev_install or --factory_install \ |
| 119 cannot be both set to True. Reset --withdev to False." | 118 cannot be both set to True. Reset --withdev to False." |
| 120 FLAGS_withdev=${FLAGS_FALSE} | 119 FLAGS_withdev=${FLAGS_FALSE} |
| 121 fi | 120 fi |
| 122 | 121 |
| 123 # TODO: Build a separated ebuild for the install shim to reduce size. | 122 # TODO: Build a separated ebuild for the install shim to reduce size. |
| 124 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" | 123 INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" |
| 125 | 124 |
| 126 info "Fixing the rootfs size at 300 MiB for install shim" | 125 info "Fixing the rootfs size at 300 MiB for install shim" |
| 127 FLAGS_rootfs_size=280 | 126 FLAGS_rootfs_size=280 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 | 137 |
| 139 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" | 138 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" |
| 140 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then | 139 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then |
| 141 echo "Using alternate emerge" | 140 echo "Using alternate emerge" |
| 142 EMERGE_BOARD_CMD="${SCRIPTS_DIR}/parallel_emerge --board=${FLAGS_board}" | 141 EMERGE_BOARD_CMD="${SCRIPTS_DIR}/parallel_emerge --board=${FLAGS_board}" |
| 143 fi | 142 fi |
| 144 | 143 |
| 145 # Determine build version. | 144 # Determine build version. |
| 146 . "${SCRIPTS_DIR}/chromeos_version.sh" | 145 . "${SCRIPTS_DIR}/chromeos_version.sh" |
| 147 | 146 |
| 147 # Configure extra USE or packages for this type of build. |
| 148 EXTRA_PACKAGES="" |
| 149 EXTRA_USE="" |
| 150 if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] ; then |
| 151 # Factory install needs to have the kernel initrmafs enabled, |
| 152 # and the factory installer added. |
| 153 EXTRA_PACKAGES="chromeos-base/chromeos-factoryinstall" |
| 154 EXTRA_USE="initramfs" |
| 155 fi |
| 156 |
| 157 # Freshen kernel with correct USE flags. This is a noop if we have |
| 158 # the right kernel prebuilt. Factory install uses USE="initramfs". |
| 159 # We don't allow building from source with the image as a target, |
| 160 # and it's not possible to store prebuilts for the same package |
| 161 # with different use flags. |
| 162 USE="${EXTRA_USE}" emerge-${FLAGS_board} \ |
| 163 -uNDvg --binpkg-respect-use=y kernel |
| 164 |
| 148 # Use canonical path since some tools (e.g. mount) do not like symlinks. | 165 # Use canonical path since some tools (e.g. mount) do not like symlinks. |
| 149 # Append build attempt to output directory. | 166 # Append build attempt to output directory. |
| 150 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" | 167 IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" |
| 151 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" | 168 OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" |
| 152 | 169 |
| 153 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" | 170 OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
| 154 | 171 |
| 155 # If we are creating a developer image, also create a pristine image with a | 172 # If we are creating a developer image, also create a pristine image with a |
| 156 # different name. | 173 # different name. |
| 157 DEVELOPER_IMAGE_NAME= | 174 DEVELOPER_IMAGE_NAME= |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 echo "Updating base packages on ${image_name}" | 444 echo "Updating base packages on ${image_name}" |
| 428 | 445 |
| 429 # Create stateful partition of the same size as the rootfs. | 446 # Create stateful partition of the same size as the rootfs. |
| 430 trap "mount_gpt_cleanup" EXIT | 447 trap "mount_gpt_cleanup" EXIT |
| 431 | 448 |
| 432 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ | 449 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
| 433 --image "${image_name}" -r "${ROOT_FS_DIR}" \ | 450 --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
| 434 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 451 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 435 | 452 |
| 436 # Emerge updated packages, exactly like when creating base image | 453 # Emerge updated packages, exactly like when creating base image |
| 437 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 454 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 438 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 455 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 439 --usepkg -uDNv chromeos ${EMERGE_JOBS} | 456 --usepkg -uDNv chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} |
| 440 | 457 |
| 441 # Clean out unused packages | 458 # Clean out unused packages |
| 442 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 459 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 443 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 460 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 444 --usepkg --depclean ${EMERGE_JOBS} | 461 --usepkg --depclean ${EMERGE_JOBS} |
| 445 | 462 |
| 446 trap - EXIT | 463 trap - EXIT |
| 447 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 464 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
| 448 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 465 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 449 } | 466 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 sudo mkdir -p "${ROOT_FS_DIR}/usr/local" | 582 sudo mkdir -p "${ROOT_FS_DIR}/usr/local" |
| 566 sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" | 583 sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" |
| 567 sudo mkdir -p "${ROOT_FS_DIR}/var" | 584 sudo mkdir -p "${ROOT_FS_DIR}/var" |
| 568 sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var" | 585 sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var" |
| 569 sudo mkdir -p "${ROOT_FS_DIR}/dev" | 586 sudo mkdir -p "${ROOT_FS_DIR}/dev" |
| 570 | 587 |
| 571 # We "emerge --root=${ROOT_FS_DIR} --root-deps=rdeps --usepkg" all of the | 588 # We "emerge --root=${ROOT_FS_DIR} --root-deps=rdeps --usepkg" all of the |
| 572 # runtime packages for chrome os. This builds up a chrome os image from | 589 # runtime packages for chrome os. This builds up a chrome os image from |
| 573 # binary packages with runtime dependencies only. We use INSTALL_MASK to | 590 # binary packages with runtime dependencies only. We use INSTALL_MASK to |
| 574 # trim the image size as much as possible. | 591 # trim the image size as much as possible. |
| 575 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 592 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 576 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 593 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 577 --usepkg chromeos ${EMERGE_JOBS} | 594 --usepkg chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} |
| 578 | 595 |
| 579 # Perform any customizations on the root file system that are needed. | 596 # Perform any customizations on the root file system that are needed. |
| 580 "${SCRIPTS_DIR}/customize_rootfs" \ | 597 "${SCRIPTS_DIR}/customize_rootfs" \ |
| 581 --root="${ROOT_FS_DIR}" \ | 598 --root="${ROOT_FS_DIR}" \ |
| 582 --target="${ARCH}" \ | 599 --target="${ARCH}" \ |
| 583 --board="${BOARD}" | 600 --board="${BOARD}" |
| 584 | 601 |
| 585 # Populates the root filesystem with legacy bootloader templates | 602 # Populates the root filesystem with legacy bootloader templates |
| 586 # appropriate for the platform. The autoupdater and installer will | 603 # appropriate for the platform. The autoupdater and installer will |
| 587 # use those templates to update the legacy boot partition (12/ESP) | 604 # use those templates to update the legacy boot partition (12/ESP) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 739 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
| 723 fi | 740 fi |
| 724 | 741 |
| 725 print_time_elapsed | 742 print_time_elapsed |
| 726 | 743 |
| 727 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 744 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 728 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 745 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 729 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 746 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
| 730 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 747 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
| 731 echo "from the scripts directory where you entered the chroot." | 748 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |