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 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
(...skipping 15 matching lines...) Expand all Loading... | |
26 DEFINE_string image "" "Location of the rootfs raw image file" i | 26 DEFINE_string image "" "Location of the rootfs raw image file" i |
27 DEFINE_boolean installmask $FLAGS_TRUE \ | 27 DEFINE_boolean installmask $FLAGS_TRUE \ |
28 "Use INSTALL_MASK to shrink the resulting image." m | 28 "Use INSTALL_MASK to shrink the resulting image." m |
29 DEFINE_integer jobs -1 \ | 29 DEFINE_integer jobs -1 \ |
30 "How many packages to build in parallel at maximum." j | 30 "How many packages to build in parallel at maximum." j |
31 DEFINE_string qualdb "" "Location of qualified component file" d | 31 DEFINE_string qualdb "" "Location of qualified component file" d |
32 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y | 32 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y |
33 DEFINE_string build_root "/build" \ | 33 DEFINE_string build_root "/build" \ |
34 "The root location for board sysroots." | 34 "The root location for board sysroots." |
35 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" | 35 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" |
36 DEFINE_boolean inplace $FLAGS_TRUE \ | |
37 "Modify/overwrite the image ${CHROMEOS_IMAGE_NAME} in place. \ | |
38 Otherwise the image will be copied to ${CHROMEOS_TEST_IMAGE_NAME} \ | |
39 if needed, and modified there" | |
40 DEFINE_boolean force_copy ${FLAGS_FALSE} \ | |
41 "Always rebuild test image if --noinplace" | |
36 | 42 |
37 | 43 |
38 # Parse command line | 44 # Parse command line |
39 FLAGS "$@" || exit 1 | 45 FLAGS "$@" || exit 1 |
40 eval set -- "${FLAGS_ARGV}" | 46 eval set -- "${FLAGS_ARGV}" |
41 | 47 |
42 EMERGE_CMD="emerge" | 48 EMERGE_CMD="emerge" |
43 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" | 49 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" |
44 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then | 50 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then |
45 echo "Using alternate emerge" | 51 echo "Using alternate emerge" |
46 EMERGE_CMD="${SCRIPTS_DIR}/parallel_emerge" | 52 EMERGE_CMD="${SCRIPTS_DIR}/parallel_emerge" |
47 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" | 53 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" |
48 fi | 54 fi |
49 | 55 |
50 # No board, no default and no image set then we can't find the image | 56 # No board, no default and no image set then we can't find the image |
51 if [ -z $FLAGS_image ] && [ -z $FLAGS_board ] ; then | 57 if [ -z $FLAGS_image ] && [ -z $FLAGS_board ] ; then |
52 setup_board_warning | 58 setup_board_warning |
53 die "mod_image_for_test failed. No board set and no image set" | 59 die "mod_image_for_test failed. No board set and no image set" |
54 fi | 60 fi |
55 | 61 |
56 # We have a board name but no image set. Use image at default location | 62 # We have a board name but no image set. Use image at default location |
57 if [ -z $FLAGS_image ] ; then | 63 if [ -z $FLAGS_image ] ; then |
58 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 64 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
59 FILENAME="chromiumos_image.bin" | 65 FILENAME="${CHROMEOS_IMAGE_NAME}" |
60 FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}" | 66 FLAGS_image="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/${FILENAME}" |
61 fi | 67 fi |
62 | 68 |
63 # Turn path into an absolute path. | 69 # Turn path into an absolute path. |
64 FLAGS_image=`eval readlink -f ${FLAGS_image}` | 70 FLAGS_image=`eval readlink -f ${FLAGS_image}` |
65 | 71 |
66 # Abort early if we can't find the image | 72 # Abort early if we can't find the image |
67 if [ ! -f $FLAGS_image ] ; then | 73 if [ ! -f $FLAGS_image ] ; then |
68 echo "No image found at $FLAGS_image" | 74 echo "No image found at $FLAGS_image" |
69 exit 1 | 75 exit 1 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 --exclude=site_tests/desktopui_UITest \ | 154 --exclude=site_tests/desktopui_UITest \ |
149 --exclude=.svn \ | 155 --exclude=.svn \ |
150 ${AUTOTEST_SRC}/client/* "${stateful_root}/${autotest_client}" | 156 ${AUTOTEST_SRC}/client/* "${stateful_root}/${autotest_client}" |
151 | 157 |
152 sudo chmod 755 "${stateful_root}/${autotest_client}" | 158 sudo chmod 755 "${stateful_root}/${autotest_client}" |
153 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}" | 159 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}" |
154 } | 160 } |
155 | 161 |
156 # main process begins here. | 162 # main process begins here. |
157 | 163 |
164 IMAGE_DIR="$(dirname "${FLAGS_image}")" | |
165 | |
166 # Copy the image to a test location if required | |
167 if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then | |
168 TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_TEST_IMAGE_NAME}" | |
169 if [ ! -f "${TEST_PATHNAME}" ] || \ | |
170 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | |
171 echo "Creating test image from original..." | |
172 ${COMMON_PV_CAT} "${FLAGS_image}" >"${TEST_PATHNAME}" \ | |
173 || die "Cannot copy ${FLAGS_image} to test image" | |
174 FLAGS_image="${TEST_PATHNAME}" | |
175 else | |
176 echo "Using cached test image" | |
sosa
2010/12/01 20:37:45
Don't you have to set FLAGS_image here too? Might
sjg
2010/12/01 20:54:00
Actually it is a flag, and is set further up the f
| |
177 fi | |
178 | |
179 # No need to confirm now, since we are not overwriting the main image | |
180 FLAGS_yes="$FLAGS_TRUE" | |
181 fi | |
182 | |
158 # Make sure this is really what the user wants, before nuking the device | 183 # Make sure this is really what the user wants, before nuking the device |
159 if [ $FLAGS_yes -ne $FLAGS_TRUE ]; then | 184 if [ $FLAGS_yes -ne $FLAGS_TRUE ]; then |
160 read -p "Modifying image ${FLAGS_image} for test; are you sure (y/N)? " SURE | 185 read -p "Modifying image ${FLAGS_image} for test; are you sure (y/N)? " SURE |
161 SURE="${SURE:0:1}" # Get just the first character | 186 SURE="${SURE:0:1}" # Get just the first character |
162 if [ "$SURE" != "y" ]; then | 187 if [ "$SURE" != "y" ]; then |
163 echo "Ok, better safe than sorry." | 188 echo "Ok, better safe than sorry." |
164 exit 1 | 189 exit 1 |
165 fi | 190 fi |
166 else | 191 else |
167 echo "Modifying image ${FLAGS_image} for test..." | 192 echo "Modifying image ${FLAGS_image} for test..." |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 cleanup | 254 cleanup |
230 | 255 |
231 # Now make it bootable with the flags from build_image | 256 # Now make it bootable with the flags from build_image |
232 ${SCRIPTS_DIR}/bin/cros_make_image_bootable $(dirname "${FLAGS_image}") \ | 257 ${SCRIPTS_DIR}/bin/cros_make_image_bootable $(dirname "${FLAGS_image}") \ |
233 $(basename "${FLAGS_image}") | 258 $(basename "${FLAGS_image}") |
234 | 259 |
235 print_time_elapsed | 260 print_time_elapsed |
236 | 261 |
237 trap - EXIT | 262 trap - EXIT |
238 | 263 |
OLD | NEW |