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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 DEFINE_integer verity_error_behavior 2 \ | 70 DEFINE_integer verity_error_behavior 2 \ |
71 "Kernel verified boot error behavior (0: I/O errors, 1: reboot, 2: nothing) \ | 71 "Kernel verified boot error behavior (0: I/O errors, 1: reboot, 2: nothing) \ |
72 Default: 2" | 72 Default: 2" |
73 DEFINE_integer verity_depth 1 \ | 73 DEFINE_integer verity_depth 1 \ |
74 "Kernel verified boot hash tree depth. Default: 1" | 74 "Kernel verified boot hash tree depth. Default: 1" |
75 DEFINE_integer verity_max_ios 1024 \ | 75 DEFINE_integer verity_max_ios 1024 \ |
76 "Number of outstanding I/O operations dm-verity caps at. Default: 1024" | 76 "Number of outstanding I/O operations dm-verity caps at. Default: 1024" |
77 DEFINE_string verity_algorithm "sha1" \ | 77 DEFINE_string verity_algorithm "sha1" \ |
78 "Cryptographic hash algorithm used for kernel vboot. Default : sha1" | 78 "Cryptographic hash algorithm used for kernel vboot. Default : sha1" |
79 | 79 |
80 DEFINE_string oem_customization \ | 80 DEFINE_string oem_customization "" \ |
81 "$GCLIENT_ROOT/src/platform/assets/oem_customization" \ | |
82 "Path to directory containing OEM partner partition contents" | 81 "Path to directory containing OEM partner partition contents" |
83 | 82 |
84 # Parse command line. | 83 # Parse command line. |
85 FLAGS "$@" || exit 1 | 84 FLAGS "$@" || exit 1 |
86 eval set -- "${FLAGS_ARGV}" | 85 eval set -- "${FLAGS_ARGV}" |
87 | 86 |
88 # Only now can we die on error. shflags functions leak non-zero error codes, | 87 # Only now can we die on error. shflags functions leak non-zero error codes, |
89 # so will die prematurely if 'set -e' is specified before now. | 88 # so will die prematurely if 'set -e' is specified before now. |
90 set -e | 89 set -e |
91 | 90 |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 | 577 |
579 # Tune and mount OEM partner partition. | 578 # Tune and mount OEM partner partition. |
580 UUID=$(uuidgen) | 579 UUID=$(uuidgen) |
581 DISK_LABEL="C-OEM" | 580 DISK_LABEL="C-OEM" |
582 sudo losetup "${OEM_LOOP_DEV}" "${OEM_FS_IMG}" | 581 sudo losetup "${OEM_LOOP_DEV}" "${OEM_FS_IMG}" |
583 sudo mkfs.ext3 "${OEM_LOOP_DEV}" | 582 sudo mkfs.ext3 "${OEM_LOOP_DEV}" |
584 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${OEM_LOOP_DEV}" | 583 sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${OEM_LOOP_DEV}" |
585 sudo mount "${OEM_LOOP_DEV}" "${OEM_FS_DIR}" | 584 sudo mount "${OEM_LOOP_DEV}" "${OEM_FS_DIR}" |
586 | 585 |
587 # Populate OEM partner partition. | 586 # Populate OEM partner partition. |
588 if [ -n ${FLAGS_oem_customization} ]; then | 587 if [ ! -z "${FLAGS_oem_customization}" ]; then |
589 if [ ! -d ${FLAGS_oem_customization} ]; then | 588 if [ ! -d ${FLAGS_oem_customization} ]; then |
590 echo "Specified OEM content directory does not exist. exiting." | 589 echo "Specified OEM content directory does not exist. exiting." |
591 exit 1 | 590 exit 1 |
592 fi | 591 fi |
593 for ITEM in `ls -A ${FLAGS_oem_customization}` | 592 for ITEM in `ls -A ${FLAGS_oem_customization}` |
594 do sudo cp -a "${FLAGS_oem_customization}/$ITEM" "${OEM_FS_DIR}" | 593 do sudo cp -a "${FLAGS_oem_customization}/$ITEM" "${OEM_FS_DIR}" |
595 done | 594 done |
596 sudo find "${OEM_FS_DIR}" -type d -exec chmod 755 "{}" \; | 595 sudo find "${OEM_FS_DIR}" -type d -exec chmod 755 "{}" \; |
597 sudo find "${OEM_FS_DIR}" -type f -exec chmod 644 "{}" \; | 596 sudo find "${OEM_FS_DIR}" -type f -exec chmod 644 "{}" \; |
598 sudo chown -R root:root "${OEM_FS_DIR}" | 597 sudo chown -R root:root "${OEM_FS_DIR}" |
| 598 else |
| 599 echo "Empty OEM partition: OEM customizations will not be applied." |
599 fi | 600 fi |
600 | 601 |
601 # -- Install packages into the root file system -- | 602 # -- Install packages into the root file system -- |
602 | 603 |
603 # We need to install libc manually from the cross toolchain. | 604 # We need to install libc manually from the cross toolchain. |
604 # TODO: Improve this? We only want libc and not the whole toolchain. | 605 # TODO: Improve this? We only want libc and not the whole toolchain. |
605 PKGDIR="/var/lib/portage/pkgs/cross/" | 606 PKGDIR="/var/lib/portage/pkgs/cross/" |
606 sudo tar jxvpf \ | 607 sudo tar jxvpf \ |
607 "${PKGDIR}/${CHOST}/cross-${CHOST}"/glibc-${LIBC_VERSION}.tbz2 \ | 608 "${PKGDIR}/${CHOST}/cross-${CHOST}"/glibc-${LIBC_VERSION}.tbz2 \ |
608 -C "${ROOT_FS_DIR}" --strip-components=3 \ | 609 -C "${ROOT_FS_DIR}" --strip-components=3 \ |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 766 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
766 fi | 767 fi |
767 | 768 |
768 print_time_elapsed | 769 print_time_elapsed |
769 | 770 |
770 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" | 771 echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
771 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 772 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
772 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 773 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
773 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" | 774 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" |
774 echo "from the scripts directory where you entered the chroot." | 775 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |