Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 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 |
| 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 | |
| 12 | # Load common constants. This should be the first executable line. |
| 13 | # The path to common.sh should be relative to your script's location. |
| 14 | . "$(dirname "$0")/common.sh" |
| 15 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 16 | . "$(dirname "$0")/chromeos-common.sh" # for partoffset |
| 17 | locate_gpt |
| 18 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 19 | # Script must be run inside the chroot. |
Don Garrett | 640a058 | 2010-05-04 16:54:28 -0700 | [diff] [blame] | 20 | restart_in_chroot_if_needed $* |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 21 | |
| 22 | get_default_board |
| 23 | |
| 24 | # Flags. |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 25 | DEFINE_string board "${DEFAULT_BOARD}" \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 26 | "The board to build an image for." |
| 27 | DEFINE_string build_root "/build" \ |
| 28 | "The root location for board sysroots." |
| 29 | DEFINE_integer build_attempt 1 \ |
| 30 | "The build attempt for this image build." |
| 31 | DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \ |
| 32 | "Directory in which to place image result directories (named by version)" |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 33 | DEFINE_boolean replace ${FLAGS_FALSE} \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 34 | "Overwrite existing output, if any." |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 35 | DEFINE_boolean withdev ${FLAGS_TRUE} \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 36 | "Include useful developer friendly utilities in the image." |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 37 | DEFINE_boolean installmask ${FLAGS_TRUE} \ |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 38 | "Use INSTALL_MASK to shrink the resulting image." |
| 39 | DEFINE_integer jobs -1 \ |
| 40 | "How many packages to build in parallel at maximum." |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 41 | DEFINE_boolean statefuldev ${FLAGS_TRUE} \ |
Chris Sosa | 4bffb8b | 2010-04-07 17:23:54 -0700 | [diff] [blame] | 42 | "Install development packages on stateful partition rather than the rootfs" |
Antoine Labour | e9e585f | 2010-04-01 15:57:57 -0700 | [diff] [blame] | 43 | DEFINE_string to "" \ |
| 44 | "The target image file or device" |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 45 | DEFINE_boolean factory_install ${FLAGS_FALSE} \ |
Tom Wai-Hong Tam | f87a367 | 2010-05-17 16:06:33 +0800 | [diff] [blame] | 46 | "Build a smaller image to overlay the factory install shim on; this argument \ |
| 47 | is also required in image_to_usb." |
robotboy | b75eee3 | 2010-04-30 09:51:23 -0700 | [diff] [blame] | 48 | DEFINE_string arm_extra_bootargs "" \ |
| 49 | "Additional command line options to pass to the ARM kernel." |
Zelidrag Hornung | 1d12c1a | 2010-06-02 10:20:29 -0700 | [diff] [blame] | 50 | DEFINE_integer rootfs_partition_size 1024 \ |
| 51 | "rootfs parition size in MBs." |
| 52 | DEFINE_integer rootfs_size 720 \ |
| 53 | "rootfs filesystem size in MBs." |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 54 | # ceil(0.1 * rootfs_size) is a good minimum. |
| 55 | DEFINE_integer rootfs_hash_pad 8 \ |
| 56 | "MBs reserved at the end of the rootfs image." |
Eric Li | 5cf288f | 2010-06-28 12:46:26 -0700 | [diff] [blame] | 57 | DEFINE_integer statefulfs_size 1024 \ |
| 58 | "stateful filesystem size in MBs." |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 59 | DEFINE_boolean preserve ${FLAGS_FALSE} \ |
| 60 | "Attempt to preserve the previous build image if one can be found (unstable, \ |
| 61 | kernel/firmware not updated)" |
David James | 0366864 | 2010-07-28 17:08:29 -0700 | [diff] [blame^] | 62 | DEFINE_boolean fast ${DEFAULT_FAST} \ |
| 63 | "Call many emerges in parallel" |
Nick Sanders | f2dee6c | 2010-07-01 00:21:32 -0700 | [diff] [blame] | 64 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 65 | DEFINE_string usb_disk /dev/sdb3 \ |
| 66 | "Path syslinux should use to do a usb boot. Default: /dev/sdb3" |
| 67 | |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 68 | DEFINE_boolean enable_rootfs_verification ${FLAGS_FALSE} \ |
| 69 | "Default all bootloaders to use kernel-based root fs integrity checking." |
| 70 | DEFINE_integer verity_error_behavior 2 \ |
| 71 | "Kernel verified boot error behavior (0: I/O errors, 1: reboot, 2: nothing) \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 72 | Default: 2" |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 73 | DEFINE_integer verity_depth 1 \ |
| 74 | "Kernel verified boot hash tree depth. Default: 1" |
| 75 | DEFINE_integer verity_max_ios 1024 \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 76 | "Number of outstanding I/O operations dm-verity caps at. Default: 1024" |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 77 | DEFINE_string verity_algorithm "sha1" \ |
| 78 | "Cryptographic hash algorithm used for kernel vboot. Default : sha1" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 79 | |
Nikita Kostylev | c8bba90 | 2010-07-28 17:05:26 +0400 | [diff] [blame] | 80 | DEFINE_string oem_customization "" \ |
Denis Romanov | 95bdf47 | 2010-07-12 22:44:42 +0400 | [diff] [blame] | 81 | "Path to directory containing OEM partner partition contents" |
| 82 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 83 | # Parse command line. |
| 84 | FLAGS "$@" || exit 1 |
| 85 | eval set -- "${FLAGS_ARGV}" |
| 86 | |
| 87 | # Only now can we die on error. shflags functions leak non-zero error codes, |
| 88 | # so will die prematurely if 'set -e' is specified before now. |
| 89 | set -e |
| 90 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 91 | if [ -z "${FLAGS_board}" ] ; then |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 92 | error "--board is required." |
| 93 | exit 1 |
| 94 | fi |
| 95 | |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 96 | if [ "$((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad))" -gt \ |
| 97 | "${FLAGS_rootfs_partition_size}" ] ; then |
| 98 | error "rootfs ($((FLAGS_rootfs_size + FLAGS_rootfs_hash_pad)) MB) is \ |
| 99 | bigger than partition (${FLAGS_rootfs_partition_size} MB)." |
Zelidrag Hornung | 1d12c1a | 2010-06-02 10:20:29 -0700 | [diff] [blame] | 100 | exit 1 |
| 101 | fi |
| 102 | |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 103 | EMERGE_BOARD_CMD="emerge-${FLAGS_board}" |
Nick Sanders | f2dee6c | 2010-07-01 00:21:32 -0700 | [diff] [blame] | 104 | if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 105 | echo "Using alternate emerge" |
Nick Sanders | f2dee6c | 2010-07-01 00:21:32 -0700 | [diff] [blame] | 106 | EMERGE_BOARD_CMD="${SCRIPTS_DIR}/parallel_emerge --board=${FLAGS_board}" |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 107 | fi |
| 108 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 109 | # Determine build version. |
| 110 | . "${SCRIPTS_DIR}/chromeos_version.sh" |
| 111 | |
| 112 | # Use canonical path since some tools (e.g. mount) do not like symlinks. |
| 113 | # Append build attempt to output directory. |
| 114 | IMAGE_SUBDIR="${CHROMEOS_VERSION_STRING}-a${FLAGS_build_attempt}" |
| 115 | OUTPUT_DIR="${FLAGS_output_root}/${FLAGS_board}/${IMAGE_SUBDIR}" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 116 | |
| 117 | OUTSIDE_OUTPUT_DIR="../build/images/${FLAGS_board}/${IMAGE_SUBDIR}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 118 | |
| 119 | # If we are creating a developer image, also create a pristine image with a |
| 120 | # different name. |
| 121 | DEVELOPER_IMAGE_NAME= |
| 122 | PRISTINE_IMAGE_NAME=chromiumos_image.bin |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 123 | if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 124 | PRISTINE_IMAGE_NAME=chromiumos_base_image.bin |
| 125 | DEVELOPER_IMAGE_NAME=chromiumos_image.bin |
| 126 | fi |
Tan Gao | a40ed44 | 2010-06-02 15:45:19 -0700 | [diff] [blame] | 127 | |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 128 | PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" |
| 129 | DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 130 | |
| 131 | BOARD="${FLAGS_board}" |
| 132 | BOARD_ROOT="${FLAGS_build_root}/${BOARD}" |
| 133 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 134 | ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" |
| 135 | ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 136 | ROOT_FS_HASH="${OUTPUT_DIR}/rootfs.hash" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 137 | |
| 138 | STATEFUL_FS_IMG="${OUTPUT_DIR}/stateful_partition.image" |
| 139 | STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition" |
| 140 | |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 141 | OEM_FS_IMG="${OUTPUT_DIR}/partner_partition.image" |
| 142 | OEM_FS_DIR="${OUTPUT_DIR}/partner_partition" |
| 143 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 144 | ESP_FS_IMG=${OUTPUT_DIR}/esp.image |
| 145 | ESP_FS_DIR=${OUTPUT_DIR}/esp |
| 146 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 147 | LOOP_DEV= |
Chris Sosa | 4bffb8b | 2010-04-07 17:23:54 -0700 | [diff] [blame] | 148 | STATEFUL_LOOP_DEV= |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 149 | OEM_LOOP_DEV= |
Bill Richardson | a81df76 | 2010-04-09 08:12:05 -0700 | [diff] [blame] | 150 | ESP_LOOP_DEV= |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 151 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 152 | # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will |
| 153 | # be installed on the stateful dir. On a Chromium OS system, this will |
| 154 | # translate to /usr/local. |
| 155 | DEV_IMAGE_ROOT="${STATEFUL_FS_DIR}/dev_image" |
| 156 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 157 | # What cross-build are we targeting? |
| 158 | . "${BOARD_ROOT}/etc/make.conf.board_setup" |
| 159 | LIBC_VERSION=${LIBC_VERSION:-"2.10.1-r1"} |
| 160 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 161 | INSTALL_MASK="" |
| 162 | if [[ ${FLAGS_installmask} -eq ${FLAGS_TRUE} ]] ; then |
| 163 | INSTALL_MASK="${DEFAULT_INSTALL_MASK}" |
| 164 | fi |
| 165 | |
| 166 | # Reduce the size of factory install shim. |
| 167 | # TODO: Build a separated ebuild for the factory install shim to reduce size. |
| 168 | if [[ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]] ; then |
| 169 | INSTALL_MASK="${INSTALL_MASK} ${FACTORY_INSTALL_MASK}" |
| 170 | fi |
| 171 | |
David James | fd7403a | 2010-07-09 12:00:17 -0700 | [diff] [blame] | 172 | if [[ ${FLAGS_jobs} -ne -1 ]]; then |
| 173 | EMERGE_JOBS="--jobs=${FLAGS_jobs}" |
| 174 | fi |
| 175 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 176 | # Figure out ARCH from the given toolchain. |
| 177 | # TODO: Move to common.sh as a function after scripts are switched over. |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 178 | TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 179 | case "${TC_ARCH}" in |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 180 | arm*) |
| 181 | ARCH="arm" |
| 182 | ;; |
| 183 | *86) |
| 184 | ARCH="x86" |
| 185 | ;; |
| 186 | *) |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 187 | error "Unable to determine ARCH from toolchain: ${CHOST}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 188 | exit 1 |
| 189 | esac |
| 190 | |
| 191 | # Hack to fix bug where x86_64 CHOST line gets incorrectly added. |
| 192 | # ToDo(msb): remove this hack. |
| 193 | PACKAGES_FILE="${BOARD_ROOT}/packages/Packages" |
| 194 | sudo sed -e "s/CHOST: x86_64-pc-linux-gnu//" -i "${PACKAGES_FILE}" |
| 195 | |
| 196 | # Handle existing directory. |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 197 | if [[ -e "${OUTPUT_DIR}" ]]; then |
| 198 | if [[ ${FLAGS_replace} -eq ${FLAGS_TRUE} ]]; then |
| 199 | sudo rm -rf "${OUTPUT_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 200 | else |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 201 | echo "Directory ${OUTPUT_DIR} already exists." |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 202 | echo "Use --build_attempt option to specify an unused attempt." |
| 203 | echo "Or use --replace if you want to overwrite this directory." |
| 204 | exit 1 |
| 205 | fi |
| 206 | fi |
| 207 | |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 208 | # Find previous build, if any... |
| 209 | PREVIOUS_DIR=$($SCRIPTS_DIR/get_latest_image.sh --board="$BOARD") |
| 210 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 211 | cleanup_rootfs_loop() { |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 212 | sudo umount -d "${ROOT_FS_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | cleanup_stateful_fs_loop() { |
Chris Sosa | 4bffb8b | 2010-04-07 17:23:54 -0700 | [diff] [blame] | 216 | sudo umount "${ROOT_FS_DIR}/usr/local" |
| 217 | sudo umount "${ROOT_FS_DIR}/var" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 218 | sudo umount -d "${STATEFUL_FS_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 221 | cleanup_oem_fs_loop() { |
| 222 | sudo umount -d "${OEM_FS_DIR}" |
| 223 | } |
| 224 | |
| 225 | |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 226 | cleanup_esp_loop() { |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 227 | sudo umount -d "${ESP_FS_DIR}" |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 230 | cleanup() { |
| 231 | # Disable die on error. |
| 232 | set +e |
| 233 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 234 | if [[ -n "${STATEFUL_LOOP_DEV}" ]]; then |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 235 | cleanup_stateful_fs_loop |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 236 | STATEFUL_LOOP_DEV= |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 237 | fi |
| 238 | |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 239 | if [[ -n "${OEM_LOOP_DEV}" ]]; then |
| 240 | cleanup_oem_fs_loop |
| 241 | fi |
| 242 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 243 | if [[ -n "${LOOP_DEV}" ]]; then |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 244 | cleanup_rootfs_loop |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 245 | LOOP_DEV= |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 246 | fi |
| 247 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 248 | if [[ -n "${ESP_LOOP_DEV}" ]]; then |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 249 | cleanup_esp_loop |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 250 | ESP_LOOP_DEV= |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 251 | fi |
| 252 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 253 | # Turn die on error back on. |
| 254 | set -e |
| 255 | } |
| 256 | |
Chris Sosa | bde8c1b | 2010-04-29 14:02:35 -0700 | [diff] [blame] | 257 | delete_prompt() { |
| 258 | echo "An error occurred in your build so your latest output directory" \ |
| 259 | "is invalid." |
| 260 | read -p "Would you like to delete the output directory (y/N)? " SURE |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 261 | SURE="${SURE:0:1}" # Get just the first character. |
Chris Sosa | bde8c1b | 2010-04-29 14:02:35 -0700 | [diff] [blame] | 262 | if [ "${SURE}" == "y" ] ; then |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 263 | sudo rm -rf "${OUTPUT_DIR}" |
| 264 | echo "Deleted ${OUTPUT_DIR}" |
Chris Sosa | bde8c1b | 2010-04-29 14:02:35 -0700 | [diff] [blame] | 265 | else |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 266 | echo "Not deleting ${OUTPUT_DIR}. Note dev server updates will not work" \ |
Chris Sosa | bde8c1b | 2010-04-29 14:02:35 -0700 | [diff] [blame] | 267 | "until you successfully build another image or delete this directory" |
| 268 | fi |
| 269 | } |
| 270 | |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 271 | # $1 - Directory where developer rootfs is mounted. |
| 272 | # $2 - Directory where developer stateful_partition is mounted. |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 273 | # $3 - Directory where the ESP partition is mounted. |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 274 | mount_gpt_cleanup() { |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 275 | local rootfs="${1-$ROOT_FS_DIR}" |
| 276 | local statefs="${2-$STATEFUL_FS_DIR}" |
| 277 | local espfs="${3-$ESP_FS_DIR}" |
| 278 | "${SCRIPTS_DIR}/mount_gpt_image.sh" \ |
| 279 | -u -r "${rootfs}" -s "${statefs}" -e "${espfs}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 280 | delete_prompt |
| 281 | } |
| 282 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 283 | make_image_bootable() { |
| 284 | local image_name="$1" |
| 285 | cros_root=/dev/sd%D%P |
| 286 | if [[ "${ARCH}" = "arm" ]]; then |
| 287 | # TODO(wad) assumed like in build_gpt for now. |
| 288 | cros_root=/dev/mmcblk1p3 |
| 289 | fi |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 290 | if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 291 | cros_root=/dev/dm-0 |
| 292 | fi |
| 293 | |
| 294 | # TODO(wad) mount the root fs to LOOP_DEV from the image |
| 295 | trap "mount_gpt_cleanup" EXIT |
| 296 | ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
| 297 | --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
Will Drewry | 721d94f | 2010-07-16 14:39:45 -0500 | [diff] [blame] | 298 | -s "${STATEFUL_FS_DIR}" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 299 | |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 300 | # The rootfs should never be mounted rw again after this point without |
| 301 | # re-calling make_image_bootable. |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 302 | sudo mount -o remount,ro "${ROOT_FS_DIR}" |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 303 | root_dev=$(mount | grep -- "on ${ROOT_FS_DIR} type" | cut -f1 -d' ' | tail -1) |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 304 | |
Mandeep Singh Baines | 87b1694 | 2010-07-09 20:52:41 -0700 | [diff] [blame] | 305 | DEVKEYSDIR="/usr/share/vboot/devkeys" |
Louis Yung-Chieh Lo | 3602040 | 2010-07-05 13:23:34 +0800 | [diff] [blame] | 306 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 307 | # Builds the kernel partition image. The temporary files are kept around |
| 308 | # so that we can perform a load_kernel_test later on the final image. |
| 309 | ${SCRIPTS_DIR}/build_kernel_image.sh \ |
| 310 | --arch="${ARCH}" \ |
| 311 | --to="${OUTPUT_DIR}/vmlinuz.image" \ |
Louis Yung-Chieh Lo | 3602040 | 2010-07-05 13:23:34 +0800 | [diff] [blame] | 312 | --hd_vblock="${OUTPUT_DIR}/vmlinuz_hd.vblock" \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 313 | --vmlinuz="${OUTPUT_DIR}/boot/vmlinuz" \ |
| 314 | --working_dir="${OUTPUT_DIR}" \ |
| 315 | --keep_work \ |
| 316 | --rootfs_image=${root_dev} \ |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 317 | --rootfs_hash=${ROOT_FS_HASH} \ |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 318 | --verity_hash_alg=${FLAGS_verity_algorithm} \ |
| 319 | --verity_tree_depth=${FLAGS_verity_depth} \ |
| 320 | --verity_max_ios=${FLAGS_verity_max_ios} \ |
| 321 | --verity_error_behavior=${FLAGS_verity_error_behavior} \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 322 | --root=${cros_root} \ |
Louis Yung-Chieh Lo | 3602040 | 2010-07-05 13:23:34 +0800 | [diff] [blame] | 323 | --keys_dir="${DEVKEYSDIR}" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 324 | |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 325 | local rootfs_hash_size=$(stat -c '%s' ${ROOT_FS_HASH}) |
| 326 | info "Appending rootfs.hash (${rootfs_hash_size} bytes) to the root fs" |
| 327 | if [[ ${rootfs_hash_size} -gt $((FLAGS_rootfs_hash_pad * 1024 * 1024)) ]] |
| 328 | then |
| 329 | die "--rootfs_hash_pad reserves less than the needed ${rootfs_hash_size}" |
| 330 | fi |
| 331 | # Unfortunately, mount_gpt_image uses mount and not losetup to create the |
| 332 | # loop devices. This means that they are not the correct size. We have to |
| 333 | # write directly to the image to append the hash tree data. |
| 334 | local hash_offset="$(partoffset ${OUTPUT_DIR}/${image_name} 3)" |
| 335 | hash_offset=$((hash_offset + ((1024 * 1024 * ${FLAGS_rootfs_size}) / 512))) |
| 336 | sudo dd bs=512 \ |
| 337 | seek=${hash_offset} \ |
| 338 | if="${ROOT_FS_HASH}" \ |
| 339 | of="${OUTPUT_DIR}/${image_name}" \ |
| 340 | conv=notrunc |
| 341 | # We don't need to keep the file around anymore. |
| 342 | sudo rm "${ROOT_FS_HASH}" |
| 343 | |
Louis Yung-Chieh Lo | ca1c2b0 | 2010-07-05 17:37:05 +0800 | [diff] [blame] | 344 | # Move the verification block needed for the hard disk install to the |
| 345 | # stateful partition. Mount stateful fs, copy file, and umount fs. |
| 346 | # In original CL: http://codereview.chromium.org/2868044, this was done in |
| 347 | # create_base_image(). However, it could break the build if it is a clean |
| 348 | # build because vmlinuz_hd.vblock hasn't been created by build_kernel_image.sh |
Louis Yung-Chieh Lo | 85d49fc | 2010-07-05 22:55:31 +0800 | [diff] [blame] | 349 | if [[ "${ARCH}" = "x86" ]]; then |
Louis Yung-Chieh Lo | 85d49fc | 2010-07-05 22:55:31 +0800 | [diff] [blame] | 350 | sudo cp "${OUTPUT_DIR}/vmlinuz_hd.vblock" "${STATEFUL_FS_DIR}" |
Louis Yung-Chieh Lo | ca1c2b0 | 2010-07-05 17:37:05 +0800 | [diff] [blame] | 351 | fi |
Louis Yung-Chieh Lo | ca1c2b0 | 2010-07-05 17:37:05 +0800 | [diff] [blame] | 352 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 353 | # START_KERN_A is set by the first call to install the gpt. |
| 354 | local koffset="$(partoffset ${OUTPUT_DIR}/${image_name} 2)" |
| 355 | sudo dd if="${OUTPUT_DIR}/vmlinuz.image" of="${OUTPUT_DIR}/${image_name}" \ |
| 356 | conv=notrunc bs=512 seek=${koffset} |
| 357 | |
Will Drewry | 07e3505 | 2010-07-09 14:50:42 -0700 | [diff] [blame] | 358 | # Update the bootloaders. For legacy/efi x86, the EFI system partition |
| 359 | # will be updated and for arm, the mbr will be updated (for u-boot). |
Will Drewry | 721d94f | 2010-07-16 14:39:45 -0500 | [diff] [blame] | 360 | local kernel_part= |
| 361 | local bootloader_to= |
| 362 | local bootloader_to_flags= |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 363 | local usb_disk="${FLAGS_usb_disk}" |
Will Drewry | 721d94f | 2010-07-16 14:39:45 -0500 | [diff] [blame] | 364 | |
| 365 | if [[ "${ARCH}" = "x86" ]]; then |
| 366 | # x86 should update the esp in place in the image. |
| 367 | bootloader_to="${OUTPUT_DIR}/${image_name}" |
| 368 | local esp_offset="$(partoffset ${OUTPUT_DIR}/${image_name} 12)" |
| 369 | esp_offset=$((esp_offset * 512)) # sectors to bytes |
| 370 | local esp_size="$(partsize ${OUTPUT_DIR}/${image_name} 12)" |
| 371 | esp_size=$((esp_size * 512)) # sectors to bytes |
| 372 | bootloader_to_flags="--to_offset=${esp_offset} --to_size=${esp_size}" |
| 373 | # Use the kernel partition to acquire configuration flags. |
| 374 | kernel_part="--kernel_partition='${OUTPUT_DIR}/vmlinuz.image'" |
| 375 | # Install syslinux on the EFI System Partition. |
| 376 | kernel_part="${kernel_part} --install_syslinux" |
| 377 | elif [[ "${ARCH}" = "arm" ]]; then |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 378 | # TODO(wad) mmcblk1p3 is hardcoded for arm for now! |
| 379 | usb_disk="/dev/mmcblk1p3" |
Will Drewry | 721d94f | 2010-07-16 14:39:45 -0500 | [diff] [blame] | 380 | # ARM doesn't support using the kernel image for kernel cmdline flags yet. |
Will Drewry | 82780e5 | 2010-07-03 18:27:10 -0700 | [diff] [blame] | 381 | kernel_part="--kernel_cmdline=\"${FLAGS_arm_extra_bootargs}\" " |
| 382 | # TODO(wad) Integrate dmtable extraction into the arm build |
| 383 | # E.g. $(cat ${OUTPUT_DIR}/boot.config | tr -s '\n' ' ')" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 384 | local kpart_offset="--kernel_partition_offset=${koffset}" |
Will Drewry | 82780e5 | 2010-07-03 18:27:10 -0700 | [diff] [blame] | 385 | local kpart_size="--kernel_partition_sectors=" |
| 386 | kpart_size="${kpart_size}$(partsize ${OUTPUT_DIR}/${image_name} 2)" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 387 | kernel_part="${kernel_part} ${kpart_size} ${kpart_offset}" |
Will Drewry | 82780e5 | 2010-07-03 18:27:10 -0700 | [diff] [blame] | 388 | info "Using addition bootloader arguments: ${kernel_part}" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 389 | bootloader_to="${OUTPUT_DIR}/arm.mbr" |
| 390 | fi |
| 391 | |
| 392 | # Update partition 12 / legacy bootloaders and arm. |
| 393 | ${SCRIPTS_DIR}/update_bootloaders.sh \ |
| 394 | --arch=${ARCH} \ |
| 395 | --to="${bootloader_to}" \ |
| 396 | --from="${OUTPUT_DIR}"/boot \ |
| 397 | --vmlinuz="${OUTPUT_DIR}"/boot/vmlinuz \ |
| 398 | --usb_disk="${usb_disk}" \ |
Will Drewry | 721d94f | 2010-07-16 14:39:45 -0500 | [diff] [blame] | 399 | ${bootloader_to_flags} \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 400 | $kernel_part |
| 401 | |
| 402 | if [[ "${ARCH}" == "arm" ]]; then |
| 403 | sudo dd bs=1 conv=notrunc if="${bootloader_to}" \ |
| 404 | of="${OUTPUT_DIR}/${image_name}" |
| 405 | sudo rm "${bootloader_to}" |
| 406 | fi |
| 407 | |
| 408 | trap - EXIT |
| 409 | ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
Andrew de los Reyes | 3172b7e | 2010-07-15 22:10:47 -0700 | [diff] [blame] | 410 | -s "${STATEFUL_FS_DIR}" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 411 | } |
| 412 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 413 | # Modifies an existing image to add development packages |
| 414 | update_dev_packages() { |
| 415 | local image_name=$1 |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 416 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 417 | echo "Adding developer packages to ${image_name}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 418 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 419 | trap "mount_gpt_cleanup" EXIT |
Tan Gao | a40ed44 | 2010-06-02 15:45:19 -0700 | [diff] [blame] | 420 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 421 | ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 422 | --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 423 | -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 424 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 425 | # Determine the root dir for developer packages. |
| 426 | local root_dev_dir="${ROOT_FS_DIR}" |
| 427 | [ ${FLAGS_statefuldev} -eq ${FLAGS_TRUE} ] && \ |
| 428 | root_dev_dir="${ROOT_FS_DIR}/usr/local" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 429 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 430 | # Install developer packages described in chromeos-dev. |
| 431 | sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 432 | --root="${root_dev_dir}" --root-deps=rdeps \ |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 433 | --usepkg -uDNv chromeos-dev ${EMERGE_JOBS} |
| 434 | |
| 435 | if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then |
| 436 | # Clean out unused packages |
| 437 | sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 438 | --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 439 | --usepkg --depclean ${EMERGE_JOBS} |
| 440 | fi |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 441 | |
| 442 | # Re-run ldconfig to fix /etc/ldconfig.so.cache. |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 443 | sudo /sbin/ldconfig -r "${ROOT_FS_DIR}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 444 | |
| 445 | # Mark the image as a developer image (input to chromeos_startup). |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 446 | sudo mkdir -p "${ROOT_FS_DIR}/root" |
| 447 | sudo touch "${ROOT_FS_DIR}/root/.dev_mode" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 448 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 449 | # Additional changes to developer image. |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 450 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 451 | # The ldd tool is a useful shell script but lives in glibc; just copy it. |
| 452 | sudo cp -a "$(which ldd)" "${root_dev_dir}/usr/bin" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 453 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 454 | # If vim is installed, then a vi symlink would probably help. |
| 455 | if [[ -x "${ROOT_FS_DIR}/usr/local/bin/vim" ]]; then |
| 456 | sudo ln -sf vim "${ROOT_FS_DIR}/usr/local/bin/vi" |
Girts Folkmanis | 7a8a838 | 2010-05-18 22:52:25 -0700 | [diff] [blame] | 457 | fi |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 458 | |
Tammo Spalink | cfc0c64 | 2010-07-07 10:51:21 +0800 | [diff] [blame] | 459 | # If pygtk is installed in stateful-dev, then install a path. |
| 460 | if [[ -d \ |
| 461 | "${ROOT_FS_DIR}/usr/local/lib/python2.6/site-packages/gtk-2.0" ]]; then |
| 462 | sudo bash -c "\ |
| 463 | echo gtk-2.0 > \ |
| 464 | ${ROOT_FS_DIR}/usr/local/lib/python2.6/site-packages/pygtk.pth" |
| 465 | fi |
| 466 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 467 | # Check that the image has been correctly created. Only do it if not |
| 468 | # building a factory install image, as the INSTALL_MASK for it will |
| 469 | # make test_image fail. |
| 470 | if [[ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]] ; then |
| 471 | "${SCRIPTS_DIR}/test_image" \ |
| 472 | --root="${ROOT_FS_DIR}" \ |
| 473 | --target="${ARCH}" |
| 474 | fi |
| 475 | echo "Developer image built and stored at ${image_name}" |
| 476 | |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 477 | trap - EXIT |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 478 | ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 479 | -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | # Update the base package on an existing image. |
| 483 | update_base_packages() { |
| 484 | local image_name=$1 |
| 485 | |
| 486 | echo "Updating base packages on ${image_name}" |
| 487 | |
| 488 | # Create stateful partition of the same size as the rootfs. |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 489 | trap "mount_gpt_cleanup" EXIT |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 490 | |
| 491 | ${SCRIPTS_DIR}/mount_gpt_image.sh --from "${OUTPUT_DIR}" \ |
| 492 | --image "${image_name}" -r "${ROOT_FS_DIR}" \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 493 | -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 494 | |
| 495 | # Emerge updated packages, exactly like when creating base image |
| 496 | sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 497 | --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 498 | --usepkg -uDNv chromeos ${EMERGE_JOBS} |
| 499 | |
| 500 | # Clean out unused packages |
| 501 | sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 502 | --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
| 503 | --usepkg --depclean ${EMERGE_JOBS} |
| 504 | |
| 505 | trap - EXIT |
| 506 | ${SCRIPTS_DIR}/mount_gpt_image.sh -u -r "${ROOT_FS_DIR}" \ |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 507 | -s "${STATEFUL_FS_DIR}" -e "${ESP_FS_DIR}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 508 | } |
| 509 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 510 | create_base_image() { |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 511 | local image_name=$1 |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 512 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 513 | trap "cleanup && delete_prompt" EXIT |
Chris Sosa | 4bffb8b | 2010-04-07 17:23:54 -0700 | [diff] [blame] | 514 | |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 515 | UUID=$(uuidgen) |
| 516 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 517 | # Create and format the root file system. |
| 518 | |
| 519 | # Check for loop device before creating image. |
| 520 | LOOP_DEV=$(sudo losetup -f) |
| 521 | if [ -z "${LOOP_DEV}" ] ; then |
| 522 | echo "No free loop device. Free up a loop device or reboot. exiting. " |
| 523 | exit 1 |
| 524 | fi |
| 525 | |
| 526 | # Create root file system disk image to fit on a 1GB memory stick. |
| 527 | # 1 GB in hard-drive-manufacturer-speak is 10^9, not 2^30. 950MB < 10^9 bytes. |
| 528 | if [[ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]] ; then |
| 529 | ROOT_SIZE_BYTES=$((1024 * 1024 * 300)) |
| 530 | else |
| 531 | ROOT_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_rootfs_size})) |
| 532 | fi |
| 533 | |
Will Drewry | 9926ee2 | 2010-07-21 15:11:10 -0500 | [diff] [blame] | 534 | # Pad out for the hash tree. |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 535 | ROOT_HASH_PAD=$((FLAGS_rootfs_hash_pad * 1024 * 1024)) |
| 536 | info "Padding the rootfs image by ${ROOT_HASH_PAD} bytes for hash data" |
Will Drewry | 9926ee2 | 2010-07-21 15:11:10 -0500 | [diff] [blame] | 537 | |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 538 | dd if=/dev/zero of="${ROOT_FS_IMG}" bs=1 count=1 \ |
| 539 | seek=$((ROOT_SIZE_BYTES + ROOT_HASH_PAD - 1)) |
Will Drewry | 9926ee2 | 2010-07-21 15:11:10 -0500 | [diff] [blame] | 540 | sudo losetup "${LOOP_DEV}" "${ROOT_FS_IMG}" |
| 541 | # Specify a block size and block count to avoid using the hash pad. |
| 542 | sudo mkfs.ext3 -b 4096 "${LOOP_DEV}" "$((ROOT_SIZE_BYTES / 4096))" |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 543 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 544 | # Tune and mount rootfs. |
Will Drewry | 78992a3 | 2010-07-21 14:02:20 -0500 | [diff] [blame] | 545 | # TODO(wad) rename the disk label to match the GPT since we |
| 546 | # can't change it later. |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 547 | DISK_LABEL="C-KEYFOB" |
| 548 | sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${LOOP_DEV}" |
| 549 | sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" |
| 550 | |
| 551 | # Create stateful partition of the same size as the rootfs. |
| 552 | STATEFUL_LOOP_DEV=$(sudo losetup -f) |
| 553 | if [ -z "${STATEFUL_LOOP_DEV}" ] ; then |
| 554 | echo "No free loop device. Free up a loop device or reboot. exiting. " |
| 555 | exit 1 |
| 556 | fi |
Eric Li | 5cf288f | 2010-06-28 12:46:26 -0700 | [diff] [blame] | 557 | STATEFUL_SIZE_BYTES=$((1024 * 1024 * ${FLAGS_statefulfs_size})) |
| 558 | dd if=/dev/zero of="${STATEFUL_FS_IMG}" bs=1 count=1 \ |
| 559 | seek=$((STATEFUL_SIZE_BYTES - 1)) |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 560 | |
| 561 | # Tune and mount the stateful partition. |
| 562 | UUID=$(uuidgen) |
| 563 | DISK_LABEL="C-STATE" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 564 | sudo losetup "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_IMG}" |
| 565 | sudo mkfs.ext3 "${STATEFUL_LOOP_DEV}" |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 566 | sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${STATEFUL_LOOP_DEV}" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 567 | sudo mount "${STATEFUL_LOOP_DEV}" "${STATEFUL_FS_DIR}" |
| 568 | |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 569 | # Create OEM partner partition. |
| 570 | OEM_LOOP_DEV=$(sudo losetup -f) |
| 571 | if [ -z "${OEM_LOOP_DEV}" ] ; then |
| 572 | echo "No free loop device. Free up a loop device or reboot. exiting. " |
| 573 | exit 1 |
| 574 | fi |
| 575 | OEM_SIZE_BYTES=$((1024 * 1024 * 16)) |
| 576 | dd if=/dev/zero of="${OEM_FS_IMG}" bs=1 count=1 seek=$((OEM_SIZE_BYTES - 1)) |
| 577 | |
| 578 | # Tune and mount OEM partner partition. |
| 579 | UUID=$(uuidgen) |
| 580 | DISK_LABEL="C-OEM" |
| 581 | sudo losetup "${OEM_LOOP_DEV}" "${OEM_FS_IMG}" |
| 582 | sudo mkfs.ext3 "${OEM_LOOP_DEV}" |
| 583 | sudo tune2fs -L "${DISK_LABEL}" -U "${UUID}" -c 0 -i 0 "${OEM_LOOP_DEV}" |
| 584 | sudo mount "${OEM_LOOP_DEV}" "${OEM_FS_DIR}" |
| 585 | |
Denis Romanov | 95bdf47 | 2010-07-12 22:44:42 +0400 | [diff] [blame] | 586 | # Populate OEM partner partition. |
Nikita Kostylev | c8bba90 | 2010-07-28 17:05:26 +0400 | [diff] [blame] | 587 | if [ ! -z "${FLAGS_oem_customization}" ]; then |
Denis Romanov | 95bdf47 | 2010-07-12 22:44:42 +0400 | [diff] [blame] | 588 | if [ ! -d ${FLAGS_oem_customization} ]; then |
| 589 | echo "Specified OEM content directory does not exist. exiting." |
| 590 | exit 1 |
| 591 | fi |
| 592 | for ITEM in `ls -A ${FLAGS_oem_customization}` |
| 593 | do sudo cp -a "${FLAGS_oem_customization}/$ITEM" "${OEM_FS_DIR}" |
| 594 | done |
| 595 | sudo find "${OEM_FS_DIR}" -type d -exec chmod 755 "{}" \; |
| 596 | sudo find "${OEM_FS_DIR}" -type f -exec chmod 644 "{}" \; |
| 597 | sudo chown -R root:root "${OEM_FS_DIR}" |
Nikita Kostylev | c8bba90 | 2010-07-28 17:05:26 +0400 | [diff] [blame] | 598 | else |
| 599 | echo "Empty OEM partition: OEM customizations will not be applied." |
Denis Romanov | 95bdf47 | 2010-07-12 22:44:42 +0400 | [diff] [blame] | 600 | fi |
| 601 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 602 | # -- Install packages into the root file system -- |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 603 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 604 | # We need to install libc manually from the cross toolchain. |
| 605 | # TODO: Improve this? We only want libc and not the whole toolchain. |
| 606 | PKGDIR="/var/lib/portage/pkgs/cross/" |
| 607 | sudo tar jxvpf \ |
| 608 | "${PKGDIR}/${CHOST}/cross-${CHOST}"/glibc-${LIBC_VERSION}.tbz2 \ |
| 609 | -C "${ROOT_FS_DIR}" --strip-components=3 \ |
| 610 | --exclude=usr/include --exclude=sys-include --exclude=*.a --exclude=*.o |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 611 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 612 | # We need to install libstdc++ manually from the cross toolchain. |
| 613 | # TODO: Figure out a better way of doing this? |
| 614 | sudo cp -a "${BOARD_ROOT}"/lib/libgcc_s.so* "${ROOT_FS_DIR}/lib" |
| 615 | sudo cp -a "${BOARD_ROOT}"/usr/lib/libstdc++.so* "${ROOT_FS_DIR}/usr/lib" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 616 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 617 | # Prepare stateful partition with some pre-created directories. |
| 618 | sudo mkdir -p "${DEV_IMAGE_ROOT}" |
| 619 | sudo mkdir -p "${STATEFUL_FS_DIR}/var" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 620 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 621 | # Create symlinks so that /usr/local/usr based directories are symlinked to |
| 622 | # /usr/local/ directories e.g. /usr/local/usr/bin -> /usr/local/bin, etc. |
| 623 | setup_symlinks_on_root "${DEV_IMAGE_ROOT}" "${STATEFUL_FS_DIR}/var" \ |
| 624 | "${STATEFUL_FS_DIR}" |
Tom Wai-Hong Tam | f87a367 | 2010-05-17 16:06:33 +0800 | [diff] [blame] | 625 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 626 | # Perform binding rather than symlinking because directories must exist |
| 627 | # on rootfs so that we can bind at run-time since rootfs is read-only. |
| 628 | echo "Binding directories from stateful partition onto the rootfs" |
| 629 | sudo mkdir -p "${ROOT_FS_DIR}/usr/local" |
| 630 | sudo mount --bind "${DEV_IMAGE_ROOT}" "${ROOT_FS_DIR}/usr/local" |
| 631 | sudo mkdir -p "${ROOT_FS_DIR}/var" |
| 632 | sudo mount --bind "${STATEFUL_FS_DIR}/var" "${ROOT_FS_DIR}/var" |
| 633 | sudo mkdir -p "${ROOT_FS_DIR}/dev" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 634 | |
Mandeep Singh Baines | 3dfa852 | 2010-06-24 15:00:49 -0700 | [diff] [blame] | 635 | # We "emerge --root=${ROOT_FS_DIR} --root-deps=rdeps --usepkg" all of the |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 636 | # runtime packages for chrome os. This builds up a chrome os image from |
| 637 | # binary packages with runtime dependencies only. We use INSTALL_MASK to |
| 638 | # trim the image size as much as possible. |
| 639 | sudo INSTALL_MASK="${INSTALL_MASK}" ${EMERGE_BOARD_CMD} \ |
| 640 | --root="${ROOT_FS_DIR}" --root-deps=rdeps \ |
Mandeep Singh Baines | 3dfa852 | 2010-06-24 15:00:49 -0700 | [diff] [blame] | 641 | --usepkg chromeos ${EMERGE_JOBS} |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 642 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 643 | # Perform any customizations on the root file system that are needed. |
| 644 | "${SCRIPTS_DIR}/customize_rootfs" \ |
| 645 | --root="${ROOT_FS_DIR}" \ |
| 646 | --target="${ARCH}" \ |
| 647 | --board="${BOARD}" |
Bill Richardson | 8b3bd10 | 2010-04-06 15:00:10 -0700 | [diff] [blame] | 648 | |
Will Drewry | 1ee156f | 2010-07-03 13:27:19 -0500 | [diff] [blame] | 649 | # Populates the root filesystem with legacy bootloader templates |
| 650 | # appropriate for the platform. The autoupdater and installer will |
| 651 | # use those templates to update the legacy boot partition (12/ESP) |
| 652 | # on update. |
| 653 | # (This script does not populate vmlinuz.A and .B needed by syslinux.) |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 654 | enable_rootfs_verification= |
| 655 | if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
| 656 | enable_rootfs_verification="--enable_rootfs_verification" |
| 657 | fi |
| 658 | |
Will Drewry | 1ee156f | 2010-07-03 13:27:19 -0500 | [diff] [blame] | 659 | ${SCRIPTS_DIR}/create_legacy_bootloader_templates.sh \ |
| 660 | --arch=${ARCH} \ |
| 661 | --to="${ROOT_FS_DIR}"/boot \ |
| 662 | --install \ |
Will Drewry | 1670d48 | 2010-07-09 13:08:38 -0700 | [diff] [blame] | 663 | ${enable_rootfs_verification} |
Bill Richardson | 9c5e5ec | 2010-05-14 17:00:21 -0700 | [diff] [blame] | 664 | |
Will Drewry | 1ee156f | 2010-07-03 13:27:19 -0500 | [diff] [blame] | 665 | # Create a working copy so we don't need the rootfs mounted |
| 666 | sudo mkdir -p "${OUTPUT_DIR}"/boot |
| 667 | # This will include any built files dropped in /boot as well. |
| 668 | # Like the current vmlinuz. |
| 669 | sudo cp -r "${ROOT_FS_DIR}"/boot/. "${OUTPUT_DIR}"/boot/ |
Will Drewry | 25861ee | 2010-07-04 05:09:41 -0700 | [diff] [blame] | 670 | sudo chmod -R a+r "${OUTPUT_DIR}"/boot/ |
Bill Richardson | a81df76 | 2010-04-09 08:12:05 -0700 | [diff] [blame] | 671 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 672 | # Don't test the factory install shim. |
| 673 | if [[ ${FLAGS_factory_install} -eq ${FLAGS_FALSE} ]] ; then |
| 674 | # Check that the image has been correctly created. |
| 675 | "${SCRIPTS_DIR}/test_image" \ |
| 676 | --root="${ROOT_FS_DIR}" \ |
| 677 | --target="${ARCH}" |
| 678 | fi |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 679 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 680 | # Clean up symlinks so they work on a running target rooted at "/". |
| 681 | # Here development packages are rooted at /usr/local. However, do not |
| 682 | # create /usr/local or /var on host (already exist on target). |
| 683 | setup_symlinks_on_root "/usr/local" "/var" "${STATEFUL_FS_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 684 | |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 685 | # make_image_bootable will clobber vmlinuz.image for x86. |
| 686 | # Until then, just copy the kernel to vmlinuz.image. It is |
| 687 | # expected in build_gpt.sh and needed by ARM until it supports the |
| 688 | # full, signed kernel partition format. |
| 689 | cp "${ROOT_FS_DIR}/boot/vmlinuz" "${OUTPUT_DIR}/vmlinuz.image" |
| 690 | |
| 691 | # Create an empty esp image to be updated in by update_bootloaders.sh. |
| 692 | ${SCRIPTS_DIR}/create_esp.sh --to="${ESP_FS_IMG}" |
| 693 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 694 | cleanup |
Chris Sosa | bde8c1b | 2010-04-29 14:02:35 -0700 | [diff] [blame] | 695 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 696 | trap delete_prompt EXIT |
Tan Gao | 6df5aee | 2010-05-19 14:19:55 -0700 | [diff] [blame] | 697 | |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 698 | # Create the GPT-formatted image. |
| 699 | ${SCRIPTS_DIR}/build_gpt.sh \ |
| 700 | --arch=${ARCH} \ |
| 701 | --board=${FLAGS_board} \ |
| 702 | --arm_extra_bootargs="${FLAGS_arm_extra_bootargs}" \ |
| 703 | --rootfs_partition_size=${FLAGS_rootfs_partition_size} \ |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 704 | "${OUTPUT_DIR}" \ |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 705 | "${OUTPUT_DIR}/${image_name}" |
| 706 | |
| 707 | trap - EXIT |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | # Create the output directory. |
| 711 | mkdir -p "${OUTPUT_DIR}" |
| 712 | mkdir -p "${ROOT_FS_DIR}" |
| 713 | mkdir -p "${STATEFUL_FS_DIR}" |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 714 | mkdir -p "${OEM_FS_DIR}" |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 715 | mkdir -p "${ESP_FS_DIR}" |
| 716 | |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 717 | # Preserve old images by copying them forward for --preserve. |
| 718 | if [[ $FLAGS_preserve -eq ${FLAGS_TRUE} ]] ; then |
| 719 | if [[ -f ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ]] ; then |
| 720 | # Copy forward pristine image, and associated files |
| 721 | cp ${PREVIOUS_DIR}/*.sh ${PREVIOUS_DIR}/config.txt ${OUTPUT_DIR} |
| 722 | cp ${PREVIOUS_DIR}/${PRISTINE_IMAGE_NAME} ${OUTPUT_DIR} |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 723 | cp -r ${PREVIOUS_DIR}/boot ${OUTPUT_DIR}/boot |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 724 | |
| 725 | # Copy forward the developer image, if we already copied forward the base. |
| 726 | if [[ ${FLAGS_withdev} -eq ${FLAGS_TRUE} ]] && \ |
| 727 | [[ -f ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ]] ; then |
| 728 | cp ${PREVIOUS_DIR}/${DEVELOPER_IMAGE_NAME} ${OUTPUT_DIR} |
| 729 | fi |
| 730 | fi |
| 731 | fi |
| 732 | |
| 733 | if [[ -f ${PRISTINE_IMG} ]] ; then |
| 734 | update_base_packages ${PRISTINE_IMAGE_NAME} |
| 735 | else |
| 736 | create_base_image ${PRISTINE_IMAGE_NAME} |
| 737 | fi |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 738 | make_image_bootable ${PRISTINE_IMAGE_NAME} |
| 739 | |
| 740 | # FIXME: only signing things for x86 right now. |
| 741 | if [[ "${ARCH}" = "x86" ]]; then |
| 742 | # Verify the final image. |
| 743 | load_kernel_test "${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" \ |
Louis Yung-Chieh Lo | 3602040 | 2010-07-05 13:23:34 +0800 | [diff] [blame] | 744 | "${DEVKEYSDIR}/recovery_key.vbpubk" |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 745 | fi |
Bill Richardson | 4364a2e | 2010-03-30 14:17:34 -0700 | [diff] [blame] | 746 | |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 747 | # Create a developer image based on the chromium os base image. |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 748 | if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ] ; then |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 749 | if [[ ! -f ${DEVELOPER_IMG} ]] ; then |
| 750 | echo "Creating developer image from base image ${PRISTINE_IMAGE_NAME}" |
| 751 | cp ${PRISTINE_IMG} ${DEVELOPER_IMG} |
| 752 | fi |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 753 | |
David James | 868d7bb | 2010-06-24 21:48:14 -0700 | [diff] [blame] | 754 | update_dev_packages ${DEVELOPER_IMAGE_NAME} |
Will Drewry | 4a675e1 | 2010-07-03 13:35:02 -0500 | [diff] [blame] | 755 | make_image_bootable ${DEVELOPER_IMAGE_NAME} |
Bill Richardson | 6ed1358 | 2010-06-16 21:38:15 -0700 | [diff] [blame] | 756 | fi |
| 757 | |
| 758 | # Clean up temporary files. |
Don Garrett | 3f41e15 | 2010-06-21 14:54:34 -0700 | [diff] [blame] | 759 | rm -f "${ROOT_FS_IMG}" "${STATEFUL_FS_IMG}" "${OUTPUT_DIR}/vmlinuz.image" \ |
Louis Yung-Chieh Lo | 3602040 | 2010-07-05 13:23:34 +0800 | [diff] [blame] | 760 | "${ESP_FS_IMG}" "${OEM_FS_IMG}" "${OUTPUT_DIR}/vmlinuz_hd.vblock" |
Denis Romanov | 1106154 | 2010-06-29 04:23:53 +0400 | [diff] [blame] | 761 | rmdir "${ROOT_FS_DIR}" "${STATEFUL_FS_DIR}" "${OEM_FS_DIR}" "${ESP_FS_DIR}" |
Bill Richardson | 6795622 | 2010-05-28 15:38:56 -0700 | [diff] [blame] | 762 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 763 | echo "Done. Image created in ${OUTPUT_DIR}" |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 764 | echo "Chromium OS image created as ${PRISTINE_IMAGE_NAME}" |
Don Garrett | e0020b1 | 2010-06-17 15:55:35 -0700 | [diff] [blame] | 765 | if [ "${FLAGS_withdev}" -eq "${FLAGS_TRUE}" ]; then |
| 766 | echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
Chris Sosa | 9673f3b | 2010-05-18 13:24:40 -0700 | [diff] [blame] | 767 | fi |
Nick Sanders | 8ab729a | 2010-06-16 03:15:17 -0700 | [diff] [blame] | 768 | |
Nick Sanders | d250927 | 2010-06-16 03:50:04 -0700 | [diff] [blame] | 769 | print_time_elapsed |
| 770 | |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 771 | echo "To copy to USB keyfob, OUTSIDE the chroot, do something like:" |
Daniel Erat | dd9818a | 2010-04-26 09:16:44 -0700 | [diff] [blame] | 772 | echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
Will Drewry | efce668 | 2010-07-23 19:43:27 -0500 | [diff] [blame] | 773 | echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
Zelidrag Hornung | 478a0d4 | 2010-07-14 11:47:39 -0700 | [diff] [blame] | 774 | echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR}" |
Bill Richardson | c09b94f | 2010-03-15 11:40:30 -0700 | [diff] [blame] | 775 | echo "from the scripts directory where you entered the chroot." |