| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 # Flags. | 24 # Flags. |
| 25 DEFINE_string board "${DEFAULT_BOARD}" \ | 25 DEFINE_string board "${DEFAULT_BOARD}" \ |
| 26 "The board to build an image for." | 26 "The board to build an image for." |
| 27 DEFINE_string build_root "/build" \ | 27 DEFINE_string build_root "/build" \ |
| 28 "The root location for board sysroots." | 28 "The root location for board sysroots." |
| 29 DEFINE_integer build_attempt 1 \ | 29 DEFINE_integer build_attempt 1 \ |
| 30 "The build attempt for this image build." | 30 "The build attempt for this image build." |
| 31 DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ | 31 DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ |
| 32 "Directory in which to place image result directories (named by version)" | 32 "Directory in which to place image result directories (named by version)" |
| 33 DEFINE_boolean eclean ${FLAGS_TRUE} \ |
| 34 "Perform eclean-<board> -d as part of this script to remove obsolete packages" |
| 33 DEFINE_boolean replace ${FLAGS_FALSE} \ | 35 DEFINE_boolean replace ${FLAGS_FALSE} \ |
| 34 "Overwrite existing output, if any." | 36 "Overwrite existing output, if any." |
| 35 DEFINE_boolean withdev ${FLAGS_TRUE} \ | 37 DEFINE_boolean withdev ${FLAGS_TRUE} \ |
| 36 "Include useful developer friendly utilities in the image." | 38 "Include useful developer friendly utilities in the image." |
| 37 DEFINE_boolean installmask ${FLAGS_TRUE} \ | 39 DEFINE_boolean installmask ${FLAGS_TRUE} \ |
| 38 "Use INSTALL_MASK to shrink the resulting image." | 40 "Use INSTALL_MASK to shrink the resulting image." |
| 39 DEFINE_integer jobs -1 \ | 41 DEFINE_integer jobs -1 \ |
| 40 "How many packages to build in parallel at maximum." | 42 "How many packages to build in parallel at maximum." |
| 41 DEFINE_boolean statefuldev ${FLAGS_TRUE} \ | 43 DEFINE_boolean statefuldev ${FLAGS_TRUE} \ |
| 42 "Install development packages on stateful partition rather than the rootfs" | 44 "Install development packages on stateful partition rather than the rootfs" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 379 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 378 | 380 |
| 379 # Determine the root dir for developer packages. | 381 # Determine the root dir for developer packages. |
| 380 local root_dev_dir="${ROOT_FS_DIR}" | 382 local root_dev_dir="${ROOT_FS_DIR}" |
| 381 [ ${FLAGS_statefuldev} -eq ${FLAGS_TRUE} ] && \ | 383 [ ${FLAGS_statefuldev} -eq ${FLAGS_TRUE} ] && \ |
| 382 root_dev_dir="${ROOT_FS_DIR}/usr/local" | 384 root_dev_dir="${ROOT_FS_DIR}/usr/local" |
| 383 | 385 |
| 384 # Install developer packages described in chromeos-dev. | 386 # Install developer packages described in chromeos-dev. |
| 385 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 387 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 386 --root="${root_dev_dir}" --root-deps=rdeps \ | 388 --root="${root_dev_dir}" --root-deps=rdeps \ |
| 387 --usepkg -uDNv chromeos-dev ${EMERGE_JOBS} | 389 --usepkgonly -uDNv chromeos-dev ${EMERGE_JOBS} |
| 388 | 390 |
| 389 if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then | 391 if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then |
| 390 # Clean out unused packages | 392 # Clean out unused packages |
| 391 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 393 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 392 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 394 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 393 --usepkg --depclean ${EMERGE_JOBS} | 395 --usepkgonly --depclean ${EMERGE_JOBS} |
| 394 fi | 396 fi |
| 395 | 397 |
| 396 # Re-run ldconfig to fix /etc/ldconfig.so.cache. | 398 # Re-run ldconfig to fix /etc/ldconfig.so.cache. |
| 397 sudo /sbin/ldconfig -r "${ROOT_FS_DIR}" | 399 sudo /sbin/ldconfig -r "${ROOT_FS_DIR}" |
| 398 | 400 |
| 399 # Mark the image as a developer image (input to chromeos_startup). | 401 # Mark the image as a developer image (input to chromeos_startup). |
| 400 sudo mkdir -p "${ROOT_FS_DIR}/root" | 402 sudo mkdir -p "${ROOT_FS_DIR}/root" |
| 401 sudo touch "${ROOT_FS_DIR}/root/.dev_mode" | 403 sudo touch "${ROOT_FS_DIR}/root/.dev_mode" |
| 402 | 404 |
| 403 # Additional changes to developer image. | 405 # Additional changes to developer image. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 # Create stateful partition of the same size as the rootfs. | 448 # Create stateful partition of the same size as the rootfs. |
| 447 trap "mount_gpt_cleanup" EXIT | 449 trap "mount_gpt_cleanup" EXIT |
| 448 | 450 |
| 449 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ | 451 ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
| 450 --image "${image_name}" -r "${ROOT_FS_DIR}" \ | 452 --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
| 451 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 453 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 452 | 454 |
| 453 # Emerge updated packages, exactly like when creating base image | 455 # Emerge updated packages, exactly like when creating base image |
| 454 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 456 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 455 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 457 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 456 --usepkg -uDNv chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} | 458 --usepkgonly -uDNv chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} |
| 457 | 459 |
| 458 # Clean out unused packages | 460 # Clean out unused packages |
| 459 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 461 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 460 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 462 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 461 --usepkg --depclean ${EMERGE_JOBS} | 463 --usepkgonly --depclean ${EMERGE_JOBS} |
| 462 | 464 |
| 463 trap - EXIT | 465 trap - EXIT |
| 464 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 466 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
| 465 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 467 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 466 } | 468 } |
| 467 | 469 |
| 468 create_base_image() { | 470 create_base_image() { |
| 469 local image_name=$1 | 471 local image_name=$1 |
| 470 | 472 |
| 471 trap "cleanup && delete_prompt" EXIT | 473 trap "cleanup && delete_prompt" EXIT |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 580 |
| 579 # Perform binding rather than symlinking because directories must exist | 581 # Perform binding rather than symlinking because directories must exist |
| 580 # on rootfs so that we can bind at run-time since rootfs is read-only. | 582 # on rootfs so that we can bind at run-time since rootfs is read-only. |
| 581 echo "Binding directories from stateful partition onto the rootfs" | 583 echo "Binding directories from stateful partition onto the rootfs" |
| 582 sudo mkdir -p "${ROOT_FS_DIR}/usr/local" | 584 sudo mkdir -p "${ROOT_FS_DIR}/usr/local" |
| 583 sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" | 585 sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" |
| 584 sudo mkdir -p "${ROOT_FS_DIR}/var" | 586 sudo mkdir -p "${ROOT_FS_DIR}/var" |
| 585 sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var" | 587 sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var" |
| 586 sudo mkdir -p "${ROOT_FS_DIR}/dev" | 588 sudo mkdir -p "${ROOT_FS_DIR}/dev" |
| 587 | 589 |
| 588 # We "emerge --root=${ROOT_FS_DIR} --root-deps=rdeps --usepkg" all of the | 590 # We "emerge --root=${ROOT_FS_DIR} --root-deps=rdeps --usepkgonly" all of the |
| 589 # runtime packages for chrome os. This builds up a chrome os image from | 591 # runtime packages for chrome os. This builds up a chrome os image from |
| 590 # binary packages with runtime dependencies only. We use INSTALL_MASK to | 592 # binary packages with runtime dependencies only. We use INSTALL_MASK to |
| 591 # trim the image size as much as possible. | 593 # trim the image size as much as possible. |
| 592 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 594 sudo USE="${EXTRA_USE}" INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 593 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 595 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 594 --usepkg chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} | 596 --usepkgonly chromeos ${EXTRA_PACKAGES} ${EMERGE_JOBS} |
| 595 | 597 |
| 596 # Perform any customizations on the root file system that are needed. | 598 # Perform any customizations on the root file system that are needed. |
| 597 "${SCRIPTS_DIR}/customize_rootfs" \ | 599 "${SCRIPTS_DIR}/customize_rootfs" \ |
| 598 --root="${ROOT_FS_DIR}" \ | 600 --root="${ROOT_FS_DIR}" \ |
| 599 --target="${ARCH}" \ | 601 --target="${ARCH}" \ |
| 600 --board="${BOARD}" | 602 --board="${BOARD}" |
| 601 | 603 |
| 602 # Populates the root filesystem with legacy bootloader templates | 604 # Populates the root filesystem with legacy bootloader templates |
| 603 # appropriate for the platform. The autoupdater and installer will | 605 # appropriate for the platform. The autoupdater and installer will |
| 604 # use those templates to update the legacy boot partition (12/ESP) | 606 # use those templates to update the legacy boot partition (12/ESP) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 cp ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR} | 675 cp ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR} |
| 674 | 676 |
| 675 # Copy forward the developer image, if we already copied forward the base. | 677 # Copy forward the developer image, if we already copied forward the base. |
| 676 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]] && \ | 678 if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]] && \ |
| 677 [[ -f ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ]] ; then | 679 [[ -f ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ]] ; then |
| 678 cp ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ${OUTPUT_DIR} | 680 cp ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ${OUTPUT_DIR} |
| 679 fi | 681 fi |
| 680 fi | 682 fi |
| 681 fi | 683 fi |
| 682 | 684 |
| 685 # Perform an eclean to remove packages which are not installed |
| 686 if [[ "${FLAGS_eclean}" -eq "${FLAGS_TRUE}" ]]; then |
| 687 eclean-${FLAGS_board} -d packages |
| 688 fi |
| 689 |
| 683 # Create the boot.desc file which stores the build-time configuration | 690 # Create the boot.desc file which stores the build-time configuration |
| 684 # information needed for making the image bootable after creation with | 691 # information needed for making the image bootable after creation with |
| 685 # cros_make_image_bootable. | 692 # cros_make_image_bootable. |
| 686 create_boot_desc | 693 create_boot_desc |
| 687 | 694 |
| 688 if [[ -f ${PRISTINE_IMG} ]] ; then | 695 if [[ -f ${PRISTINE_IMG} ]] ; then |
| 689 update_base_packages ${PRISTINE_IMAGE_NAME} | 696 update_base_packages ${PRISTINE_IMAGE_NAME} |
| 690 else | 697 else |
| 691 create_base_image ${PRISTINE_IMAGE_NAME} | 698 create_base_image ${PRISTINE_IMAGE_NAME} |
| 692 fi | 699 fi |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 750 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
| 744 fi | 751 fi |
| 745 | 752 |
| 746 print_time_elapsed | 753 print_time_elapsed |
| 747 | 754 |
| 748 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 755 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
| 749 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 756 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 750 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 757 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
| 751 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 758 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
| 752 echo "from the scripts directory where you entered the chroot." | 759 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |