J. Richard Barnette | 8447777 | 2011-07-25 13:41:33 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 2 | |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 3 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 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 |
| 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. |
| 11 | |
Brian Harring | aa13ea4 | 2012-03-15 18:31:03 -0700 | [diff] [blame] | 12 | SCRIPT_ROOT=$(dirname $(readlink -f "$0")) |
J. Richard Barnette | 8447777 | 2011-07-25 13:41:33 -0700 | [diff] [blame] | 13 | . "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1 |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 14 | |
Greg Spencer | 798d75f | 2011-02-01 22:04:49 -0800 | [diff] [blame] | 15 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 16 | # Developer-visible flags. |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 17 | DEFINE_string board "${DEFAULT_BOARD}" \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 18 | "The board to build an image for." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 19 | DEFINE_string boot_args "noinitrd" \ |
| 20 | "Additional boot arguments to pass to the commandline" |
| 21 | DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \ |
| 22 | "Default all bootloaders to use kernel-based root fs integrity checking." |
Liam McLoughlin | 8afcdcd | 2012-07-13 18:20:56 -0700 | [diff] [blame] | 23 | DEFINE_boolean full "${FLAGS_FALSE}" "Build full image with all partitions." |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 24 | DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ |
| 25 | "Directory in which to place image result directories (named by version)" |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 26 | DEFINE_integer rootfs_hash_pad 8 \ |
| 27 | "MiBs reserved at the end of the rootfs image. \ |
| 28 | ceil(0.01 * rootfs_size) is a good minimum." |
Zelidrag Hornung | 1d12c1a | 2010-06-02 10:20:29 -0700 | [diff] [blame] | 29 | DEFINE_integer rootfs_partition_size 1024 \ |
Will Drewry | d253bad | 2010-08-17 14:09:41 -0500 | [diff] [blame] | 30 | "rootfs partition size in MiBs." |
Andrew de los Reyes | 0eb6d76 | 2010-11-01 18:27:53 -0700 | [diff] [blame] | 31 | DEFINE_integer rootfs_size 850 \ |
Will Drewry | d253bad | 2010-08-17 14:09:41 -0500 | [diff] [blame] | 32 | "rootfs filesystem size in MiBs." |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 33 | DEFINE_integer rootfs_boost_size 0 \ |
| 34 | "MiBs by which to increase the rootfs allocations." |
David Rochberg | cf93237 | 2011-06-30 21:25:08 -0400 | [diff] [blame] | 35 | DEFINE_boolean standard_backdoor ${FLAGS_TRUE} \ |
| 36 | "Install standard backdoor credentials for testing" |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 37 | DEFINE_integer statefulfs_size 1024 \ |
| 38 | "stateful filesystem size in MiBs." |
| 39 | DEFINE_string usb_disk /dev/sdb3 \ |
| 40 | "Path syslinux should use to do a usb boot. Default: /dev/sdb3" |
Che-Liang Chiou | 611d5b7 | 2011-07-27 16:03:26 +0800 | [diff] [blame] | 41 | |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 42 | FLAGS_HELP="USAGE: build_image [flags] [list of images to build]. |
| 43 | This script is used to build a Chromium OS image. Chromium OS comes in many |
| 44 | different forms. This scripts can be used to build the following: |
| 45 | |
| 46 | base - Pristine Chromium OS image. As similar to Chrome OS as possible. |
| 47 | dev - Developer image. Like base but with additional developer packages. |
| 48 | test - Like dev, but with additional test specific packages and can be easily |
| 49 | used for automated testing using scripts like run_remote_tests, etc. |
| 50 | factory_test - Like test but with extra packages and modifications used to |
| 51 | test images in a factory setting. Cannot be built along with a test image. |
| 52 | factory_install - Install shim for bootstrapping the factory test process. |
| 53 | Cannot be built along with any other image. |
| 54 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 55 | Examples: |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 56 | |
| 57 | build_image --board=<board> dev test - builds developer and test images. |
| 58 | build_image --board=<board> factory_install - builds a factory install shim. |
| 59 | ... |
| 60 | " |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 61 | show_help_if_requested "$@" |
| 62 | |
| 63 | # The following options are advanced options, only available to those willing |
| 64 | # to read the source code. They are not shown in help output, since they are |
| 65 | # not needed for the typical developer workflow. |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 66 | DEFINE_integer build_attempt 1 \ |
| 67 | "The build attempt for this image build." |
Liam McLoughlin | 0727903 | 2012-06-25 17:31:11 -0700 | [diff] [blame] | 68 | DEFINE_boolean hybrid_mbr ${FLAGS_FALSE} \ |
| 69 | "Creates a hybrid MBR rather than a protective one" |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 70 | DEFINE_integer jobs -1 \ |
| 71 | "How many packages to build in parallel at maximum." |
| 72 | DEFINE_boolean replace ${FLAGS_FALSE} \ |
| 73 | "Overwrite existing output, if any." |
| 74 | DEFINE_string symlink "latest" \ |
| 75 | "Symlink name to use for this image." |
| 76 | DEFINE_integer verity_error_behavior 3 \ |
| 77 | "Kernel verified boot error behavior (0: I/O errors, 1: panic, 2: nothing, \ |
| 78 | 3: cros) Default: 3" |
| 79 | DEFINE_integer verity_max_ios -1 \ |
| 80 | "Number of outstanding I/O operations dm-verity caps at. Default: -1" |
| 81 | DEFINE_string verity_algorithm "sha1" \ |
| 82 | "Cryptographic hash algorithm used for kernel vboot. Default : sha1" |
| 83 | DEFINE_string verity_salt "" \ |
| 84 | "Root filesystem salt. Default: randomly generated." |
Liam McLoughlin | 0727903 | 2012-06-25 17:31:11 -0700 | [diff] [blame] | 85 | DEFINE_string version "" \ |
| 86 | "Overrides version number in name to this version." |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 87 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 88 | # Parse command line. |
| 89 | FLAGS "$@" || exit 1 |
| 90 | eval set -- "${FLAGS_ARGV}" |
| 91 | |
| 92 | # Only now can we die on error. shflags functions leak non-zero error codes, |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 93 | # so will die prematurely if 'switch_to_strict_mode' is specified before now. |
| 94 | switch_to_strict_mode |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 95 | |
J. Richard Barnette | e4e3dec | 2011-08-08 16:35:02 -0700 | [diff] [blame] | 96 | # Determine build version. |
| 97 | OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos" |
| 98 | . "${OVERLAY_CHROMEOS_DIR}/config/chromeos_version.sh" || exit 1 |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 99 | # N.B. Ordering matters for some of the libraries below, because |
| 100 | # some of the files contain initialization used by later files. |
J. Richard Barnette | aaef761 | 2011-08-11 17:10:28 -0700 | [diff] [blame] | 101 | . "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 |
| 102 | . "${BUILD_LIBRARY_DIR}/build_gpt.sh" || exit 1 |
J. Richard Barnette | 5f9dbe4 | 2011-08-22 14:31:33 -0700 | [diff] [blame] | 103 | . "${BUILD_LIBRARY_DIR}/mount_gpt_util.sh" || exit 1 |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 104 | . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1 |
| 105 | . "${BUILD_LIBRARY_DIR}/base_image_util.sh" || exit 1 |
| 106 | . "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1 |
| 107 | . "${BUILD_LIBRARY_DIR}/test_image_util.sh" || exit 1 |
J. Richard Barnette | aaef761 | 2011-08-11 17:10:28 -0700 | [diff] [blame] | 108 | . "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 |
J. Richard Barnette | e4e3dec | 2011-08-08 16:35:02 -0700 | [diff] [blame] | 109 | |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 110 | parse_build_image_args |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 111 | |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 112 | for overlay in $(cros_overlay_list --board "$BOARD"); do |
| 113 | setup_sh="${overlay}/scripts/board_specific_setup.sh" |
| 114 | if [[ -e ${setup_sh} ]]; then |
| 115 | source "${setup_sh}" |
| 116 | fi |
| 117 | done |
| 118 | |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 119 | # Tweak sizes defaulted or given based on any boost given (or defaulted). |
| 120 | # This is syntactic sugar to separate concerns in callers, and unify |
| 121 | # default values here. |
| 122 | if [[ $FLAGS_rootfs_boost_size -gt 0 ]]; then |
| 123 | max() { |
| 124 | echo $(( $1 > $2 ? $1 : $2 )) |
| 125 | } |
| 126 | root_boost() { |
| 127 | echo $(( $1 + ( $1 * $FLAGS_rootfs_boost_size + $FLAGS_rootfs_size - 1 ) \ |
| 128 | / $FLAGS_rootfs_size )) |
| 129 | } |
| 130 | FLAGS_rootfs_hash_pad=$(root_boost $FLAGS_rootfs_hash_pad) |
| 131 | FLAGS_rootfs_partition_size=$(root_boost $FLAGS_rootfs_partition_size) |
| 132 | FLAGS_rootfs_size=$(root_boost $FLAGS_rootfs_size) |
| 133 | FLAGS_rootfs_boost_size=0 |
| 134 | # Push up to the recommended minimum if we did not get there. |
| 135 | FLAGS_rootfs_hash_pad=$(max $FLAGS_rootfs_hash_pad \ |
| 136 | $(( ( $FLAGS_rootfs_size + 99 ) / 100 ))) |
| 137 | fi |
| 138 | |
Chris Sosa | 4299eb9 | 2011-11-01 12:54:01 -0700 | [diff] [blame] | 139 | # Tweak flags, configure extra USE flags, and add packages for the factory |
| 140 | # install shim. |
| 141 | EXTRA_PACKAGES="" |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 142 | if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 143 | # TODO: Build a separated ebuild for the install shim to reduce size. |
Hung-Te Lin | d32c59f | 2012-01-19 19:54:01 +0800 | [diff] [blame] | 144 | INSTALL_MASK="${FACTORY_SHIM_INSTALL_MASK}" |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 145 | |
Vadim Bendebury | 0887dc2 | 2012-09-05 15:15:13 -0700 | [diff] [blame] | 146 | # Reduce the size of factory install shim. Note that 400M is too much, it |
| 147 | # should be smaller, see http://crosbug.com/34167 |
| 148 | FLAGS_rootfs_size=400 |
| 149 | FLAGS_rootfs_partition_size=420 |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 150 | FLAGS_statefulfs_size=140 |
Vadim Bendebury | 0887dc2 | 2012-09-05 15:15:13 -0700 | [diff] [blame] | 151 | info "Fixing the rootfs size at ${FLAGS_rootfs_partition_size} MiB " \ |
| 152 | "for install shim" |
| 153 | info "Fixing the statefulfs size at ${FLAGS_statefulfs_size} MiB " \ |
| 154 | "for install shim" |
Jon Salz | 67145df | 2011-10-20 14:05:06 +0800 | [diff] [blame] | 155 | |
| 156 | # Add the cros_factory_install boot arg. |
| 157 | FLAGS_boot_args="${FLAGS_boot_args} cros_factory_install" |
Chris Sosa | 4299eb9 | 2011-11-01 12:54:01 -0700 | [diff] [blame] | 158 | |
| 159 | # Factory install needs to have the factory installer added. |
| 160 | EXTRA_PACKAGES="${EXTRA_PACKAGES} chromeos-base/chromeos-factoryinstall" |
Hung-Te Lin | 7119cb1 | 2012-03-07 22:29:13 +0800 | [diff] [blame] | 161 | # On x86/amd64, we boot the factory install shim from an SD card using |
| 162 | # initramfs for our root. On ARM, we boot the factory install shim over the |
| 163 | # network, so we don't require initramfs, but we do require fbconsole to fix |
| 164 | # a display driver bug. |
| 165 | if [ "${ARCH}" = "x86" -o "${ARCH}" = "amd64" ] ; then |
Vic Yang | 4051405 | 2012-05-22 14:27:40 +0800 | [diff] [blame] | 166 | export USE="${USE} initramfs vfat" |
Chris Sosa | 4299eb9 | 2011-11-01 12:54:01 -0700 | [diff] [blame] | 167 | fi |
| 168 | # CONFIG_BLK_DEV_RAM is disabled by default. |
| 169 | # But tftp install needs it to mount rootfs in ram |
| 170 | if [ "${ARCH}" = "arm" ] ; then |
| 171 | export USE="${USE} fbconsole blkdevram" |
| 172 | fi |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 173 | fi |
| 174 | |
J. Richard Barnette | eb5246f | 2011-04-08 10:34:31 -0700 | [diff] [blame] | 175 | if [ $((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) -gt \ |
| 176 | ${FLAGS_rootfs_partition_size} ] ; then |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 177 | die_notrace "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MiB) is" \ |
Chris Sosa | 131eaf5 | 2011-10-27 16:15:53 -0700 | [diff] [blame] | 178 | "bigger than partition (${FLAGS_rootfs_partition_size} MiB)." |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 179 | fi |
| 180 | |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 181 | # If we are creating a developer image, also create a pristine image with a |
| 182 | # different name. |
Chris Sosa | 93e7b78 | 2012-01-03 15:52:12 -0800 | [diff] [blame] | 183 | PRISTINE_IMAGE_NAME= |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 184 | if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 185 | PRISTINE_IMAGE_NAME=${CHROMEOS_FACTORY_INSTALL_SHIM_NAME} |
Chris Sosa | 93e7b78 | 2012-01-03 15:52:12 -0800 | [diff] [blame] | 186 | else |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 187 | PRISTINE_IMAGE_NAME=${CHROMEOS_BASE_IMAGE_NAME} |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 188 | fi |
| 189 | |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 190 | ROOT_FS_DIR="${BUILD_DIR}/rootfs" |
| 191 | STATEFUL_FS_DIR="${BUILD_DIR}/stateful_partition" |
| 192 | ESP_FS_DIR=${BUILD_DIR}/esp |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 193 | |
Will Drewry | 7ab698d | 2010-08-05 13:57:52 -0500 | [diff] [blame] | 194 | DEVKEYSDIR="/usr/share/vboot/devkeys" |
| 195 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 196 | # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will |
| 197 | # be installed on the stateful dir. On a Chromium OS system, this will |
| 198 | # translate to /usr/local. |
| 199 | DEV_IMAGE_ROOT="${STATEFUL_FS_DIR}/dev_image" |
| 200 | |
J. Richard Barnette | 8e48095 | 2011-08-30 16:00:59 -0700 | [diff] [blame] | 201 | eclean-$BOARD -d packages |
Will Drewry | 12f14ce | 2010-08-17 17:27:16 -0500 | [diff] [blame] | 202 | |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 203 | if [[ ${skip_blacklist_check} -ne 1 ]]; then |
| 204 | check_blacklist |
| 205 | fi |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 206 | |
| 207 | # Check that the build root is sane. |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 208 | if [[ ${skip_test_build_root} -ne 1 ]]; then |
| 209 | "${BUILD_LIBRARY_DIR}/test_build_root" --root="${BOARD_ROOT}" |
| 210 | fi |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 211 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 212 | # Hack to fix bug where x86_64 CHOST line gets incorrectly added. |
| 213 | # ToDo(msb): remove this hack. |
| 214 | PACKAGES_FILE="${BOARD_ROOT}/packages/Packages" |
| 215 | sudo sed -e "s/CHOST: x86_64-pc-linux-gnu//" -i "${PACKAGES_FILE}" |
| 216 | |
| 217 | # Handle existing directory. |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 218 | if [[ -e "${BUILD_DIR}" ]]; then |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 219 | if [[ ${FLAGS_replace} -eq ${FLAGS_TRUE} ]]; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 220 | sudo rm -rf "${BUILD_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 221 | else |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 222 | error "Directory ${BUILD_DIR} already exists." |
| 223 | error "Use --build_attempt option to specify an unused attempt." |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 224 | error "Or use --replace if you want to overwrite this directory." |
| 225 | die "Unwilling to overwrite ${BUILD_DIR}." |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 226 | fi |
| 227 | fi |
| 228 | |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 229 | # Create the output directory and temporary mount points. |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 230 | mkdir -p "${BUILD_DIR}" |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 231 | mkdir -p "${ROOT_FS_DIR}" "${STATEFUL_FS_DIR}" "${ESP_FS_DIR}" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 232 | |
Will Drewry | 7ab698d | 2010-08-05 13:57:52 -0500 | [diff] [blame] | 233 | # Create the boot.desc file which stores the build-time configuration |
| 234 | # information needed for making the image bootable after creation with |
| 235 | # cros_make_image_bootable. |
| 236 | create_boot_desc |
| 237 | |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 238 | create_base_image ${PRISTINE_IMAGE_NAME} |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 239 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 240 | |
Che-Liang Chiou | e51bdf2 | 2011-07-26 21:19:24 +0800 | [diff] [blame] | 241 | BOOT_FLAG= |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 242 | if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then |
Che-Liang Chiou | e51bdf2 | 2011-07-26 21:19:24 +0800 | [diff] [blame] | 243 | BOOT_FLAG="-b 1" # BOOT_FLAG_DEVELOPER value defined in load_kernel_fw.h |
Chris Sosa | 131eaf5 | 2011-10-27 16:15:53 -0700 | [diff] [blame] | 244 | info "--factory_install set, pass BOOT_FLAG_DEVELOPER flag to" \ |
| 245 | "load_kernel_test" |
Che-Liang Chiou | 451f36e | 2011-07-21 19:53:37 +0800 | [diff] [blame] | 246 | fi |
Che-Liang Chiou | 2d2e825 | 2011-06-18 17:38:59 -0700 | [diff] [blame] | 247 | |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 248 | # Verify pristine image if we built it. |
| 249 | if should_build_image "${PRISTINE_IMAGE_NAME}"; then |
| 250 | load_kernel_test "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" \ |
| 251 | "${DEVKEYSDIR}/recovery_key.vbpubk" ${BOOT_FLAG} |
| 252 | fi |
Che-Liang Chiou | e51bdf2 | 2011-07-26 21:19:24 +0800 | [diff] [blame] | 253 | |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 254 | # Running board-specific setup if any exists. |
| 255 | if type board_setup &>/dev/null; then |
| 256 | board_setup "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" |
| 257 | fi |
| 258 | |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 259 | # Create a developer image if an image that is based on it is requested. |
| 260 | if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \ |
| 261 | ${CHROMEOS_TEST_IMAGE_NAME} ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 262 | copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME} |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 263 | install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME} |
Bill Richardson | 6ed1358 | 2010-06-16 21:38:15 -0700 | [diff] [blame] | 264 | fi |
| 265 | |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 266 | # From a developer image create a test|factory_test image. |
| 267 | if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then |
| 268 | copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${CHROMEOS_TEST_IMAGE_NAME} |
| 269 | mod_image_for_test ${CHROMEOS_TEST_IMAGE_NAME} |
| 270 | fi |
| 271 | if should_build_image ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 272 | copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \ |
| 273 | ${CHROMEOS_FACTORY_TEST_IMAGE_NAME} |
| 274 | mod_image_for_test ${CHROMEOS_FACTORY_TEST_IMAGE_NAME} |
Vince Laviano | 6aebf31 | 2011-06-01 15:27:31 -0700 | [diff] [blame] | 275 | fi |
| 276 | |
Dmitry Polukhin | 0a649b5 | 2011-02-24 13:02:52 +0300 | [diff] [blame] | 277 | rmdir "${ROOT_FS_DIR}" "${STATEFUL_FS_DIR}" "${ESP_FS_DIR}" |
Bill Richardson | 6795622 | 2010-05-28 15:38:56 -0700 | [diff] [blame] | 278 | |
Raja Aluri | aeb1048 | 2010-12-10 13:03:09 -0800 | [diff] [blame] | 279 | # Generating AU generator zip file to run outside chroot |
| 280 | generate_au_zip || echo "Failed generating AU zip file - ignoring Error..." |
David James | 4dd4c54 | 2011-08-10 10:19:47 -0700 | [diff] [blame] | 281 | |
| 282 | # Create a named symlink. |
| 283 | LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}" |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 284 | ln -sfT $(basename ${BUILD_DIR}) ${LINK_NAME} |
Olof Johansson | 58f25cc | 2010-08-04 21:18:49 -0700 | [diff] [blame] | 285 | |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 286 | echo "Done. Image(s) created in ${BUILD_DIR}" |
| 287 | |
| 288 | # Print out the images we generated. |
| 289 | if should_build_image ${CHROMEOS_BASE_IMAGE_NAME}; then |
| 290 | echo "Non-developer Chromium OS image created as ${PRISTINE_IMAGE_NAME}" |
| 291 | fi |
| 292 | if should_build_image ${CHROMEOS_FACTORY_SHIM_NAME}; then |
| 293 | echo "Chromium OS Factory install shim created as ${PRISTINE_IMAGE_NAME}" |
| 294 | fi |
| 295 | if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 296 | echo "Developer image created as ${CHROMEOS_DEVELOPER_IMAGE_NAME}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 297 | fi |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 298 | if should_build_image ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Vince Laviano | 6aebf31 | 2011-06-01 15:27:31 -0700 | [diff] [blame] | 299 | echo "Factory test image created as ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 300 | fi |
| 301 | if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then |
Vince Laviano | 6aebf31 | 2011-06-01 15:27:31 -0700 | [diff] [blame] | 302 | echo "Test image created as ${CHROMEOS_TEST_IMAGE_NAME}" |
| 303 | fi |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 304 | |
Matt Tennant | 0a9d32d | 2012-07-30 16:51:37 -0700 | [diff] [blame] | 305 | command_completed |
Nick Sanders | d250927 | 2010-06-16 03:50:04 -0700 | [diff] [blame] | 306 | |
Gilad Arnold | a7536ef | 2012-06-20 18:43:39 -0700 | [diff] [blame] | 307 | cat << EOF |
| 308 | To copy the image to a USB key, use: |
| 309 | ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} |
| 310 | To convert it to a VMWare image, use: |
| 311 | ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD} |
| 312 | EOF |