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 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \ | 61 # Keep the directory name of the current image set (*.bin). |
62 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)" | 62 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
| 63 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" |
63 DEFAULT_USED=1 | 64 DEFAULT_USED=1 |
64 fi | 65 fi |
65 | 66 |
66 # Die on any errors. | 67 # Die on any errors. |
67 set -e | 68 set -e |
68 | 69 |
69 if [ -z $DEFAULT_USED ] && [ $FLAGS_test_mod -eq $FLAGS_TRUE ] | 70 if [ -z $DEFAULT_USED ] |
70 then | 71 then |
71 echo "test_mod requires that the default from path be used." | 72 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ |
72 echo "If non default behavior is desired, run mod_image_for_test manually" | 73 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ |
73 echo "re-run archive build without test_mod" | 74 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] |
74 exit 1 | 75 then |
| 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 |
75 fi | 81 fi |
76 | 82 |
77 if [ ! -d "$FLAGS_from" ] | 83 if [ ! -d "$FLAGS_from" ] |
78 then | 84 then |
79 echo "$FLAGS_from does not exist. Exiting..." | 85 echo "$FLAGS_from does not exist. Exiting..." |
80 exit 1 | 86 exit 1 |
81 fi | 87 fi |
82 | 88 |
83 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 89 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] |
84 then | 90 then |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 popd | 151 popd |
146 fi | 152 fi |
147 | 153 |
148 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 154 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] |
149 then | 155 then |
150 echo "Modifying image for factory test" | 156 echo "Modifying image for factory test" |
151 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ | 157 do_chroot_mod "${FLAGS_from}/chromiumos_factory_image.bin" \ |
152 "--factory" | 158 "--factory" |
153 fi | 159 fi |
154 | 160 |
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 | |
162 # Modify for recovery | 161 # Modify for recovery |
163 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] | 162 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] |
164 then | 163 then |
165 BUILDVER=$(ls -t1 $IMAGES_DIR/$FLAGS_board 2>&-| head -1) | 164 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
166 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER | 165 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER |
167 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ | 166 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ |
168 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin | 167 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin |
169 fi | 168 fi |
170 | 169 |
171 # Remove the developer build if test image is also built. | 170 # Remove the developer build if test image is also built. |
172 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then | 171 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] ; then |
173 rm -f ${SRC_IMAGE} | 172 rm -f ${SRC_IMAGE} |
174 fi | 173 fi |
175 | 174 |
| 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 # HACK: The build system can't currently handle more than one image size |
| 181 # at a time. Therefor eit's necessary to do another round of build after |
| 182 # archiving the original build. This should be fixed in Chromite. |
| 183 |
| 184 # HACK: cbuild has a special case when running on chrome-bot that |
| 185 # zeroes out the current revision, which makes calling build_image directly |
| 186 # fail. You must explictly call replace and specify a unique name numerically |
| 187 # using build_attempt. |
| 188 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install \ |
| 189 --replace --build_attempt 7 |
| 190 |
| 191 # Get the install shim dir: It is the newest build. |
| 192 # This is the output dir for the factory shim, the factory test and |
| 193 # release images will remain in IMG_DIR, defined previously. |
| 194 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
| 195 |
| 196 echo "Factory image dir: ${IMG_DIR}" |
| 197 echo "Factory install shim dir: ${SHIM_DIR}" |
| 198 fi |
| 199 |
176 # Zip the build | 200 # Zip the build |
177 echo "Compressing and archiving build..." | 201 echo "Compressing and archiving build..." |
178 cd "$FLAGS_from" | 202 cd "$FLAGS_from" |
179 MANIFEST=`ls | grep -v factory` | 203 MANIFEST=`ls | grep -v factory` |
180 zip -r "${ZIPFILE}" ${MANIFEST} | 204 zip -r "${ZIPFILE}" ${MANIFEST} |
181 | 205 |
182 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 206 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
183 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 207 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
184 then | 208 then |
185 FACTORY_MANIFEST=`ls | grep factory` | 209 # We need to have directory structure for factory package, as |
186 zip -r "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST} | 210 # signing and packaging utilities need unpack_partitions.sh. |
| 211 echo "Compressing factory software" |
| 212 pushd .. |
| 213 [ -n "${SHIM_DIR}" ] && rm -f factory_shim && ln -s "${SHIM_DIR}" factory_shim |
| 214 [ -n "${IMG_DIR}" ] && rm -f factory_test && ln -s "${IMG_DIR}" factory_test |
| 215 |
| 216 # Restore "latest" status to the original image. |
| 217 # The "latest" symlink and latest timestamp are used extensively |
| 218 # throughout the build scripts rather than explicitly specifying an image. |
| 219 touch "${IMG_DIR}" |
| 220 [ -n "${IMG_DIR}" ] && rm -f latest && ln -s "${IMG_DIR}" latest |
| 221 FACTORY_MANIFEST=`find factory_shim factory_test -follow \ |
| 222 -type f | grep -E "(factory_image|factory_install|partition)"` |
| 223 zip "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST} |
| 224 echo "Zipped" |
| 225 popd |
187 chmod 644 "${FACTORY_ZIPFILE}" | 226 chmod 644 "${FACTORY_ZIPFILE}" |
188 fi | 227 fi |
189 cd - | 228 cd - |
190 | 229 |
191 # Update LATEST file | 230 # Update LATEST file |
192 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" | 231 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" |
193 | 232 |
194 # Make sure files are readable | 233 # Make sure files are readable |
195 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" | 234 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
196 chmod 755 "$OUTDIR" | 235 chmod 755 "$OUTDIR" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 if [ $FLAGS_keep_max -gt 0 ] | 293 if [ $FLAGS_keep_max -gt 0 ] |
255 then | 294 then |
256 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 295 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
257 cd "$FLAGS_to" | 296 cd "$FLAGS_to" |
258 # +2 because line numbers start at 1 and need to skip LATEST file | 297 # +2 because line numbers start at 1 and need to skip LATEST file |
259 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 298 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
260 cd - | 299 cd - |
261 fi | 300 fi |
262 | 301 |
263 echo "Done." | 302 echo "Done." |
OLD | NEW |