| 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_free_space() { | 
 |  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 bs=4096 || true | 
 |  510   sudo rm -f "${fs_mount_point}/filler" | 
 |  511   sudo sync | 
 |  512 } | 
 |  513  | 
|  506 create_base_image() { |  514 create_base_image() { | 
|  507   local image_name=$1 |  515   local image_name=$1 | 
|  508  |  516  | 
|  509   trap "cleanup && delete_prompt" EXIT |  517   trap "cleanup && delete_prompt" EXIT | 
|  510  |  518  | 
|  511   # Create and format the root file system. |  519   # Create and format the root file system. | 
|  512  |  520  | 
|  513   # Check for loop device before creating image. |  521   # Check for loop device before creating image. | 
|  514   LOOP_DEV=$(sudo losetup -f) |  522   LOOP_DEV=$(sudo losetup -f) | 
|  515   if [ -z "${LOOP_DEV}" ] ; then |  523   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}" |  684   setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" | 
|  677  |  685  | 
|  678   # cros_make_image_bootable will clobber vmlinuz.image for x86. |  686   # cros_make_image_bootable will clobber vmlinuz.image for x86. | 
|  679   # Until then, just copy the kernel to vmlinuz.image. It is |  687   # Until then, just copy the kernel to vmlinuz.image. It is | 
|  680   # expected in build_gpt.sh. |  688   # expected in build_gpt.sh. | 
|  681   cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" |  689   cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" | 
|  682  |  690  | 
|  683   # Create an empty esp image to be updated in by update_bootloaders.sh. |  691   # Create an empty esp image to be updated in by update_bootloaders.sh. | 
|  684   ${SCRIPTS_DIR}/create_esp.sh --to="${ESP_FS_IMG}" |  692   ${SCRIPTS_DIR}/create_esp.sh --to="${ESP_FS_IMG}" | 
|  685  |  693  | 
 |  694   # Zero rootfs free space to make it more compressible so auto-update | 
 |  695   # payloads become smaller | 
 |  696   zero_free_space "${ROOT_FS_DIR}" | 
 |  697  | 
|  686   cleanup |  698   cleanup | 
|  687  |  699  | 
|  688   trap delete_prompt EXIT |  700   trap delete_prompt EXIT | 
|  689  |  701  | 
|  690   # Create the GPT-formatted image. |  702   # Create the GPT-formatted image. | 
|  691   ${SCRIPTS_DIR}/build_gpt.sh \ |  703   ${SCRIPTS_DIR}/build_gpt.sh \ | 
|  692     --arch=${ARCH} \ |  704     --arch=${ARCH} \ | 
|  693     --board=${FLAGS_board} \ |  705     --board=${FLAGS_board} \ | 
|  694     --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ |  706     --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ | 
|  695     "${OUTPUT_DIR}" \ |  707     "${OUTPUT_DIR}" \ | 
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  802   echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |  814   echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 
|  803 fi |  815 fi | 
|  804  |  816  | 
|  805 print_time_elapsed |  817 print_time_elapsed | 
|  806  |  818  | 
|  807 echo "To copy to USB keyfob, do something like:" |  819 echo "To copy to USB keyfob, do something like:" | 
|  808 echo "  ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |  820 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:" |  821 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 
|  810 echo "  ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |  822 echo "  ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 
|  811 echo "from the scripts directory where you entered the chroot." |  823 echo "from the scripts directory where you entered the chroot." | 
| OLD | NEW |