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 # --- BEGIN COMMON.SH BOILERPLATE --- | 9 # --- BEGIN COMMON.SH BOILERPLATE --- |
10 # Load common CrOS utilities. Inside the chroot this file is installed in | 10 # Load common CrOS utilities. Inside the chroot this file is installed in |
(...skipping 17 matching lines...) Expand all Loading... | |
28 # --- END COMMON.SH BOILERPLATE --- | 28 # --- END COMMON.SH BOILERPLATE --- |
29 | 29 |
30 # Script must be run outside the chroot | 30 # Script must be run outside the chroot |
31 assert_outside_chroot | 31 assert_outside_chroot |
32 | 32 |
33 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" | 33 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" |
34 # Default to the most recent image | 34 # Default to the most recent image |
35 DEFAULT_TO="${GCLIENT_ROOT}/archive" | 35 DEFAULT_TO="${GCLIENT_ROOT}/archive" |
36 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ | 36 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \ |
37 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" | 37 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)" |
38 # The set of environment assignment we need to pass to enter_chroots for this | |
39 # build. e.g. USE flags alter some of the commands' effect. | |
40 CHROOT_ENV="" | |
38 | 41 |
39 # Flags | 42 # Flags |
40 DEFINE_boolean archive_debug $FLAGS_TRUE \ | 43 DEFINE_boolean archive_debug $FLAGS_TRUE \ |
41 "Archive debug information for build" | 44 "Archive debug information for build" |
42 DEFINE_string board "$DEFAULT_BOARD" \ | 45 DEFINE_string board "$DEFAULT_BOARD" \ |
43 "The board to build packages for." | 46 "The board to build packages for." |
44 DEFINE_string build_number "" \ | 47 DEFINE_string build_number "" \ |
45 "The build-bot build number (when called by buildbot only)." "b" | 48 "The build-bot build number (when called by buildbot only)." "b" |
46 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ | 49 DEFINE_string chroot "$DEFAULT_CHROOT_DIR" \ |
47 "The chroot of the build to archive." | 50 "The chroot of the build to archive." |
(...skipping 16 matching lines...) Expand all Loading... | |
64 "Optional Whether to append build # and chrome os hash to GS uploads" | 67 "Optional Whether to append build # and chrome os hash to GS uploads" |
65 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" | 68 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" |
66 DEFINE_boolean official_build $FLAGS_FALSE \ | 69 DEFINE_boolean official_build $FLAGS_FALSE \ |
67 "Set CHROMEOS_OFFICIAL=1 for release builds." | 70 "Set CHROMEOS_OFFICIAL=1 for release builds." |
68 DEFINE_string test_tarball "" "Optional path to test tarball to archive" | 71 DEFINE_string test_tarball "" "Optional path to test tarball to archive" |
69 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" | 72 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" |
70 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." | 73 DEFINE_boolean prebuilt_upload $FLAGS_FALSE "Upload prebuilt binary packages." |
71 DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive." | 74 DEFINE_boolean remove_dev $FLAGS_TRUE "Remove the de image during archive." |
72 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" | 75 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" |
73 DEFINE_string zipname "image.zip" "Name of zip file to create." | 76 DEFINE_string zipname "image.zip" "Name of zip file to create." |
77 DEFINE_string useflags "" \ | |
78 "Space separated flags specifying types of pieces to assemble of modify." | |
davidjames
2011/04/25 20:58:19
Lots of other scripts accept USE flags, and they d
davidjames
2011/04/28 19:02:14
Could you clarify this comment? "Space separated f
Peter Mayo
2011/04/29 20:09:55
I'm OK with dropping space separated, and referenc
| |
74 | 79 |
75 # Parse command line | 80 # Parse command line |
76 FLAGS "$@" || exit 1 | 81 FLAGS "$@" || exit 1 |
77 eval set -- "${FLAGS_ARGV}" | 82 eval set -- "${FLAGS_ARGV}" |
78 | 83 |
79 # Set if default from path is used | 84 # Set if default from path is used |
80 DEFAULT_USED= | 85 DEFAULT_USED= |
81 | 86 |
82 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line | 87 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line |
83 if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then | 88 if [ "$FLAGS_from" = "$DEFAULT_FROM" ]; then |
84 # Keep the directory name of the current image set (*.bin). | 89 # Keep the directory name of the current image set (*.bin). |
85 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 90 IMG_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
86 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" | 91 FLAGS_from="${IMAGES_DIR}/${FLAGS_board}/${IMG_DIR}" |
87 DEFAULT_USED=1 | 92 DEFAULT_USED=1 |
88 fi | 93 fi |
89 | 94 |
90 # Die on any errors. | 95 # Die on any errors. |
91 set -e | 96 set -e |
92 | 97 |
98 if [ -n "${FLAGS_useflags}" ]; then | |
99 CHROOT_ENV="${CHROOT_ENV} USE='${FLAGS_useflags}'" | |
100 fi | |
101 | |
93 if [ -z "$DEFAULT_USED" ]; then | 102 if [ -z "$DEFAULT_USED" ]; then |
94 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ | 103 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] || \ |
95 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ | 104 [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ] || \ |
96 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] | 105 [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ] |
97 then | 106 then |
98 echo "test_mod requires that the default from path be used." | 107 echo "test_mod requires that the default from path be used." |
99 echo "If non default behavior is desired, run mod_image_for_test manually" | 108 echo "If non default behavior is desired, run mod_image_for_test manually" |
100 echo "re-run archive build without test_mod" | 109 echo "re-run archive build without test_mod" |
101 exit 1 | 110 exit 1 |
102 fi | 111 fi |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 FACTORY_ZIPFILE="${OUTDIR}/factory_${FLAGS_zipname}" | 146 FACTORY_ZIPFILE="${OUTDIR}/factory_${FLAGS_zipname}" |
138 echo "archive to dir: $OUTDIR" | 147 echo "archive to dir: $OUTDIR" |
139 echo "archive to file: $ZIPFILE" | 148 echo "archive to file: $ZIPFILE" |
140 | 149 |
141 rm -rf "$OUTDIR" | 150 rm -rf "$OUTDIR" |
142 mkdir -p "$OUTDIR" | 151 mkdir -p "$OUTDIR" |
143 | 152 |
144 # Modify image for test if flag set. | 153 # Modify image for test if flag set. |
145 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then | 154 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]; then |
146 echo "Modifying image for test" | 155 echo "Modifying image for test" |
147 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \ | 156 ./enter_chroot.sh $CHROOT_ENV -- ./mod_image_for_test.sh \ |
148 --noinplace --yes | 157 --board $FLAGS_board --noinplace --yes |
149 | 158 |
150 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" | 159 pushd "${FLAGS_chroot}/build/${FLAGS_board}/usr/local" |
151 echo "Archiving autotest build artifacts" | 160 echo "Archiving autotest build artifacts" |
152 tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest | 161 tar cjf "${FLAGS_from}/autotest.tar.bz2" --checkpoint=1000 autotest |
153 popd | 162 popd |
154 fi | 163 fi |
155 | 164 |
156 # Modify for recovery | 165 # Modify for recovery |
157 if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then | 166 if [ $FLAGS_official_build -eq $FLAGS_TRUE ]; then |
158 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 167 BUILDVER="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
159 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER | 168 CHROOT_IMAGE_DIR=/home/$USER/trunk/src/build/images/$FLAGS_board/$BUILDVER |
160 ./enter_chroot.sh -- ./mod_image_for_recovery.sh --board $FLAGS_board \ | 169 ./enter_chroot.sh $CHROOT_ENV -- ./mod_image_for_recovery.sh \ |
161 --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin | 170 --board $FLAGS_board --image $CHROOT_IMAGE_DIR/chromiumos_base_image.bin |
162 fi | 171 fi |
163 | 172 |
164 # Remove the developer build if test image is also built. | 173 # Remove the developer build if test image is also built. |
165 if [ $FLAGS_remove_dev -eq $FLAGS_TRUE ]; then | 174 if [ $FLAGS_remove_dev -eq $FLAGS_TRUE ]; then |
166 rm -f "${FLAGS_from}/${CHROMEOS_IMAGE_NAME}" | 175 rm -f "${FLAGS_from}/${CHROMEOS_IMAGE_NAME}" |
167 fi | 176 fi |
168 | 177 |
169 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then | 178 if [ $FLAGS_factory_test_mod -eq $FLAGS_TRUE ]; then |
170 echo "Generating image for factory test" | 179 echo "Generating image for factory test" |
171 # HACK: The build system can't currently handle more than one image size | 180 # HACK: The build system can't currently handle more than one image size |
172 # at a time. Therefore it's necessary to do another round of build after | 181 # at a time. Therefore it's necessary to do another round of build after |
173 # archiving the original build. This should be fixed in Chromite. | 182 # archiving the original build. This should be fixed in Chromite. |
174 | 183 |
175 # HACK: cbuild has a special case when running on chrome-bot that | 184 # HACK: cbuild has a special case when running on chrome-bot that |
176 # zeroes out the current revision, which makes calling build_image directly | 185 # zeroes out the current revision, which makes calling build_image directly |
177 # fail. You must explictly call replace and specify a unique name numerically | 186 # fail. You must explictly call replace and specify a unique name numerically |
178 # using build_attempt. | 187 # using build_attempt. |
179 ./enter_chroot.sh -- ./build_image --board $FLAGS_board \ | 188 ./enter_chroot.sh $CHROOT_ENV -- ./build_image --board $FLAGS_board \ |
180 --replace --noenable_rootfs_verification --build_attempt 4 | 189 --replace --noenable_rootfs_verification --build_attempt 4 |
181 | 190 |
182 ./enter_chroot.sh -- ./mod_image_for_test.sh --board $FLAGS_board \ | 191 ./enter_chroot.sh $CHROOT_ENV -- ./mod_image_for_test.sh \ |
183 --yes --noinplace --factory | 192 --board $FLAGS_board --yes --noinplace --factory |
184 | 193 |
185 # Get the factory test dir: It is the newest build. | 194 # Get the factory test dir: It is the newest build. |
186 # This is the output dir for the factory shim, the factory test and | 195 # This is the output dir for the factory shim, the factory test and |
187 # release images will remain in IMG_DIR, defined previously. | 196 # release images will remain in IMG_DIR, defined previously. |
188 FACTORY_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 197 FACTORY_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
189 | 198 |
190 echo "Factory image dir: ${FACTORY_DIR}" | 199 echo "Factory image dir: ${FACTORY_DIR}" |
191 fi | 200 fi |
192 | 201 |
193 # Build differently sized shims. Currently only factory install shim is | 202 # Build differently sized shims. Currently only factory install shim is |
194 # supported, TODO(tgao): Add developer shim. | 203 # supported, TODO(tgao): Add developer shim. |
195 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then | 204 if [ $FLAGS_factory_install_mod -eq $FLAGS_TRUE ]; then |
196 echo "Building factory install shim." | 205 echo "Building factory install shim." |
197 # HACK: The build system can't currently handle more than one image size | 206 # HACK: The build system can't currently handle more than one image size |
198 # at a time. Therefore it's necessary to do another round of build after | 207 # at a time. Therefore it's necessary to do another round of build after |
199 # archiving the original build. This should be fixed in Chromite. | 208 # archiving the original build. This should be fixed in Chromite. |
200 | 209 |
201 # HACK: cbuild has a special case when running on chrome-bot that | 210 # HACK: cbuild has a special case when running on chrome-bot that |
202 # zeroes out the current revision, which makes calling build_image directly | 211 # zeroes out the current revision, which makes calling build_image directly |
203 # fail. You must explictly call replace and specify a unique name numerically | 212 # fail. You must explictly call replace and specify a unique name numerically |
204 # using build_attempt. | 213 # using build_attempt. |
205 ./enter_chroot.sh -- ./build_image --board $FLAGS_board --factory_install \ | 214 ./enter_chroot.sh $CHROOT_ENV -- ./build_image --board $FLAGS_board \ |
206 --replace --build_attempt 7 | 215 --factory_install --replace --build_attempt 7 |
207 | 216 |
208 # Get the install shim dir: It is the newest build. | 217 # Get the install shim dir: It is the newest build. |
209 # This is the output dir for the factory shim, the factory test and | 218 # This is the output dir for the factory shim, the factory test and |
210 # release images will remain in IMG_DIR, defined previously. | 219 # release images will remain in IMG_DIR, defined previously. |
211 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" | 220 SHIM_DIR="$(readlink ${IMAGES_DIR}/${FLAGS_board}/latest)" |
212 | 221 |
213 echo "Factory install shim dir: ${SHIM_DIR}" | 222 echo "Factory install shim dir: ${SHIM_DIR}" |
214 fi | 223 fi |
215 | 224 |
216 # Zip the build | 225 # Zip the build |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 # Purge old builds if necessary | 360 # Purge old builds if necessary |
352 if [ $FLAGS_keep_max -gt 0 ]; then | 361 if [ $FLAGS_keep_max -gt 0 ]; then |
353 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." | 362 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." |
354 cd "$FLAGS_to" | 363 cd "$FLAGS_to" |
355 # +2 because line numbers start at 1 and need to skip LATEST file | 364 # +2 because line numbers start at 1 and need to skip LATEST file |
356 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` | 365 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` |
357 cd - | 366 cd - |
358 fi | 367 fi |
359 | 368 |
360 echo "Done." | 369 echo "Done." |
OLD | NEW |