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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 # Load functions and constants for chromeos-install | 33 # Load functions and constants for chromeos-install |
34 . "/usr/lib/installer/chromeos-common.sh" || \ | 34 . "/usr/lib/installer/chromeos-common.sh" || \ |
35 die "Unable to load /usr/lib/installer/chromeos-common.sh" | 35 die "Unable to load /usr/lib/installer/chromeos-common.sh" |
36 | 36 |
37 get_default_board | 37 get_default_board |
38 | 38 |
39 DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b | 39 DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" b |
40 DEFINE_boolean factory $FLAGS_FALSE \ | 40 DEFINE_boolean factory $FLAGS_FALSE \ |
41 "Modify the image for manufacturing testing" f | 41 "Modify the image for manufacturing testing" f |
42 DEFINE_boolean factory_install $FLAGS_FALSE \ | |
43 "Modify the image for factory install shim" | |
44 DEFINE_string image "" "Location of the rootfs raw image file" i | 42 DEFINE_string image "" "Location of the rootfs raw image file" i |
45 DEFINE_boolean installmask $FLAGS_TRUE \ | 43 DEFINE_boolean installmask $FLAGS_TRUE \ |
46 "Use INSTALL_MASK to shrink the resulting image." m | 44 "Use INSTALL_MASK to shrink the resulting image." m |
47 DEFINE_integer jobs -1 \ | 45 DEFINE_integer jobs -1 \ |
48 "How many packages to build in parallel at maximum." j | 46 "How many packages to build in parallel at maximum." j |
49 DEFINE_string qualdb "" "Location of qualified component file" d | 47 DEFINE_string qualdb "" "Location of qualified component file" d |
50 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y | 48 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" y |
51 DEFINE_string build_root "/build" \ | 49 DEFINE_string build_root "/build" \ |
52 "The root location for board sysroots." | 50 "The root location for board sysroots." |
53 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" | 51 DEFINE_boolean fast ${DEFAULT_FAST} "Call many emerges in parallel" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 IMAGE_NAME="$(basename "$FLAGS_image")" | 219 IMAGE_NAME="$(basename "$FLAGS_image")" |
222 ROOT_FS_DIR="$IMAGE_DIR/rootfs" | 220 ROOT_FS_DIR="$IMAGE_DIR/rootfs" |
223 STATEFUL_DIR="$IMAGE_DIR/stateful_partition" | 221 STATEFUL_DIR="$IMAGE_DIR/stateful_partition" |
224 | 222 |
225 trap cleanup EXIT | 223 trap cleanup EXIT |
226 | 224 |
227 # Mounts gpt image and sets up var, /usr/local and symlinks. | 225 # Mounts gpt image and sets up var, /usr/local and symlinks. |
228 "$SCRIPTS_DIR/mount_gpt_image.sh" -i "$IMAGE_NAME" -f "$IMAGE_DIR" \ | 226 "$SCRIPTS_DIR/mount_gpt_image.sh" -i "$IMAGE_NAME" -f "$IMAGE_DIR" \ |
229 -r "$ROOT_FS_DIR" -s "$STATEFUL_DIR" | 227 -r "$ROOT_FS_DIR" -s "$STATEFUL_DIR" |
230 | 228 |
231 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then | 229 emerge_chromeos_test |
232 # We don't want to emerge test packages on factory install, otherwise we run | |
233 # out of space. | |
234 | 230 |
235 # Run factory setup script to modify the image. | 231 MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" |
236 sudo $EMERGE_BOARD_CMD --root=$ROOT_FS_DIR --usepkgonly \ | 232 # Run test setup script to modify the image |
237 --root-deps=rdeps --nodeps chromeos-factoryinstall | 233 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ |
| 234 STATEFUL_DIR="${STATEFUL_DIR}" ARCH="${ARCH}" "${MOD_TEST_ROOT}/test_setup.s
h" |
238 | 235 |
239 # Set factory server if necessary. | 236 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
240 if [ "${FACTORY_SERVER}" != "" ]; then | 237 install_autotest |
241 sudo sed -i \ | |
242 "s/CHROMEOS_AUSERVER=.*$/CHROMEOS_AUSERVER=\ | |
243 http:\/\/${FACTORY_SERVER}:8080\/update/" \ | |
244 ${ROOT_FS_DIR}/etc/lsb-release | |
245 fi | |
246 else | |
247 emerge_chromeos_test | |
248 | 238 |
249 MOD_TEST_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | 239 MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts" |
250 # Run test setup script to modify the image | 240 # Run factory setup script to modify the image |
251 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ | 241 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ |
252 STATEFUL_DIR="${STATEFUL_DIR}" ARCH="${ARCH}" "${MOD_TEST_ROOT}/test_setup
.sh" | 242 QUALDB="${FLAGS_qualdb}" BOARD=${FLAGS_board} \ |
253 | 243 "${MOD_FACTORY_ROOT}/factory_setup.sh" |
254 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then | |
255 install_autotest | |
256 | |
257 MOD_FACTORY_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts" | |
258 # Run factory setup script to modify the image | |
259 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ | |
260 QUALDB="${FLAGS_qualdb}" BOARD=${FLAGS_board} \ | |
261 "${MOD_FACTORY_ROOT}/factory_setup.sh" | |
262 fi | |
263 fi | 244 fi |
264 | 245 |
265 # Re-run ldconfig to fix /etc/ldconfig.so.cache. | 246 # Re-run ldconfig to fix /etc/ldconfig.so.cache. |
266 sudo /sbin/ldconfig -r "${ROOT_FS_DIR}" | 247 sudo /sbin/ldconfig -r "${ROOT_FS_DIR}" |
267 | 248 |
268 # Let's have a look at the image just in case.. | 249 # Let's have a look at the image just in case.. |
269 if [ "${VERIFY}" = "true" ]; then | 250 if [ "${VERIFY}" = "true" ]; then |
270 pushd "${ROOT_FS_DIR}" | 251 pushd "${ROOT_FS_DIR}" |
271 bash | 252 bash |
272 popd | 253 popd |
273 fi | 254 fi |
274 | 255 |
275 cleanup | 256 cleanup |
276 | 257 |
277 # Now make it bootable with the flags from build_image | 258 # Now make it bootable with the flags from build_image |
278 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ | 259 "${SCRIPTS_DIR}/bin/cros_make_image_bootable" "$(dirname "${FLAGS_image}")" \ |
279 $(basename "${FLAGS_image}") | 260 $(basename "${FLAGS_image}") |
280 | 261 |
281 print_time_elapsed | 262 print_time_elapsed |
282 | 263 |
283 trap - EXIT | 264 trap - EXIT |
284 | 265 |
OLD | NEW |