OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Script to build a bootable keyfob-based chromeos system image from within | 7 # Script to build a bootable keyfob-based chromeos system image from within |
8 # a chromiumos setup. This assumes that all needed packages have been built into | 8 # a chromiumos setup. This assumes that all needed packages have been built into |
9 # the given target's root with binary packages turned on. This script will | 9 # the given target's root with binary packages turned on. This script will |
10 # build the Chrome OS image using only pre-built binary packages. | 10 # build the Chrome OS image using only pre-built binary packages. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 echo "Using alternate emerge" | 180 echo "Using alternate emerge" |
181 EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" | 181 EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" |
182 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" | 182 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" |
183 fi | 183 fi |
184 | 184 |
185 OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/" | 185 OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/chromiumos-overlay/chromeos/" |
186 | 186 |
187 # Determine build version. | 187 # Determine build version. |
188 . "${OVERLAY_CHROMEOS_DIR}/config/chromeos_version.sh" | 188 . "${OVERLAY_CHROMEOS_DIR}/config/chromeos_version.sh" |
189 | 189 |
| 190 BOARD="${FLAGS_board}" |
| 191 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" |
| 192 |
| 193 # What cross-build are we targeting? |
| 194 . "${BOARD_ROOT}/etc/make.conf.board_setup" |
| 195 LIBC_VERSION=${LIBC_VERSION} |
| 196 |
| 197 # Figure out ARCH from the given toolchain. |
| 198 # TODO: Move to common.sh as a function after scripts are switched over. |
| 199 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 200 case "${TC_ARCH}" in |
| 201 arm*) |
| 202 ARCH="arm" |
| 203 ;; |
| 204 *86) |
| 205 ARCH="x86" |
| 206 ;; |
| 207 *) |
| 208 error "Unable to determine ARCH from toolchain: ${CHOST}" |
| 209 exit 1 |
| 210 esac |
| 211 |
190 # Configure extra USE or packages for this type of build. | 212 # Configure extra USE or packages for this type of build. |
191 EXTRA_PACKAGES="" | 213 EXTRA_PACKAGES="" |
192 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then | 214 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
193 # Factory install needs to have the factory installer added. | 215 # Factory install needs to have the factory installer added. |
194 EXTRA_PACKAGES="${EXTRA_PACKAGES} chromeos-base/chromeos-factoryinstall" | 216 EXTRA_PACKAGES="${EXTRA_PACKAGES} chromeos-base/chromeos-factoryinstall" |
195 # On x86, booting factory install shim on SD card needs to have the kernel | 217 # On x86, we boot the factory install shim from an SD card using |
196 # initrmafs enabled. On ARM, booting factory install image on network does | 218 # initramfs for our root. On ARM, we boot the factory install shim |
197 # not needs initramfs. Force to enable fbconsole to fix a display driver bug. | 219 # over the network, so we don't require initramfs, but we do require |
198 if [ ${ARCH} -eq "arm" ] ; then | 220 # fbconsole to fix a display driver bug. |
| 221 if [ "${ARCH}" = "x86" ] ; then |
| 222 export USE="${USE} initramfs" |
| 223 fi |
| 224 if [ "${ARCH}" = "arm" ] ; then |
199 export USE="${USE} fbconsole" | 225 export USE="${USE} fbconsole" |
200 else | |
201 export USE="${USE} initramfs" | |
202 fi | 226 fi |
203 fi | 227 fi |
204 | 228 |
205 emerge_to_image() { | 229 emerge_to_image() { |
206 sudo -E ${EMERGE_BOARD_CMD} --root-deps=rdeps --usepkgonly \ | 230 sudo -E ${EMERGE_BOARD_CMD} --root-deps=rdeps --usepkgonly \ |
207 "$@" ${EMERGE_JOBS} | 231 "$@" ${EMERGE_JOBS} |
208 } | 232 } |
209 | 233 |
210 # Freshen kernel with correct USE flags. This is a noop if we have | 234 # Freshen kernel with correct USE flags. This is a noop if we have |
211 # the right kernel prebuilt. Factory install uses USE="initramfs". | 235 # the right kernel prebuilt. Factory install uses USE="initramfs". |
(...skipping 17 matching lines...) Expand all Loading... |
229 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin | 253 PRISTINE_IMAGE_NAME=chromiumos_base_image.bin |
230 DEVELOPER_IMAGE_NAME=chromiumos_image.bin | 254 DEVELOPER_IMAGE_NAME=chromiumos_image.bin |
231 # Rename pristine image for factory install shim | 255 # Rename pristine image for factory install shim |
232 elif [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then | 256 elif [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then |
233 PRISTINE_IMAGE_NAME=factory_install_shim.bin | 257 PRISTINE_IMAGE_NAME=factory_install_shim.bin |
234 fi | 258 fi |
235 | 259 |
236 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" | 260 PRISTINE_IMG="${OUTPUT_DIR}/${PRISTINE_IMAGE_NAME}" |
237 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" | 261 DEVELOPER_IMG="${OUTPUT_DIR}/${DEVELOPER_IMAGE_NAME}" |
238 | 262 |
239 BOARD="${FLAGS_board}" | |
240 BOARD_ROOT="${FLAGS_build_root}/${BOARD}" | |
241 | |
242 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" | 263 ROOT_FS_IMG="${OUTPUT_DIR}/rootfs.image" |
243 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" | 264 ROOT_FS_DIR="${OUTPUT_DIR}/rootfs" |
244 ROOT_FS_HASH="${OUTPUT_DIR}/rootfs.hash" | 265 ROOT_FS_HASH="${OUTPUT_DIR}/rootfs.hash" |
245 | 266 |
246 STATEFUL_FS_IMG="${OUTPUT_DIR}/stateful_partition.image" | 267 STATEFUL_FS_IMG="${OUTPUT_DIR}/stateful_partition.image" |
247 STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition" | 268 STATEFUL_FS_DIR="${OUTPUT_DIR}/stateful_partition" |
248 | 269 |
249 ESP_FS_IMG=${OUTPUT_DIR}/esp.image | 270 ESP_FS_IMG=${OUTPUT_DIR}/esp.image |
250 ESP_FS_DIR=${OUTPUT_DIR}/esp | 271 ESP_FS_DIR=${OUTPUT_DIR}/esp |
251 | 272 |
252 DEVKEYSDIR="/usr/share/vboot/devkeys" | 273 DEVKEYSDIR="/usr/share/vboot/devkeys" |
253 | 274 |
254 LOOP_DEV= | 275 LOOP_DEV= |
255 STATEFUL_LOOP_DEV= | 276 STATEFUL_LOOP_DEV= |
256 ESP_LOOP_DEV= | 277 ESP_LOOP_DEV= |
257 | 278 |
258 # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will | 279 # ${DEV_IMAGE_ROOT} specifies the location of where developer packages will |
259 # be installed on the stateful dir. On a Chromium OS system, this will | 280 # be installed on the stateful dir. On a Chromium OS system, this will |
260 # translate to /usr/local. | 281 # translate to /usr/local. |
261 DEV_IMAGE_ROOT="${STATEFUL_FS_DIR}/dev_image" | 282 DEV_IMAGE_ROOT="${STATEFUL_FS_DIR}/dev_image" |
262 | 283 |
263 # What cross-build are we targeting? | |
264 . "${BOARD_ROOT}/etc/make.conf.board_setup" | |
265 LIBC_VERSION=${LIBC_VERSION} | |
266 | |
267 if [ ${FLAGS_jobs} -ne -1 ]; then | 284 if [ ${FLAGS_jobs} -ne -1 ]; then |
268 EMERGE_JOBS="--jobs=${FLAGS_jobs}" | 285 EMERGE_JOBS="--jobs=${FLAGS_jobs}" |
269 fi | 286 fi |
270 | 287 |
271 # Figure out ARCH from the given toolchain. | |
272 # TODO: Move to common.sh as a function after scripts are switched over. | |
273 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') | |
274 case "${TC_ARCH}" in | |
275 arm*) | |
276 ARCH="arm" | |
277 ;; | |
278 *86) | |
279 ARCH="x86" | |
280 ;; | |
281 *) | |
282 error "Unable to determine ARCH from toolchain: ${CHOST}" | |
283 exit 1 | |
284 esac | |
285 | |
286 if [[ ${FLAGS_crosbug12352_arm_kernel_signing} -eq ${FLAGS_TRUE} ]]; then | 288 if [[ ${FLAGS_crosbug12352_arm_kernel_signing} -eq ${FLAGS_TRUE} ]]; then |
287 crosbug12352_flag="--crosbug12352_arm_kernel_signing" | 289 crosbug12352_flag="--crosbug12352_arm_kernel_signing" |
288 else | 290 else |
289 crosbug12352_flag="--nocrosbug12352_arm_kernel_signing" | 291 crosbug12352_flag="--nocrosbug12352_arm_kernel_signing" |
290 fi | 292 fi |
291 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then | 293 if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then |
292 enable_rootfs_verification_flag="--enable_rootfs_verification" | 294 enable_rootfs_verification_flag="--enable_rootfs_verification" |
293 fi | 295 fi |
294 | 296 |
295 # Hack to fix bug where x86_64 CHOST line gets incorrectly added. | 297 # Hack to fix bug where x86_64 CHOST line gets incorrectly added. |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" | 810 echo "Developer image created as ${DEVELOPER_IMAGE_NAME}" |
809 fi | 811 fi |
810 | 812 |
811 print_time_elapsed | 813 print_time_elapsed |
812 | 814 |
813 echo "To copy to USB keyfob, do something like:" | 815 echo "To copy to USB keyfob, do something like:" |
814 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" | 816 echo " ./image_to_usb.sh --from=${OUTSIDE_OUTPUT_DIR} --to=/dev/sdX" |
815 echo "To convert to VMWare image, INSIDE the chroot, do something like:" | 817 echo "To convert to VMWare image, INSIDE the chroot, do something like:" |
816 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" | 818 echo " ./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}" |
817 echo "from the scripts directory where you entered the chroot." | 819 echo "from the scripts directory where you entered the chroot." |
OLD | NEW |