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 21 matching lines...) Expand all Loading... |
32 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." | 32 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release
builds." |
33 DEFINE_string build_number "" \ | 33 DEFINE_string build_number "" \ |
34 "The build-bot build number (when called by buildbot only)." "b" | 34 "The build-bot build number (when called by buildbot only)." "b" |
35 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" | 35 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
36 DEFINE_boolean factory_test_mod $FLAGS_FALSE \ | 36 DEFINE_boolean factory_test_mod $FLAGS_FALSE \ |
37 "Modify image for factory testing purposes" | 37 "Modify image for factory testing purposes" |
38 DEFINE_boolean factory_install_mod $FLAGS_FALSE \ | 38 DEFINE_boolean factory_install_mod $FLAGS_FALSE \ |
39 "Modify image for factory install purposes" | 39 "Modify image for factory install purposes" |
40 DEFINE_string gsutil "gsutil" \ | 40 DEFINE_string gsutil "gsutil" \ |
41 "Location of gsutil" | 41 "Location of gsutil" |
| 42 DEFINE_string gsd_gen_index "" \ |
| 43 "Location of gsd_generate_index.py" |
| 44 DEFINE_string acl "private" \ |
| 45 "ACL to set on GSD archives" |
42 DEFINE_string gsutil_archive "" \ | 46 DEFINE_string gsutil_archive "" \ |
43 "Optional datastore archive location" | 47 "Optional datastore archive location" |
44 | 48 |
45 # Parse command line | 49 # Parse command line |
46 FLAGS "$@" || exit 1 | 50 FLAGS "$@" || exit 1 |
47 eval set -- "${FLAGS_ARGV}" | 51 eval set -- "${FLAGS_ARGV}" |
48 | 52 |
49 # Set if default from path is used | 53 # Set if default from path is used |
50 DEFAULT_USED= | 54 DEFAULT_USED= |
51 | 55 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 fi | 177 fi |
174 cd - | 178 cd - |
175 | 179 |
176 # Update LATEST file | 180 # Update LATEST file |
177 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" | 181 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" |
178 | 182 |
179 # Make sure files are readable | 183 # Make sure files are readable |
180 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" | 184 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" |
181 chmod 755 "$OUTDIR" | 185 chmod 755 "$OUTDIR" |
182 | 186 |
| 187 |
| 188 GSUTIL_CP="${FLAGS_gsutil} cp -a ${FLAGS_acl}" |
| 189 GSUTIL_GENERATE_INDEX="${FLAGS_gsd_gen_index} -a ${FLAGS_acl}" |
| 190 |
| 191 function gsutil_archive() { |
| 192 IN_PATH="$1" |
| 193 OUT_PATH="$2" |
| 194 if [ $FLAGS_gsutil_archive != "" ] |
| 195 then |
| 196 FULL_OUT_PATH="${FLAGS_gsutil_archive}/${OUT_PATH}" |
| 197 echo "Using gsutil to archive to ${OUT_PATH}..." |
| 198 ${GSUTIL_CP} ${IN_PATH} ${FULL_OUT_PATH} |
| 199 if [ $FLAGS_gsd_gen_index != "" ] |
| 200 then |
| 201 echo "Updating indexes..." |
| 202 ${GSD_GENERATE_INDEX} -p ${FULL_OUT_PATH} ${FLAGS_gsutil_archive} |
| 203 fi |
| 204 fi |
| 205 } |
| 206 |
183 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] | 207 if [ $FLAGS_test_mod -eq $FLAGS_TRUE -a $FLAGS_official_build -eq $FLAGS_TRUE ] |
184 then | 208 then |
185 echo "Creating hwqual archive" | 209 echo "Creating hwqual archive" |
186 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" | 210 HWQUAL_NAME="chromeos-hwqual-${FLAGS_board}-${CHROMEOS_VERSION_STRING}" |
187 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ | 211 "${SCRIPTS_DIR}/archive_hwqual" --from "${OUTDIR}" \ |
188 --output_tag "${HWQUAL_NAME}" | 212 --output_tag "${HWQUAL_NAME}" |
189 # Optionally archive with gsutil hwqual. | 213 gsutil_archive "${OUTDIR}/${HWQUAL_NAME}.tar.bz2" \ |
190 if [ $FLAGS_gsutil_archive != "" ] | 214 "${LAST_CHANGE}/${HWQUAL_NAME}.tar.bz2" |
191 then | |
192 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" | |
193 GS_HWQUAL_IN="${OUTDIR}/${HWQUAL_NAME}.tar.bz2" | |
194 GS_HWQUAL_OUT="${GS_OUTDIR}/${HWQUAL_NAME}.tar.bz2" | |
195 echo "Using gsutil to archive to ${GS_HWQUAL_OUT}..." | |
196 ${FLAGS_gsutil} cp ${GS_HWQUAL_IN} ${GS_HWQUAL_OUT} | |
197 fi | |
198 fi | 215 fi |
199 | 216 |
200 # Optionally archive to Google Storage for Developers. | 217 gsutil_archive "${ZIPFILE}" "${LAST_CHANGE}/${FLAGS_zipname}" |
201 if [ $FLAGS_gsutil_archive != "" ] | 218 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ |
| 219 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] |
202 then | 220 then |
203 GS_OUTDIR="${FLAGS_gsutil_archive}/${LAST_CHANGE}" | 221 gsutil_archive "${FACTORY_ZIPFILE}" \ |
204 GS_ZIPFILE="${GS_OUTDIR}/${FLAGS_zipname}" | 222 "${LAST_CHANGE}/factory_${FLAGS_zipname}" |
205 GS_FACTORY_ZIPFILE="${GS_OUTDIR}/factory_${FLAGS_zipname}" | |
206 GS_LATEST="${FLAGS_gsutil_archive}/LATEST" | |
207 echo "Using gsutil to archive to ${GS_ZIPFILE}..." | |
208 ${FLAGS_gsutil} cp ${ZIPFILE} ${GS_ZIPFILE} | |
209 | |
210 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] || \ | |
211 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] | |
212 then | |
213 echo "Using gsutil to archive to ${GS_FACTORY_ZIPFILE}..." | |
214 ${FLAGS_gsutil} cp ${FACTORY_ZIPFILE} ${GS_FACTORY_ZIPFILE} | |
215 fi | |
216 | |
217 echo "Updating latest ${GS_LATEST}..." | |
218 ${FLAGS_gsutil} cp ${FLAGS_to}/LATEST ${GS_LATEST} | |
219 fi | 223 fi |
| 224 gsutil_archive "${FLAGS_to}/LATEST" "LATEST" |
220 | 225 |
221 # Purge old builds if necessary | 226 # Purge old builds if necessary |
222 if [ $FLAGS_keep_max -gt 0 ] | 227 if [ $FLAGS_keep_max -gt 0 ] |
223 then | 228 then |
224 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 229 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
225 cd "$FLAGS_to" | 230 cd "$FLAGS_to" |
226 # +2 because line numbers start at 1 and need to skip LATEST file | 231 # +2 because line numbers start at 1 and need to skip LATEST file |
227 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 232 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
228 cd - | 233 cd - |
229 fi | 234 fi |
230 | 235 |
231 echo "Done." | 236 echo "Done." |
OLD | NEW |