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 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 15 | # Developer-visible flags. |
Liam McLoughlin | 12a9a84 | 2012-10-10 10:37:06 -0400 | [diff] [blame] | 16 | DEFINE_string adjust_part "" \ |
Chris Sosa | 36b4e30 | 2013-10-17 11:54:50 -0700 | [diff] [blame] | 17 | "Adjustments to apply to partition table (LABEL:[+-=]SIZE) e.g. ROOT-A:+1G" |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 18 | DEFINE_string board "${DEFAULT_BOARD}" \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 19 | "The board to build an image for." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 20 | DEFINE_string boot_args "noinitrd" \ |
| 21 | "Additional boot arguments to pass to the commandline" |
Paul Taysom | 00df6f6 | 2012-11-20 12:35:40 -0800 | [diff] [blame] | 22 | DEFINE_boolean enable_bootcache ${FLAGS_FALSE} \ |
| 23 | "Default all bootloaders to NOT use boot cache." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 24 | DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \ |
| 25 | "Default all bootloaders to use kernel-based root fs integrity checking." |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 26 | DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ |
| 27 | "Directory in which to place image result directories (named by version)" |
Liam McLoughlin | 5b37c54 | 2012-08-16 11:09:37 -0700 | [diff] [blame] | 28 | DEFINE_string disk_layout "default" \ |
Liam McLoughlin | b78a7c3 | 2012-11-06 20:19:05 -0500 | [diff] [blame] | 29 | "The disk layout type to use for this image." |
Paul Taysom | 5e39bb6 | 2013-01-18 07:39:25 -0800 | [diff] [blame] | 30 | DEFINE_string enable_serial "" \ |
| 31 | "Enable serial port for printks. Example values: ttyS0" |
Zach Reizner | f09d3d1 | 2014-09-24 10:45:19 -0700 | [diff] [blame] | 32 | DEFINE_integer loglevel 7 \ |
| 33 | "The loglevel to add to the kernel command line." |
Che-Liang Chiou | 611d5b7 | 2011-07-27 16:03:26 +0800 | [diff] [blame] | 34 | |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 35 | FLAGS_HELP="USAGE: build_image [flags] [list of images to build]. |
| 36 | This script is used to build a Chromium OS image. Chromium OS comes in many |
| 37 | different forms. This scripts can be used to build the following: |
| 38 | |
| 39 | base - Pristine Chromium OS image. As similar to Chrome OS as possible. |
Marc Herbert | bc4ed81 | 2015-01-21 11:41:14 -0800 | [diff] [blame] | 40 | dev [default] - Developer image. Like base but with additional dev packages. |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 41 | test - Like dev, but with additional test specific packages and can be easily |
Christopher Wiley | 5cfcf95 | 2015-05-19 09:50:35 -0700 | [diff] [blame] | 42 | used for automated testing using scripts like test_that, etc. |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 43 | factory_test - Like test but with extra packages and modifications used to |
| 44 | test images in a factory setting. Cannot be built along with a test image. |
| 45 | factory_install - Install shim for bootstrapping the factory test process. |
| 46 | Cannot be built along with any other image. |
| 47 | |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 48 | Examples: |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 49 | |
| 50 | build_image --board=<board> dev test - builds developer and test images. |
| 51 | build_image --board=<board> factory_install - builds a factory install shim. |
Chris Sosa | 36b4e30 | 2013-10-17 11:54:50 -0700 | [diff] [blame] | 52 | |
| 53 | Note if you want to build an image with custom size partitions, either consider |
| 54 | adding a new disk layout in build_library/legacy_disk_layout.json OR use |
Chris Sosa | 1cffeee | 2013-11-25 14:37:36 -0800 | [diff] [blame] | 55 | adjust_part. See the help above but here are a few examples: |
Chris Sosa | 36b4e30 | 2013-10-17 11:54:50 -0700 | [diff] [blame] | 56 | |
Chris Sosa | 1cffeee | 2013-11-25 14:37:36 -0800 | [diff] [blame] | 57 | adjust_part='STATE:+1G' -- add one GB to the size the stateful partition |
| 58 | adjust_part='ROOT-A:-1G' -- remove one GB from the primary rootfs partition |
| 59 | adjust_part='STATE:=1G' -- make the stateful partition 1 GB |
Chris Sosa | ef4a645 | 2011-10-27 16:01:07 -0700 | [diff] [blame] | 60 | ... |
| 61 | " |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 62 | show_help_if_requested "$@" |
| 63 | |
| 64 | # The following options are advanced options, only available to those willing |
| 65 | # to read the source code. They are not shown in help output, since they are |
| 66 | # not needed for the typical developer workflow. |
Steve Fung | b6ef9e8 | 2015-06-01 04:03:20 -0700 | [diff] [blame] | 67 | DEFINE_string app_id "" \ |
| 68 | "The application ID to install into the image's /etc/lsb-release |
| 69 | file. It is a UUID in the canonical {8-4-4-4-12} format, e.g. |
| 70 | {01234567-89AB-CDEF-0123-456789ABCDEF}" |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 71 | DEFINE_integer build_attempt 1 \ |
| 72 | "The build attempt for this image build." |
Steve Fung | 817a1ef | 2015-05-06 17:23:17 -0700 | [diff] [blame] | 73 | DEFINE_string build_root "${DEFAULT_BUILD_ROOT}/images" \ |
| 74 | "Directory in which to compose the image, before copying it to output_root." |
Steve Fung | 3996ec6 | 2015-03-19 17:16:38 -0700 | [diff] [blame] | 75 | DEFINE_string extra_packages "" \ |
| 76 | "Space-delimited list of additional packages to add to the image." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 77 | DEFINE_integer jobs -1 \ |
| 78 | "How many packages to build in parallel at maximum." |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 79 | DEFINE_boolean progress_bar ${FLAGS_FALSE} \ |
| 80 | "Display helper messages to allow progress to be easily measured." |
David James | 855afb7 | 2012-03-14 20:04:59 -0700 | [diff] [blame] | 81 | DEFINE_boolean replace ${FLAGS_FALSE} \ |
| 82 | "Overwrite existing output, if any." |
| 83 | DEFINE_string symlink "latest" \ |
| 84 | "Symlink name to use for this image." |
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 |
Mike Frysinger | 454c526 | 2012-12-01 14:18:51 -0500 | [diff] [blame] | 90 | |
| 91 | # See if we want to default the bootcache flag before we clobber |
| 92 | # the user's command line. We want to default to false if the |
| 93 | # user explicitly disabled rootfs verification otherwise they |
| 94 | # have to manually specify both. |
| 95 | FLAGS_bootcache_use_board_default=${FLAGS_enable_rootfs_verification} |
| 96 | case " $* " in |
| 97 | *" --enable_bootcache "*|\ |
| 98 | *" --noenable_bootcache "*) |
| 99 | FLAGS_bootcache_use_board_default=${FLAGS_FALSE} |
| 100 | ;; |
| 101 | esac |
| 102 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 103 | eval set -- "${FLAGS_ARGV}" |
| 104 | |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 105 | # 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] | 106 | # so will die prematurely if 'switch_to_strict_mode' is specified before now. |
| 107 | switch_to_strict_mode |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 108 | |
J. Richard Barnette | e4e3dec | 2011-08-08 16:35:02 -0700 | [diff] [blame] | 109 | # Determine build version. |
| 110 | OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos" |
| 111 | . "${OVERLAY_CHROMEOS_DIR}/config/chromeos_version.sh" || exit 1 |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 112 | # N.B. Ordering matters for some of the libraries below, because |
| 113 | # some of the files contain initialization used by later files. |
J. Richard Barnette | aaef761 | 2011-08-11 17:10:28 -0700 | [diff] [blame] | 114 | . "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1 |
Liam McLoughlin | 5b37c54 | 2012-08-16 11:09:37 -0700 | [diff] [blame] | 115 | . "${BUILD_LIBRARY_DIR}/disk_layout_util.sh" || exit 1 |
J. Richard Barnette | 5f9dbe4 | 2011-08-22 14:31:33 -0700 | [diff] [blame] | 116 | . "${BUILD_LIBRARY_DIR}/mount_gpt_util.sh" || exit 1 |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 117 | . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1 |
| 118 | . "${BUILD_LIBRARY_DIR}/base_image_util.sh" || exit 1 |
| 119 | . "${BUILD_LIBRARY_DIR}/dev_image_util.sh" || exit 1 |
| 120 | . "${BUILD_LIBRARY_DIR}/test_image_util.sh" || exit 1 |
J. Richard Barnette | aaef761 | 2011-08-11 17:10:28 -0700 | [diff] [blame] | 121 | . "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1 |
J. Richard Barnette | e4e3dec | 2011-08-08 16:35:02 -0700 | [diff] [blame] | 122 | |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 123 | parse_build_image_args |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 124 | |
Steve Fung | 88897cc | 2015-03-25 13:38:38 -0700 | [diff] [blame] | 125 | load_board_specific_script "board_specific_setup.sh" |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 126 | |
Chris Masone | bbccc24 | 2014-02-08 16:23:53 -0800 | [diff] [blame] | 127 | sudo_clear_shadow_locks "/build/${FLAGS_board}" |
| 128 | |
Liam McLoughlin | 5b37c54 | 2012-08-16 11:09:37 -0700 | [diff] [blame] | 129 | # TODO: <prebuild hook> |
Peter Mayo | 82975f9 | 2012-05-01 11:03:31 -0400 | [diff] [blame] | 130 | |
Mike Frysinger | 2262195 | 2014-04-01 17:41:20 -0400 | [diff] [blame] | 131 | BASE_PACKAGE="virtual/target-os" |
Vic Yang | 8e0cd07 | 2012-12-18 22:31:46 +0800 | [diff] [blame] | 132 | # Tweak flags, configure extra USE flags, and set base packages for the factory |
Chris Sosa | 4299eb9 | 2011-11-01 12:54:01 -0700 | [diff] [blame] | 133 | # install shim. |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 134 | if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 135 | # 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] | 136 | INSTALL_MASK="${FACTORY_SHIM_INSTALL_MASK}" |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 137 | |
Jon Salz | 67145df | 2011-10-20 14:05:06 +0800 | [diff] [blame] | 138 | # Add the cros_factory_install boot arg. |
| 139 | FLAGS_boot_args="${FLAGS_boot_args} cros_factory_install" |
Chris Sosa | 4299eb9 | 2011-11-01 12:54:01 -0700 | [diff] [blame] | 140 | |
Vic Yang | 8e0cd07 | 2012-12-18 22:31:46 +0800 | [diff] [blame] | 141 | BASE_PACKAGE="chromeos-base/chromeos-installshim" |
| 142 | |
Hung-Te Lin | f6f180c | 2015-02-11 20:09:02 +0800 | [diff] [blame] | 143 | export USE="${USE} fbconsole vtconsole factory_shim_ramfs tpm i2cdev vfat" |
Nick Sanders | ae26a5c | 2010-08-30 21:59:50 -0700 | [diff] [blame] | 144 | fi |
| 145 | |
Kees Cook | 8df86b2 | 2012-09-28 18:15:49 -0700 | [diff] [blame] | 146 | if should_build_image ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
| 147 | # Disable module restrictions on factory test image to allow for |
| 148 | # external third party drivers in /usr/local. |
| 149 | FLAGS_boot_args="${FLAGS_boot_args} lsm.module_locking=0" |
| 150 | fi |
| 151 | |
Liam McLoughlin | 5b37c54 | 2012-08-16 11:09:37 -0700 | [diff] [blame] | 152 | # TODO: </prebuild hook> |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 153 | |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 154 | # If we are creating a developer image, also create a pristine image with a |
| 155 | # different name. |
Chris Sosa | 93e7b78 | 2012-01-03 15:52:12 -0800 | [diff] [blame] | 156 | PRISTINE_IMAGE_NAME= |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 157 | if should_build_image ${CHROMEOS_FACTORY_INSTALL_SHIM_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 158 | PRISTINE_IMAGE_NAME=${CHROMEOS_FACTORY_INSTALL_SHIM_NAME} |
Chris Sosa | 93e7b78 | 2012-01-03 15:52:12 -0800 | [diff] [blame] | 159 | else |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 160 | PRISTINE_IMAGE_NAME=${CHROMEOS_BASE_IMAGE_NAME} |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 161 | fi |
| 162 | |
Will Drewry | 7ab698d | 2010-08-05 13:57:52 -0500 | [diff] [blame] | 163 | DEVKEYSDIR="/usr/share/vboot/devkeys" |
| 164 | |
Bertrand SIMONNET | 5ba8adf | 2015-04-16 11:58:52 -0700 | [diff] [blame] | 165 | "${BOARD_ROOT}/build/bin/eclean" -d packages |
Will Drewry | 12f14ce | 2010-08-17 17:27:16 -0500 | [diff] [blame] | 166 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 167 | if [[ ${skip_blacklist_check} -ne ${FLAGS_FALSE} ]]; then |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 168 | check_blacklist |
| 169 | fi |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 170 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 171 | # Handle existing directory. |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 172 | if [[ -e "${BUILD_DIR}" ]]; then |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 173 | if [[ ${FLAGS_replace} -eq ${FLAGS_TRUE} ]]; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 174 | sudo rm -rf "${BUILD_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 175 | else |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 176 | error "Directory ${BUILD_DIR} already exists." |
| 177 | error "Use --build_attempt option to specify an unused attempt." |
Brian Harring | 7f175a5 | 2012-03-02 05:37:00 -0800 | [diff] [blame] | 178 | error "Or use --replace if you want to overwrite this directory." |
| 179 | die "Unwilling to overwrite ${BUILD_DIR}." |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 180 | fi |
| 181 | fi |
| 182 | |
J. Richard Barnette | a308b39 | 2011-08-29 13:53:34 -0700 | [diff] [blame] | 183 | # Create the output directory and temporary mount points. |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 184 | mkdir -p "${BUILD_DIR}" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 185 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 186 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 187 | echo 'operation: creating base image' |
| 188 | fi |
| 189 | |
Liam McLoughlin | 5b37c54 | 2012-08-16 11:09:37 -0700 | [diff] [blame] | 190 | # Create the base image. |
Paul Taysom | 00df6f6 | 2012-11-20 12:35:40 -0800 | [diff] [blame] | 191 | create_base_image ${PRISTINE_IMAGE_NAME} ${FLAGS_enable_rootfs_verification} \ |
| 192 | ${FLAGS_enable_bootcache} |
Tan Gao | 843b70a | 2010-08-17 09:41:48 -0700 | [diff] [blame] | 193 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 194 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 195 | echo 'operation: done creating base image' |
| 196 | fi |
| 197 | |
Liam McLoughlin | d606ee2 | 2012-07-03 16:48:57 -0700 | [diff] [blame] | 198 | # Running board-specific setup if any exists. |
| 199 | if type board_setup &>/dev/null; then |
| 200 | board_setup "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}" |
| 201 | fi |
| 202 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 203 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 204 | echo 'operation: creating developer image' |
| 205 | fi |
| 206 | |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 207 | # Create a developer image if an image that is based on it is requested. |
| 208 | if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \ |
| 209 | ${CHROMEOS_TEST_IMAGE_NAME} ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 210 | copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME} |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 211 | install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME} |
Bill Richardson | 6ed1358 | 2010-06-16 21:38:15 -0700 | [diff] [blame] | 212 | fi |
| 213 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 214 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 215 | echo 'operation: done creating developer image' |
| 216 | echo 'operation: creating test image' |
| 217 | fi |
| 218 | |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 219 | # From a developer image create a test|factory_test image. |
| 220 | if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then |
| 221 | copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${CHROMEOS_TEST_IMAGE_NAME} |
| 222 | mod_image_for_test ${CHROMEOS_TEST_IMAGE_NAME} |
| 223 | fi |
| 224 | if should_build_image ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Chris Sosa | b0f5732 | 2011-10-25 03:07:23 +0000 | [diff] [blame] | 225 | copy_image ${CHROMEOS_DEVELOPER_IMAGE_NAME} \ |
| 226 | ${CHROMEOS_FACTORY_TEST_IMAGE_NAME} |
| 227 | mod_image_for_test ${CHROMEOS_FACTORY_TEST_IMAGE_NAME} |
Vince Laviano | 6aebf31 | 2011-06-01 15:27:31 -0700 | [diff] [blame] | 228 | fi |
| 229 | |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 230 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
Ralph Nathan | a5ba50e | 2015-04-21 13:41:12 -0700 | [diff] [blame] | 231 | echo 'operation: done creating test image' |
| 232 | fi |
| 233 | |
Steve Fung | 5d7a0ae | 2015-05-08 15:16:12 -0700 | [diff] [blame] | 234 | # Move the completed image to the output_root. |
| 235 | move_image "${BUILD_DIR}" "${OUTPUT_DIR}" |
Steve Fung | 817a1ef | 2015-05-06 17:23:17 -0700 | [diff] [blame] | 236 | |
David James | 4dd4c54 | 2011-08-10 10:19:47 -0700 | [diff] [blame] | 237 | # Create a named symlink. |
| 238 | LINK_NAME="${FLAGS_output_root}/${BOARD}/${FLAGS_symlink}" |
Steve Fung | 817a1ef | 2015-05-06 17:23:17 -0700 | [diff] [blame] | 239 | ln -sfT $(basename ${OUTPUT_DIR}) ${LINK_NAME} |
Olof Johansson | 58f25cc | 2010-08-04 21:18:49 -0700 | [diff] [blame] | 240 | |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 241 | WORKSPACE_PREFIX="//" |
Steve Fung | 817a1ef | 2015-05-06 17:23:17 -0700 | [diff] [blame] | 242 | OUTPUT_DIR_NAME="${OUTPUT_DIR/"${_WORKSPACE_DIRS[1]}/"/${WORKSPACE_PREFIX}}" |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 243 | |
| 244 | info "Done. Image(s) created in ${OUTPUT_DIR_NAME}" |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 245 | echo |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 246 | |
| 247 | # Print out the images we generated. |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 248 | summarize() { |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 249 | |
| 250 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
| 251 | echo 'operation: summarize' |
| 252 | fi |
| 253 | |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 254 | local name="$1" img="$2" |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 255 | local dir_path |
| 256 | |
| 257 | if [[ "${FLAGS_output_root}" == "${__flags_output_root_default}" ]]; then |
| 258 | dir_path=${OUTSIDE_OUTPUT_DIR} |
| 259 | else |
Steve Fung | 817a1ef | 2015-05-06 17:23:17 -0700 | [diff] [blame] | 260 | dir_path="${OUTPUT_DIR}" |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 261 | fi |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 262 | |
| 263 | info "${name} image created as ${img}" |
| 264 | info "To copy the image to a USB key, use:" |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 265 | info " cros flash usb:// ${dir_path}/${img}" |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 266 | if [[ $# -ge 3 ]]; then |
| 267 | info "To convert it to a VM image, use:" |
Steve Fung | 1fcece0 | 2015-04-06 17:54:50 -0700 | [diff] [blame] | 268 | info " ./image_to_vm.sh --from=${dir_path} --board=${BOARD} $3" |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 269 | fi |
| 270 | echo |
Ralph Nathan | 89157bf | 2015-05-14 14:06:13 -0700 | [diff] [blame] | 271 | |
| 272 | if [[ ${FLAGS_progress_bar} -eq ${FLAGS_TRUE} ]]; then |
| 273 | echo 'operation: done summarize' |
| 274 | fi |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 275 | } |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 276 | if should_build_image ${CHROMEOS_BASE_IMAGE_NAME}; then |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 277 | summarize "Non-developer Chromium OS" "${PRISTINE_IMAGE_NAME}" |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 278 | fi |
| 279 | if should_build_image ${CHROMEOS_FACTORY_SHIM_NAME}; then |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 280 | summarize "Chromium OS Factory install shim" "${PRISTINE_IMAGE_NAME}" |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 281 | fi |
| 282 | if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 283 | summarize "Developer" "${CHROMEOS_DEVELOPER_IMAGE_NAME}" "" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 284 | fi |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 285 | if should_build_image ${CHROMEOS_FACTORY_TEST_IMAGE_NAME}; then |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 286 | summarize "Factory test" "${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" "--factory" |
Chris Sosa | c9422fa | 2012-03-05 15:58:07 -0800 | [diff] [blame] | 287 | fi |
| 288 | if should_build_image ${CHROMEOS_TEST_IMAGE_NAME}; then |
Mike Frysinger | b86854a | 2014-11-25 18:43:58 -0500 | [diff] [blame] | 289 | summarize "Test" "${CHROMEOS_TEST_IMAGE_NAME}" "--test" |
Vince Laviano | 6aebf31 | 2011-06-01 15:27:31 -0700 | [diff] [blame] | 290 | fi |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 291 | |
Matt Tennant | 0a9d32d | 2012-07-30 16:51:37 -0700 | [diff] [blame] | 292 | command_completed |