| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 # Turn path into an absolute path. | 62 # Turn path into an absolute path. |
| 63 FLAGS_image=`eval readlink -f ${FLAGS_image}` | 63 FLAGS_image=`eval readlink -f ${FLAGS_image}` |
| 64 | 64 |
| 65 # Abort early if we can't find the image | 65 # Abort early if we can't find the image |
| 66 if [ ! -f $FLAGS_image ] ; then | 66 if [ ! -f $FLAGS_image ] ; then |
| 67 echo "No image found at $FLAGS_image" | 67 echo "No image found at $FLAGS_image" |
| 68 exit 1 | 68 exit 1 |
| 69 fi | 69 fi |
| 70 | 70 |
| 71 # What cross-build are we targeting? |
| 72 . "${FLAGS_build_root}/${FLAGS_board}/etc/make.conf.board_setup" |
| 73 # Figure out ARCH from the given toolchain. |
| 74 # TODO: Move to common.sh as a function after scripts are switched over. |
| 75 TC_ARCH=$(echo "${CHOST}" | awk -F'-' '{ print $1 }') |
| 76 case "${TC_ARCH}" in |
| 77 arm*) |
| 78 ARCH="arm" |
| 79 ;; |
| 80 *86) |
| 81 ARCH="x86" |
| 82 ;; |
| 83 *) |
| 84 error "Unable to determine ARCH from toolchain: ${CHOST}" |
| 85 exit 1 |
| 86 esac |
| 87 |
| 71 # Make sure anything mounted in the rootfs/stateful is cleaned up ok on exit. | 88 # Make sure anything mounted in the rootfs/stateful is cleaned up ok on exit. |
| 72 cleanup_mounts() { | 89 cleanup_mounts() { |
| 73 # Occasionally there are some daemons left hanging around that have our | 90 # Occasionally there are some daemons left hanging around that have our |
| 74 # root/stateful image file system open. We do a best effort attempt to kill | 91 # root/stateful image file system open. We do a best effort attempt to kill |
| 75 # them. | 92 # them. |
| 76 PIDS=`sudo lsof -t "$1" | sort | uniq` | 93 PIDS=`sudo lsof -t "$1" | sort | uniq` |
| 77 for pid in ${PIDS} | 94 for pid in ${PIDS} |
| 78 do | 95 do |
| 79 local cmdline=`cat /proc/$pid/cmdline` | 96 local cmdline=`cat /proc/$pid/cmdline` |
| 80 echo "Killing process that has open file on the mounted directory: $cmdline" | 97 echo "Killing process that has open file on the mounted directory: $cmdline" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 "s/CHROMEOS_AUSERVER=.*$/CHROMEOS_AUSERVER=\ | 195 "s/CHROMEOS_AUSERVER=.*$/CHROMEOS_AUSERVER=\ |
| 179 http:\/\/${FACTORY_SERVER}:8080\/update/" \ | 196 http:\/\/${FACTORY_SERVER}:8080\/update/" \ |
| 180 ${ROOT_FS_DIR}/etc/lsb-release | 197 ${ROOT_FS_DIR}/etc/lsb-release |
| 181 fi | 198 fi |
| 182 else | 199 else |
| 183 emerge_chromeos_test | 200 emerge_chromeos_test |
| 184 | 201 |
| 185 MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | 202 MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" |
| 186 # Run test setup script to modify the image | 203 # Run test setup script to modify the image |
| 187 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ | 204 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ |
| 188 STATEFUL_DIR="${STATEFUL_DIR}" "${MOD_TEST_ROOT}/test_setup.sh" | 205 STATEFUL_DIR="${STATEFUL_DIR}" ARCH="${ARCH}" "${MOD_TEST_ROOT}/test_setup
.sh" |
| 189 | 206 |
| 190 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then | 207 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
| 191 install_autotest | 208 install_autotest |
| 192 | 209 |
| 193 MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts" | 210 MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts" |
| 194 # Run factory setup script to modify the image | 211 # Run factory setup script to modify the image |
| 195 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ | 212 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ |
| 196 QUALDB="${FLAGS_qualdb}" \ | 213 QUALDB="${FLAGS_qualdb}" \ |
| 197 "${MOD_FACTORY_ROOT}/factory_setup.sh" | 214 "${MOD_FACTORY_ROOT}/factory_setup.sh" |
| 198 fi | 215 fi |
| 199 fi | 216 fi |
| 200 | 217 |
| 201 # Let's have a look at the image just in case.. | 218 # Let's have a look at the image just in case.. |
| 202 if [ "${VERIFY}" = "true" ]; then | 219 if [ "${VERIFY}" = "true" ]; then |
| 203 pushd "${ROOT_FS_DIR}" | 220 pushd "${ROOT_FS_DIR}" |
| 204 bash | 221 bash |
| 205 popd | 222 popd |
| 206 fi | 223 fi |
| 207 | 224 |
| 208 cleanup | 225 cleanup |
| 209 | 226 |
| 210 print_time_elapsed | 227 print_time_elapsed |
| 211 | 228 |
| 212 trap - EXIT | 229 trap - EXIT |
| 213 | 230 |
| OLD | NEW |