OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 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 archive build results. Used by the buildbots. | 7 # Script to archive build results. Used by the buildbots. |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 # Parse command line | 51 # Parse command line |
52 FLAGS "$@" || exit 1 | 52 FLAGS "$@" || exit 1 |
53 eval set -- "${FLAGS_ARGV}" | 53 eval set -- "${FLAGS_ARGV}" |
54 | 54 |
55 # Set if default from path is used | 55 # Set if default from path is used |
56 DEFAULT_USED= | 56 DEFAULT_USED= |
57 | 57 |
58 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line | 58 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
59 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] | 59 if [ "$FLAGS_from" = "$DEFAULT_FROM" ] |
60 then | 60 then |
61 # Keep the directory name of the current image set (*.bin). | 61 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ |
62 IMG_DIR="$(ls -t1 ${IMAGES_DIR}/${FLAGS_board} 2>&-| head -1)" | 62 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" |
63 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" | |
64 DEFAULT_USED=1 | 63 DEFAULT_USED=1 |
65 fi | 64 fi |
66 | 65 |
67 # Die on any errors. | 66 # Die on any errors. |
68 set -e | 67 set -e |
69 | 68 |
70 if [ -z $DEFAULT_USED ] | 69 if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] |
71 then | 70 then |
72 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ | 71 echo "test_mod requires that the default from path be used." |
73 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ | 72 echo "If non default behavior is desired, run mod_image_for_test manually" |
74 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 73 echo "re-run archive build without test_mod" |
75 then | 74 exit 1 |
76 echo "test_mod requires that the default from path be used." | |
77 echo "If non default behavior is desired, run mod_image_for_test manually" | |
78 echo "re-run archive build without test_mod" | |
79 exit 1 | |
80 fi | |
81 fi | 75 fi |
82 | 76 |
83 if [ ! -d "$FLAGS_from" ] | 77 if [ ! -d "$FLAGS_from" ] |
84 then | 78 then |
85 echo "$FLAGS_from does not exist. Exiting..." | 79 echo "$FLAGS_from does not exist. Exiting..." |
86 exit 1 | 80 exit 1 |
87 fi | 81 fi |
88 | 82 |
89 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 83 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] |
90 then | 84 then |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 popd | 145 popd |
152 fi | 146 fi |
153 | 147 |
154 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 148 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] |
155 then | 149 then |
156 echo "Modifying image for factory test" | 150 echo "Modifying image for factory test" |
157 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ | 151 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ |
158 "--factory" | 152 "--factory" |
159 fi | 153 fi |
160 | 154 |
| 155 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
| 156 then |
| 157 echo "Modifying image for factory install" |
| 158 do_chroot_mod "${FLAGS_from}/chromiumos_factory_install_image.bin" \ |
| 159 "--factory_install" |
| 160 fi |
| 161 |
161 # Modify for recovery | 162 # Modify for recovery |
162 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 163 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] |
163 then | 164 then |
164 BUILDVER=$(ls -t1 $IMAGES_DIR/$FLAGS_board 2>&-| head -1) | 165 BUILDVER=$(ls -t1 $IMAGES_DIR/$FLAGS_board 2>&-| head -1) |
165 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER | 166 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER |
166 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ | 167 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ |
167 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin | 168 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin |
168 fi | 169 fi |
169 | 170 |
170 # Remove the developer build if test image is also built. | 171 # Remove the developer build if test image is also built. |
171 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then | 172 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then |
172 rm -f ${SRC_IMAGE} | 173 rm -f ${SRC_IMAGE} |
173 fi | 174 fi |
174 | 175 |
175 # Build differently sized shims. Currently only factory install shim is | |
176 # supported, TODO(tgao): Add developer shim. | |
177 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | |
178 then | |
179 echo "Building factory install shim." | |
180 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install | |
181 | |
182 # Get the install shim dir: It is the newest build. | |
183 # This is the output dir for the factory shim, the factory test and | |
184 # release umages will remain in IMG_DIR, defined previously. | |
185 SHIM_DIR="$(ls -t1 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" | |
186 fi | |
187 | |
188 # Zip the build | 176 # Zip the build |
189 echo "Compressing and archiving build..." | 177 echo "Compressing and archiving build..." |
190 cd "$FLAGS_from" | 178 cd "$FLAGS_from" |
191 MANIFEST=`ls | grep -v factory` | 179 MANIFEST=`ls | grep -v factory` |
192 zip -r "${ZIPFILE}" ${MANIFEST} | 180 zip -r "${ZIPFILE}" ${MANIFEST} |
193 | 181 |
194 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 182 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
195 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 183 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
196 then | 184 then |
197 # We need to have directory structure for factory package, as | 185 FACTORY_MANIFEST=`ls | grep factory` |
198 # signing and packaging utilities need unpack_partitions.sh. | 186 zip -r "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST} |
199 echo "Compressing factory software" | |
200 pushd .. | |
201 [ -n "${SHIM_DIR}" ] && ln -sf "${SHIM_DIR}" factory_shim | |
202 [ -n "${IMG_DIR}" ] && ln -sf "${IMG_DIR}" factory_test | |
203 FACTORY_MANIFEST=`find factory_shim factory_test -follow \ | |
204 -type f | grep -E "(factory_image|factory_install|partition)"` | |
205 zip "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST} | |
206 echo "Zipped" | |
207 popd | |
208 chmod 644 "${FACTORY_ZIPFILE}" | 187 chmod 644 "${FACTORY_ZIPFILE}" |
209 fi | 188 fi |
210 cd - | 189 cd - |
211 | 190 |
212 # Update LATEST file | 191 # Update LATEST file |
213 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" | 192 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" |
214 | 193 |
215 # Make sure files are readable | 194 # Make sure files are readable |
216 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" | 195 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
217 chmod 755 "$OUTDIR" | 196 chmod 755 "$OUTDIR" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if [ $FLAGS_keep_max -gt 0 ] | 254 if [ $FLAGS_keep_max -gt 0 ] |
276 then | 255 then |
277 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 256 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
278 cd "$FLAGS_to" | 257 cd "$FLAGS_to" |
279 # +2 because line numbers start at 1 and need to skip LATEST file | 258 # +2 because line numbers start at 1 and need to skip LATEST file |
280 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 259 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
281 cd - | 260 cd - |
282 fi | 261 fi |
283 | 262 |
284 echo "Done." | 263 echo "Done." |
OLD | NEW |