Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: mod_image_for_test.sh

Issue 5271010: Factored out the code to copy an image and modify it for test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« image_to_vm.sh ('K') | « image_to_vm.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 \
sjg 2010/11/30 21:07:29 I used 'inplace' since possibly this could become
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" o
sosa 2010/11/30 22:01:43 Short var doesn't really help here?
sjg 2010/12/01 20:02:31 Yes have r3emoved it.
40 DEFINE_boolean force_copy ${FLAGS_FALSE} \
sosa 2010/11/30 22:01:43 Use exact def ... i.e. always rebuild test image i
41 "If --noinplace, always copy test image"
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
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")"
sosa 2010/11/30 22:01:43 {}
165
166 # Copy the image to a test location if required
167 if [ $FLAGS_inplace -eq $FLAGS_FALSE ]; then
sosa 2010/11/30 22:01:43 be consistent with use of {}
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 $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"
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
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
OLDNEW
« image_to_vm.sh ('K') | « image_to_vm.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698