Chromium Code Reviews| 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 modify a keyfob-based chromeos system image for testability. | 7 # Script to modify a keyfob-based chromeos system image for testability. |
| 8 | 8 |
| 9 # --- BEGIN COMMON.SH BOILERPLATE --- | 9 # --- BEGIN COMMON.SH BOILERPLATE --- |
| 10 # Load common CrOS utilities. Inside the chroot this file is installed in | 10 # Load common CrOS utilities. Inside the chroot this file is installed in |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 # We have a board name but no image set. Use image at default location | 80 # We have a board name but no image set. Use image at default location |
| 81 if [ -z $FLAGS_image ] ; then | 81 if [ -z $FLAGS_image ] ; then |
| 82 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 82 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
| 83 FILENAME="${CHROMEOS_IMAGE_NAME}" | 83 FILENAME="${CHROMEOS_IMAGE_NAME}" |
| 84 FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}" | 84 FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}" |
| 85 fi | 85 fi |
| 86 | 86 |
| 87 # Turn path into an absolute path. | 87 # Turn path into an absolute path. |
| 88 FLAGS_image=`eval readlink -f ${FLAGS_image}` | 88 FLAGS_image=`eval readlink -f ${FLAGS_image}` |
| 89 | 89 |
| 90 # Abort early if we can't find the image | |
| 91 if [ ! -f $FLAGS_image ] ; then | |
| 92 echo "No image found at $FLAGS_image" | |
| 93 exit 1 | |
| 94 fi | |
| 95 | |
| 96 # What cross-build are we targeting? | 90 # What cross-build are we targeting? |
| 97 . "${FLAGS_build_root}/${FLAGS_board}/etc/make.conf.board_setup" | 91 . "${FLAGS_build_root}/${FLAGS_board}/etc/make.conf.board_setup" |
| 98 # Figure out ARCH from the given toolchain. | 92 # Figure out ARCH from the given toolchain. |
| 99 # TODO: Move to common.sh as a function after scripts are switched over. | 93 # TODO: Move to common.sh as a function after scripts are switched over. |
| 100 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') | 94 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 101 case "${TC_ARCH}" in | 95 case "${TC_ARCH}" in |
| 102 arm*) | 96 arm*) |
| 103 ARCH="arm" | 97 ARCH="arm" |
| 104 ;; | 98 ;; |
| 105 *86) | 99 *86) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 read -p "Modifying image ${FLAGS_image} for test; are you sure (y/N)? " SURE | 201 read -p "Modifying image ${FLAGS_image} for test; are you sure (y/N)? " SURE |
| 208 SURE="${SURE:0:1}" # Get just the first character | 202 SURE="${SURE:0:1}" # Get just the first character |
| 209 if [ "$SURE" != "y" ]; then | 203 if [ "$SURE" != "y" ]; then |
| 210 echo "Ok, better safe than sorry." | 204 echo "Ok, better safe than sorry." |
| 211 exit 1 | 205 exit 1 |
| 212 fi | 206 fi |
| 213 else | 207 else |
| 214 echo "Modifying image ${FLAGS_image} for test..." | 208 echo "Modifying image ${FLAGS_image} for test..." |
| 215 fi | 209 fi |
| 216 | 210 |
| 211 # Abort early if we can't find the image | |
| 212 if [ ! -f $FLAGS_image ] && [ ${FLAGS_inplace} -eq ${FLAGS_TRUE} ; then | |
| 213 echo "No image found at $FLAGS_image to modify" | |
|
petkov
2011/02/17 20:00:41
die
| |
| 214 exit 1 | |
| 215 fi | |
| 216 | |
| 217 set -e | 217 set -e |
| 218 | 218 |
| 219 IMAGE_DIR=$(dirname "$FLAGS_image") | 219 IMAGE_DIR=$(dirname "$FLAGS_image") |
| 220 IMAGE_NAME="$(basename "$FLAGS_image")" | 220 IMAGE_NAME="$(basename "$FLAGS_image")" |
| 221 ROOT_FS_DIR="$IMAGE_DIR/rootfs" | 221 ROOT_FS_DIR="$IMAGE_DIR/rootfs" |
| 222 STATEFUL_DIR="$IMAGE_DIR/stateful_partition" | 222 STATEFUL_DIR="$IMAGE_DIR/stateful_partition" |
| 223 | 223 |
| 224 trap cleanup EXIT | 224 trap cleanup EXIT |
| 225 | 225 |
| 226 # Mounts gpt image and sets up var, /usr/local and symlinks. | 226 # Mounts gpt image and sets up var, /usr/local and symlinks. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 cleanup | 274 cleanup |
| 275 | 275 |
| 276 # Now make it bootable with the flags from build_image | 276 # Now make it bootable with the flags from build_image |
| 277 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ | 277 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ |
| 278 $(basename "${FLAGS_image}") | 278 $(basename "${FLAGS_image}") |
| 279 | 279 |
| 280 print_time_elapsed | 280 print_time_elapsed |
| 281 | 281 |
| 282 trap - EXIT | 282 trap - EXIT |
| 283 | 283 |
| OLD | NEW |