Chromium Code Reviews| 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. |
| 11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
| 12 | 12 |
| 13 DEFINE_string image "rootfs.image" \ | 13 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" |
| 14 DEFAULT_IMAGE="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)/rootfs.image" | |
|
petkov
2009/12/07 22:14:11
Does it make sense to use the get_latest_image.sh
| |
| 15 DEFINE_string image "$DEFAULT_IMAGE" \ | |
| 14 "Location of the rootfs raw image file" | 16 "Location of the rootfs raw image file" |
| 15 | 17 |
| 16 # Parse command line | 18 # Parse command line |
| 17 FLAGS "$@" || exit 1 | 19 FLAGS "$@" || exit 1 |
| 18 eval set -- "${FLAGS_ARGV}" | 20 eval set -- "${FLAGS_ARGV}" |
| 19 | 21 |
| 20 # Make sure anything mounted in the rootfs is cleaned up ok on exit. | 22 # Make sure anything mounted in the rootfs is cleaned up ok on exit. |
| 21 cleanup_rootfs_mounts() { | 23 cleanup_rootfs_mounts() { |
| 22 # Occasionally there are some daemons left hanging around that have our | 24 # Occasionally there are some daemons left hanging around that have our |
| 23 # root image file system open. We do a best effort attempt to kill them. | 25 # root image file system open. We do a best effort attempt to kill them. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 54 set -e | 56 set -e |
| 55 trap cleanup EXIT | 57 trap cleanup EXIT |
| 56 | 58 |
| 57 ROOT_FS_DIR="`dirname ${FLAGS_image}`/rootfs" | 59 ROOT_FS_DIR="`dirname ${FLAGS_image}`/rootfs" |
| 58 mkdir -p "${ROOT_FS_DIR}" | 60 mkdir -p "${ROOT_FS_DIR}" |
| 59 | 61 |
| 60 LOOP_DEV=`sudo losetup -f` | 62 LOOP_DEV=`sudo losetup -f` |
| 61 sudo losetup "${LOOP_DEV}" "${FLAGS_image}" | 63 sudo losetup "${LOOP_DEV}" "${FLAGS_image}" |
| 62 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" | 64 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" |
| 63 | 65 |
| 66 echo "Modifying image ${FLAGS_image} for test..." | |
| 67 | |
| 64 # Run build steps for modify for test | 68 # Run build steps for modify for test |
| 65 sudo mkdir -p "${ROOT_FS_DIR}/modify_build" | 69 sudo mkdir -p "${ROOT_FS_DIR}/modify_build" |
| 66 scripts_dir="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | 70 scripts_dir="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" |
| 67 for script in "${scripts_dir}"/b[0-9][0-9][0-9]*[!$~]; do | 71 for script in "${scripts_dir}"/b[0-9][0-9][0-9]*[!$~]; do |
| 68 . ${script} | 72 . ${script} |
| 69 done | 73 done |
| 70 | 74 |
| 71 MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | 75 MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" |
| 72 sudo mkdir -p "${ROOT_FS_DIR}/modify_scripts" | 76 sudo mkdir -p "${ROOT_FS_DIR}/modify_scripts" |
| 73 sudo mount --bind "${MOD_SCRIPTS_ROOT}" "${ROOT_FS_DIR}/modify_scripts" | 77 sudo mount --bind "${MOD_SCRIPTS_ROOT}" "${ROOT_FS_DIR}/modify_scripts" |
| 74 | 78 |
| 75 # Run test setup script inside chroot jail to modify the image | 79 # Run test setup script inside chroot jail to modify the image |
| 76 sudo chroot "${ROOT_FS_DIR}" "/modify_scripts/test_setup.sh" | 80 sudo chroot "${ROOT_FS_DIR}" "/modify_scripts/test_setup.sh" |
| 77 | 81 |
| 78 sudo umount "${ROOT_FS_DIR}/modify_scripts" | 82 sudo umount "${ROOT_FS_DIR}/modify_scripts" |
| 79 sudo rmdir "${ROOT_FS_DIR}/modify_scripts" | 83 sudo rmdir "${ROOT_FS_DIR}/modify_scripts" |
| 80 sudo rm -rf "${ROOT_FS_DIR}/modify_build" | 84 sudo rm -rf "${ROOT_FS_DIR}/modify_build" |
| 81 | 85 |
| 82 cleanup | 86 cleanup |
| 83 trap - EXIT | 87 trap - EXIT |
| 84 | 88 |
| OLD | NEW |