| 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="$(ls -t1 ${IMAGES_DIR}/${FLAGS_board} 2>&-| head -1)" |
| 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=$(ls -t1 $IMAGES_DIR/$FLAGS_board 2>&-| head -1) |
| 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 ./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 |
| 176 # Zip the build | 188 # Zip the build |
| 177 echo "Compressing and archiving build..." | 189 echo "Compressing and archiving build..." |
| 178 cd "$FLAGS_from" | 190 cd "$FLAGS_from" |
| 179 MANIFEST=`ls | grep -v factory` | 191 MANIFEST=`ls | grep -v factory` |
| 180 zip -r "${ZIPFILE}" ${MANIFEST} | 192 zip -r "${ZIPFILE}" ${MANIFEST} |
| 181 | 193 |
| 182 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | 194 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
| 183 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | 195 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
| 184 then | 196 then |
| 185 FACTORY_MANIFEST=`ls | grep factory` | 197 # We need to have directory structure for factory package, as |
| 186 zip -r "${FACTORY_ZIPFILE}" ${FACTORY_MANIFEST} | 198 # signing and packaging utilities need unpack_partitions.sh. |
| 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 |
| 187 chmod 644 "${FACTORY_ZIPFILE}" | 208 chmod 644 "${FACTORY_ZIPFILE}" |
| 188 fi | 209 fi |
| 189 cd - | 210 cd - |
| 190 | 211 |
| 191 # Update LATEST file | 212 # Update LATEST file |
| 192 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" | 213 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" |
| 193 | 214 |
| 194 # Make sure files are readable | 215 # Make sure files are readable |
| 195 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" | 216 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
| 196 chmod 755 "$OUTDIR" | 217 chmod 755 "$OUTDIR" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 if [ $FLAGS_keep_max -gt 0 ] | 275 if [ $FLAGS_keep_max -gt 0 ] |
| 255 then | 276 then |
| 256 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 277 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
| 257 cd "$FLAGS_to" | 278 cd "$FLAGS_to" |
| 258 # +2 because line numbers start at 1 and need to skip LATEST file | 279 # +2 because line numbers start at 1 and need to skip LATEST file |
| 259 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 280 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
| 260 cd - | 281 cd - |
| 261 fi | 282 fi |
| 262 | 283 |
| 263 echo "Done." | 284 echo "Done." |
| OLD | NEW |