| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 DEFINE_integer jobs -1 \ | 47 DEFINE_integer jobs -1 \ |
| 48 "How many packages to build in parallel at maximum." j | 48 "How many packages to build in parallel at maximum." j |
| 49 DEFINE_string qualdb "" "Location of qualified component file" d | 49 DEFINE_string qualdb "" "Location of qualified component file" d |
| 50 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y | 50 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y |
| 51 DEFINE_string build_root "/build" \ | 51 DEFINE_string build_root "/build" \ |
| 52 "The root location for board sysroots." | 52 "The root location for board sysroots." |
| 53 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" | 53 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" |
| 54 DEFINE_boolean inplace $FLAGS_TRUE \ | 54 DEFINE_boolean inplace $FLAGS_TRUE \ |
| 55 "Modify/overwrite the image ${CHROMEOS_IMAGE_NAME} in place. \ | 55 "Modify/overwrite the image ${CHROMEOS_IMAGE_NAME} in place. \ |
| 56 Otherwise the image will be copied to ${CHROMEOS_TEST_IMAGE_NAME} \ | 56 Otherwise the image will be copied to ${CHROMEOS_TEST_IMAGE_NAME} \ |
| 57 if needed, and modified there" | 57 (or ${CHROMEOS_FACTORY_TEST_IMAGE_NAME} for --factory) if needed, and \ |
| 58 modified there" |
| 58 DEFINE_boolean force_copy ${FLAGS_FALSE} \ | 59 DEFINE_boolean force_copy ${FLAGS_FALSE} \ |
| 59 "Always rebuild test image if --noinplace" | 60 "Always rebuild test image if --noinplace" |
| 60 | 61 |
| 61 | |
| 62 # Parse command line | 62 # Parse command line |
| 63 FLAGS "$@" || exit 1 | 63 FLAGS "$@" || exit 1 |
| 64 eval set -- "${FLAGS_ARGV}" | 64 eval set -- "${FLAGS_ARGV}" |
| 65 | 65 |
| 66 EMERGE_CMD="emerge" | 66 EMERGE_CMD="emerge" |
| 67 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" | 67 EMERGE_BOARD_CMD="emerge-${FLAGS_board}" |
| 68 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then | 68 if [ "${FLAGS_fast}" -eq "${FLAGS_TRUE}" ]; then |
| 69 echo "Using alternate emerge" | 69 echo "Using alternate emerge" |
| 70 EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" | 70 EMERGE_CMD="${GCLIENT_ROOT}/chromite/bin/parallel_emerge" |
| 71 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" | 71 EMERGE_BOARD_CMD="${EMERGE_CMD} --board=${FLAGS_board}" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 sudo chmod 755 "${stateful_root}/${autotest_client}" | 175 sudo chmod 755 "${stateful_root}/${autotest_client}" |
| 176 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}" | 176 sudo chown -R 1000:1000 "${stateful_root}/${autotest_client}" |
| 177 } | 177 } |
| 178 | 178 |
| 179 # main process begins here. | 179 # main process begins here. |
| 180 | 180 |
| 181 IMAGE_DIR="$(dirname "${FLAGS_image}")" | 181 IMAGE_DIR="$(dirname "${FLAGS_image}")" |
| 182 | 182 |
| 183 # Copy the image to a test location if required | 183 # Copy the image to a test location if required |
| 184 if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then | 184 if [ ${FLAGS_inplace} -eq ${FLAGS_FALSE} ]; then |
| 185 TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_TEST_IMAGE_NAME}" | 185 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
| 186 TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_FACTORY_TEST_IMAGE_NAME}" |
| 187 else |
| 188 TEST_PATHNAME="${IMAGE_DIR}/${CHROMEOS_TEST_IMAGE_NAME}" |
| 189 fi |
| 186 if [ ! -f "${TEST_PATHNAME}" ] || \ | 190 if [ ! -f "${TEST_PATHNAME}" ] || \ |
| 187 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | 191 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then |
| 188 echo "Creating test image from original..." | 192 echo "Creating test image from original..." |
| 189 ${COMMON_PV_CAT} "${FLAGS_image}" >"${TEST_PATHNAME}" \ | 193 ${COMMON_PV_CAT} "${FLAGS_image}" >"${TEST_PATHNAME}" \ |
| 190 || die "Cannot copy ${FLAGS_image} to test image" | 194 || die "Cannot copy ${FLAGS_image} to test image" |
| 191 FLAGS_image="${TEST_PATHNAME}" | 195 FLAGS_image="${TEST_PATHNAME}" |
| 192 else | 196 else |
| 193 echo "Using cached test image" | 197 echo "Using cached test image" |
| 194 exit | 198 exit |
| 195 fi | 199 fi |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 cleanup | 274 cleanup |
| 271 | 275 |
| 272 # Now make it bootable with the flags from build_image | 276 # Now make it bootable with the flags from build_image |
| 273 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ | 277 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ |
| 274 $(basename "${FLAGS_image}") | 278 $(basename "${FLAGS_image}") |
| 275 | 279 |
| 276 print_time_elapsed | 280 print_time_elapsed |
| 277 | 281 |
| 278 trap - EXIT | 282 trap - EXIT |
| 279 | 283 |
| OLD | NEW |