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 # Load functions and constants for chromeos-install | 13 # Load functions and constants for chromeos-install |
14 . "$(dirname "$0")/chromeos-common.sh" | 14 . "$(dirname "$0")/chromeos-common.sh" |
15 | 15 |
16 get_default_board | 16 get_default_board |
17 | 17 |
18 DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" | 18 DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" |
19 DEFINE_string qualdb "/tmp/run_remote_tests.*" \ | 19 DEFINE_string qualdb "/tmp/run_remote_tests.*" \ |
20 "Location of qualified component file" | 20 "Location of qualified component file" |
21 DEFINE_string image "" "Location of the rootfs raw image file" | 21 DEFINE_string image "" "Location of the rootfs raw image file" |
22 DEFINE_boolean manuf $FLAGS_FALSE "Modify the image for manufacturing testing" | 22 DEFINE_boolean factory $FLAGS_FALSE "Modify the image for manufacturing testing" |
23 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" | 23 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" |
24 | 24 |
25 # Parse command line | 25 # Parse command line |
26 FLAGS "$@" || exit 1 | 26 FLAGS "$@" || exit 1 |
27 eval set -- "${FLAGS_ARGV}" | 27 eval set -- "${FLAGS_ARGV}" |
28 | 28 |
29 # No board, no default and no image set then we can't find the image | 29 # No board, no default and no image set then we can't find the image |
30 if [ -z $FLAGS_image ] && [ -z $FLAGS_board ] ; then | 30 if [ -z $FLAGS_image ] && [ -z $FLAGS_board ] ; then |
31 setup_board_warning | 31 setup_board_warning |
32 echo "*** mod_image_for_test failed. No board set and no image set" | 32 echo "*** mod_image_for_test failed. No board set and no image set" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 fi | 113 fi |
114 sudo losetup -o $(( $offset * 512 )) "${LOOP_DEV}" "${FLAGS_image}" | 114 sudo losetup -o $(( $offset * 512 )) "${LOOP_DEV}" "${FLAGS_image}" |
115 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" | 115 sudo mount "${LOOP_DEV}" "${ROOT_FS_DIR}" |
116 | 116 |
117 MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | 117 MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" |
118 # Run test setup script inside chroot jail to modify the image | 118 # Run test setup script inside chroot jail to modify the image |
119 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ | 119 sudo GCLIENT_ROOT="${GCLIENT_ROOT}" ROOT_FS_DIR="${ROOT_FS_DIR}" \ |
120 "${MOD_SCRIPTS_ROOT}/test_setup.sh" | 120 "${MOD_SCRIPTS_ROOT}/test_setup.sh" |
121 | 121 |
122 # Run manufacturing test setup | 122 # Run manufacturing test setup |
123 if [ ${FLAGS_manuf} -eq ${FLAGS_TRUE} ]; then | 123 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then |
124 echo "Modifying image ${FLAGS_image} for manufacturing test..." | 124 echo "Modifying image ${FLAGS_image} for manufacturing test..." |
125 | 125 |
| 126 echo "Disabling ui.conf, don't do chrome startup on boot." |
| 127 sudo mv ${ROOT_FS_DIR}/etc/init/ui.conf \ |
| 128 ${ROOT_FS_DIR}/etc/init/ui.conf.disabled |
| 129 |
| 130 echo "Applying patch to init scripts" |
| 131 MOD_MFG_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_factory_scripts" |
| 132 pushd ${ROOT_FS_DIR} |
| 133 sudo patch -d ${ROOT_FS_DIR} -p1 < ${MOD_MFG_ROOT}/factory.patch |
| 134 popd |
| 135 |
| 136 echo "Modifying Release Description for Factory." |
| 137 FILE="${ROOT_FS_DIR}/etc/lsb-release" |
| 138 sudo sed -i 's/Test/Factory/' $FILE |
| 139 |
| 140 echo "Done applying patch." |
| 141 |
126 # Try to use the sytem component file in the most recent autotest result | 142 # Try to use the sytem component file in the most recent autotest result |
127 FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1) | 143 FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1) |
128 | 144 |
129 # Try to append the full path to the file if FLAGS_qualdb is a directory | 145 # Try to append the full path to the file if FLAGS_qualdb is a directory |
130 if [ ! -z ${FLAGS_qualdb} ] && [ -d ${FLAGS_qualdb} ]; then | 146 if [ ! -z ${FLAGS_qualdb} ] && [ -d ${FLAGS_qualdb} ]; then |
131 # TODO(waihong): Handle multiple results to deliver to multiple images | 147 # TODO(waihong): Handle multiple results to deliver to multiple images |
132 FLAGS_qualdb="${FLAGS_qualdb}/hardware_Components,*" | 148 FLAGS_qualdb="${FLAGS_qualdb}/hardware_Components,*" |
133 FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1) | 149 FLAGS_qualdb=$(ls -dt ${FLAGS_qualdb} 2>&-| head -1) |
134 FLAGS_qualdb="${FLAGS_qualdb}/hardware_Components/results/system_components" | 150 FLAGS_qualdb="${FLAGS_qualdb}/hardware_Components/results/system_components" |
135 fi | 151 fi |
136 | 152 |
137 if [ ! -z ${FLAGS_qualdb} ] && [ -f ${FLAGS_qualdb} ]; then | 153 if [ ! -z ${FLAGS_qualdb} ] && [ -f ${FLAGS_qualdb} ]; then |
138 # Copy the qualified component file to the image | 154 # Copy the qualified component file to the image |
139 echo "Copying ${FLAGS_qualdb} to the image." | 155 echo "Copying ${FLAGS_qualdb} to the image." |
140 sudo mkdir -p ${ROOT_FS_DIR}/usr/local/manufacturing | 156 sudo mkdir -p ${ROOT_FS_DIR}/usr/local/manufacturing |
141 sudo cp -f ${FLAGS_qualdb} \ | 157 sudo cp -f ${FLAGS_qualdb} \ |
142 ${ROOT_FS_DIR}/usr/local/manufacturing/qualified_components | 158 ${ROOT_FS_DIR}/usr/local/manufacturing/qualified_components |
143 else | 159 else |
144 echo "No qualified component file found at: ${FLAGS_qualdb}" | 160 echo "No qualified component file found at: ${FLAGS_qualdb}" |
145 exit 1 | |
146 fi | 161 fi |
147 fi | 162 fi |
148 | 163 |
149 cleanup | 164 cleanup |
150 trap - EXIT | 165 trap - EXIT |
151 | 166 |
OLD | NEW |