Chromium Code Reviews| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 # Clean out unused packages | 496 # Clean out unused packages |
| 497 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ | 497 sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 498 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ | 498 --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 499 --usepkgonly --depclean ${EMERGE_JOBS} | 499 --usepkgonly --depclean ${EMERGE_JOBS} |
| 500 | 500 |
| 501 trap - EXIT | 501 trap - EXIT |
| 502 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ | 502 ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
| 503 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" | 503 -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
| 504 } | 504 } |
| 505 | 505 |
| 506 zero_freespace() { | |
|
petkov
2010/12/11 00:25:44
zero_free_space?
thieule
2010/12/11 00:54:35
Done.
| |
| 507 local fs_mount_point=$1 | |
| 508 info "Zeroing freespace in ${fs_mount_point}" | |
| 509 sudo dd if=/dev/zero of="${fs_mount_point}/filler" oflag=sync || \ | |
|
petkov
2010/12/11 00:25:44
this seems strange, especially with || instead of
thieule
2010/12/11 00:54:35
Done.
The oflag is required to force the writes t
| |
| 510 sudo rm "${fs_mount_point}/filler" || sudo sync | |
| 511 } | |
| 512 | |
| 506 create_base_image() { | 513 create_base_image() { |
| 507 local image_name=$1 | 514 local image_name=$1 |
| 508 | 515 |
| 509 trap "cleanup && delete_prompt" EXIT | 516 trap "cleanup && delete_prompt" EXIT |
| 510 | 517 |
| 511 # Create and format the root file system. | 518 # Create and format the root file system. |
| 512 | 519 |
| 513 # Check for loop device before creating image. | 520 # Check for loop device before creating image. |
| 514 LOOP_DEV=$(sudo losetup -f) | 521 LOOP_DEV=$(sudo losetup -f) |
| 515 if [ -z "${LOOP_DEV}" ] ; then | 522 if [ -z "${LOOP_DEV}" ] ; then |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" | 683 setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" |
| 677 | 684 |
| 678 # cros_make_image_bootable will clobber vmlinuz.image for x86. | 685 # cros_make_image_bootable will clobber vmlinuz.image for x86. |
| 679 # Until then, just copy the kernel to vmlinuz.image. It is | 686 # Until then, just copy the kernel to vmlinuz.image. It is |
| 680 # expected in build_gpt.sh. | 687 # expected in build_gpt.sh. |
| 681 cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" | 688 cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" |
| 682 | 689 |
| 683 # Create an empty esp image to be updated in by update_bootloaders.sh. | 690 # Create an empty esp image to be updated in by update_bootloaders.sh. |
| 684 ${SCRIPTS_DIR}/create_esp.sh --to="${ESP_FS_IMG}" | 691 ${SCRIPTS_DIR}/create_esp.sh --to="${ESP_FS_IMG}" |
| 685 | 692 |
| 693 # Zero rootfs free space to make it more compressible so auto-update | |
| 694 # packages become smaller | |
|
petkov
2010/12/11 00:25:44
s/packages/payloads/
thieule
2010/12/11 00:54:35
Done.
| |
| 695 zero_freespace "${ROOT_FS_DIR}" | |
| 696 | |
| 686 cleanup | 697 cleanup |
| 687 | 698 |
| 688 trap delete_prompt EXIT | 699 trap delete_prompt EXIT |
| 689 | 700 |
| 690 # Create the GPT-formatted image. | 701 # Create the GPT-formatted image. |
| 691 ${SCRIPTS_DIR}/build_gpt.sh \ | 702 ${SCRIPTS_DIR}/build_gpt.sh \ |
| 692 --arch=${ARCH} \ | 703 --arch=${ARCH} \ |
| 693 --board=${FLAGS_board} \ | 704 --board=${FLAGS_board} \ |
| 694 --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ | 705 --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ |
| 695 "${OUTPUT_DIR}" \ | 706 "${OUTPUT_DIR}" \ |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 813 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
| 803 fi | 814 fi |
| 804 | 815 |
| 805 print_time_elapsed | 816 print_time_elapsed |
| 806 | 817 |
| 807 echo "To copy to USB keyfob, do something like:" | 818 echo "To copy to USB keyfob, do something like:" |
| 808 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 819 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
| 809 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 820 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
| 810 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 821 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
| 811 echo "from the scripts directory where you entered the chroot." | 822 echo "from the scripts directory where you entered the chroot." |
| OLD | NEW |