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

Side by Side Diff: src/scripts/image_to_usb.sh

Issue 1606004: Only mod image for test if necessary (Closed)
Patch Set: Dealt with whitespace Created 10 years, 8 months 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
« no previous file with comments | « no previous file | 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 convert the output of build_image.sh to a usb image. 7 # Script to convert the output of build_image.sh to a usb image.
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 30 matching lines...) Expand all
41 SYSROOT="${FLAGS_build_root}/${FLAGS_board}" 41 SYSROOT="${FLAGS_build_root}/${FLAGS_board}"
42 else 42 else
43 SYSROOT="${DEFAULT_CHROOT_DIR}${FLAGS_build_root}/${FLAGS_board}" 43 SYSROOT="${DEFAULT_CHROOT_DIR}${FLAGS_build_root}/${FLAGS_board}"
44 fi 44 fi
45 AUTOTEST_SRC="${SYSROOT}/usr/local/autotest" 45 AUTOTEST_SRC="${SYSROOT}/usr/local/autotest"
46 46
47 # Die on any errors. 47 # Die on any errors.
48 set -e 48 set -e
49 49
50 # No board, no default and no image set then we can't find the image 50 # No board, no default and no image set then we can't find the image
51 if [ -z ${FLAGS_from} ] && [ -z ${FLAGS_board} ] ; then 51 if [ -z ${FLAGS_from} ] && [ -z ${FLAGS_board} ] ; then
52 setup_board_warning 52 setup_board_warning
53 exit 1 53 exit 1
54 fi 54 fi
55 55
56 # We have a board name but no image set. Use image at default location 56 # We have a board name but no image set. Use image at default location
57 if [ -z "${FLAGS_from}" ]; then 57 if [ -z "${FLAGS_from}" ]; then
58 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" 58 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
59 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)" 59 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)"
60 fi 60 fi
61 61
(...skipping 21 matching lines...) Expand all
83 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. 83 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work.
84 FLAGS_from=`eval readlink -f ${FLAGS_from}` 84 FLAGS_from=`eval readlink -f ${FLAGS_from}`
85 FLAGS_to=`eval readlink -f ${FLAGS_to}` 85 FLAGS_to=`eval readlink -f ${FLAGS_to}`
86 86
87 # Use this image as the source image to copy 87 # Use this image as the source image to copy
88 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" 88 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin"
89 89
90 # If we're asked to modify the image for test, then let's make a copy and 90 # If we're asked to modify the image for test, then let's make a copy and
91 # modify that instead. 91 # modify that instead.
92 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then 92 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then
93 # Copy it. 93 if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] ; then
94 echo "Creating test image from original..." 94 # Copy it.
95 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" 95 echo "Creating test image from original..."
96 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin"
97 # Modify it.
98 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
99 "${FLAGS_from}/chromiumos_test_image.bin"
100 fi
96 # Use it. 101 # Use it.
97 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" 102 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin"
98 # Modify it.
99 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image "${SRC_IMAGE}"
100 fi 103 fi
101 104
102 STATEFUL_DIR="${FLAGS_from}/stateful_partition" 105 STATEFUL_DIR="${FLAGS_from}/stateful_partition"
103 mkdir -p "${STATEFUL_DIR}" 106 mkdir -p "${STATEFUL_DIR}"
104 107
105 function do_cleanup { 108 function do_cleanup {
106 echo "Cleaning loopback devices: ${STATEFUL_LOOP_DEV}" 109 echo "Cleaning loopback devices: ${STATEFUL_LOOP_DEV}"
107 if [ "${STATEFUL_LOOP_DEV}" != "" ]; then 110 if [ "${STATEFUL_LOOP_DEV}" != "" ]; then
108 sudo umount "${STATEFUL_DIR}" 111 sudo umount "${STATEFUL_DIR}"
109 sudo losetup -d "${STATEFUL_LOOP_DEV}" 112 sudo losetup -d "${STATEFUL_LOOP_DEV}"
(...skipping 22 matching lines...) Expand all
132 echo "Mounting ${STATEFUL_DIR} loopback" 135 echo "Mounting ${STATEFUL_DIR} loopback"
133 sudo losetup -o $(( $offset * 512 )) "${stateful_loop_dev}" "${SRC_IMAGE}" 136 sudo losetup -o $(( $offset * 512 )) "${stateful_loop_dev}" "${SRC_IMAGE}"
134 sudo mount "${stateful_loop_dev}" "${STATEFUL_DIR}" 137 sudo mount "${stateful_loop_dev}" "${STATEFUL_DIR}"
135 stateful_root="${STATEFUL_DIR}/dev_image" 138 stateful_root="${STATEFUL_DIR}/dev_image"
136 139
137 echo "Install autotest into stateful partition..." 140 echo "Install autotest into stateful partition..."
138 autotest_client="/home/autotest-client" 141 autotest_client="/home/autotest-client"
139 sudo mkdir -p "${stateful_root}${autotest_client}" 142 sudo mkdir -p "${stateful_root}${autotest_client}"
140 143
141 sudo cp -fpru ${AUTOTEST_SRC}/client/* \ 144 sudo cp -fpru ${AUTOTEST_SRC}/client/* \
142 » "${stateful_root}/${autotest_client}" 145 "${stateful_root}/${autotest_client}"
143 sudo chmod 755 "${stateful_root}/${autotest_client}" 146 sudo chmod 755 "${stateful_root}/${autotest_client}"
144 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}" 147 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}"
145 148
146 sudo umount ${STATEFUL_DIR} 149 sudo umount ${STATEFUL_DIR}
147 sudo losetup -d "${stateful_loop_dev}" 150 sudo losetup -d "${stateful_loop_dev}"
148 trap - INT TERM EXIT 151 trap - INT TERM EXIT
149 rmdir "${STATEFUL_DIR}" 152 rmdir "${STATEFUL_DIR}"
150 else 153 else
151 echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed." 154 echo "/usr/local/autotest under ${DEFAULT_CHROOT_DIR} is not installed."
152 echo "Please call make_autotest.sh inside chroot first." 155 echo "Please call make_autotest.sh inside chroot first."
153 exit -1 156 exit -1
154 fi 157 fi
155 fi 158 fi
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" 210 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M"
208 echo "where /dev/sdb is the entire keyfob." 211 echo "where /dev/sdb is the entire keyfob."
209 if [ ${INSIDE_CHROOT} -eq 1 ] 212 if [ ${INSIDE_CHROOT} -eq 1 ]
210 then 213 then
211 example=$(basename "${FLAGS_to}") 214 example=$(basename "${FLAGS_to}")
212 echo "NOTE: Since you are currently inside the chroot, and you'll need to" 215 echo "NOTE: Since you are currently inside the chroot, and you'll need to"
213 echo "run dd outside the chroot, the path to the USB image will be" 216 echo "run dd outside the chroot, the path to the USB image will be"
214 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." 217 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)."
215 fi 218 fi
216 fi 219 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698