Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/scripts/archive_build.sh

Issue 651079: Rework DEFAULT_FROM due to dependence on FLAGS_board. (Closed)
Patch Set: fixarc Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
11 . "$(dirname "$0")/common.sh" 11 . "$(dirname "$0")/common.sh"
12 12
13 # Script must be run outside the chroot 13 # Script must be run outside the chroot
14 assert_outside_chroot 14 assert_outside_chroot
15 15
16 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" 16 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
17 # Default to the most recent image 17 # Default to the most recent image
18 DEFAULT_TO="${GCLIENT_ROOT}/archive" 18 DEFAULT_TO="${GCLIENT_ROOT}/archive"
19 DEFAULT_FROM="${IMAGES_DIR}/$DEFAULT_BOARD/$(ls -t1 \
20 $IMAGES_DIR/$DEFAULT_BOARD 2>&-| head -1)"
19 21
20 # Flags 22 # Flags
21 DEFINE_string board "$DEFAULT_BOARD" \ 23 DEFINE_string board "$DEFAULT_BOARD" \
22 "The board to build packages for." 24 "The board to build packages for."
23 DEFAULT_FROM="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 $IMAGES_DIR/$FLAGS_board | hea d -1)"
24 DEFINE_string from "$DEFAULT_FROM" \ 25 DEFINE_string from "$DEFAULT_FROM" \
25 "Directory to archive" 26 "Directory to archive"
26 DEFINE_string to "$DEFAULT_TO" "Directory of build archive" 27 DEFINE_string to "$DEFAULT_TO" "Directory of build archive"
27 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)" 28 DEFINE_integer keep_max 0 "Maximum builds to keep in archive (0=all)"
28 DEFINE_string zipname "image.zip" "Name of zip file to create." 29 DEFINE_string zipname "image.zip" "Name of zip file to create."
29 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release builds." 30 DEFINE_boolean official_build $FLAGS_FALSE "Set CHROMEOS_OFFICIAL=1 for release builds."
30 DEFINE_string build_number "" \ 31 DEFINE_string build_number "" \
31 "The build-bot build number (when called by buildbot only)." "b" 32 "The build-bot build number (when called by buildbot only)." "b"
32 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes" 33 DEFINE_boolean test_mod $FLAGS_TRUE "Modify image for testing purposes"
33 34
34 # Parse command line 35 # Parse command line
35 FLAGS "$@" || exit 1 36 FLAGS "$@" || exit 1
36 eval set -- "${FLAGS_ARGV}" 37 eval set -- "${FLAGS_ARGV}"
37 38
39 # Reset "default" FLAGS_from based on passed-in board if not set on cmd-line
40 if [ "$FLAGS_from" = "$DEFAULT_FROM" ]
41 then
42 FLAGS_from="${IMAGES_DIR}/$FLAGS_board/$(ls -t1 \
43 $IMAGES_DIR/$FLAGS_board 2>&-| head -1)"
44 fi
45
38 # Die on any errors. 46 # Die on any errors.
39 set -e 47 set -e
40 48
49 if [ ! -d "$FLAGS_from" ]
50 then
51 echo "$FLAGS_from does not exist. Exiting..."
52 exit 1
53 fi
54
41 if [ $FLAGS_official_build -eq $FLAGS_TRUE ] 55 if [ $FLAGS_official_build -eq $FLAGS_TRUE ]
42 then 56 then
43 CHROMEOS_OFFICIAL=1 57 CHROMEOS_OFFICIAL=1
44 fi 58 fi
45 59
46 # Get version information 60 # Get version information
47 . "${SCRIPTS_DIR}/chromeos_version.sh" 61 . "${SCRIPTS_DIR}/chromeos_version.sh"
48 62
49 # Get git hash 63 # Get git hash
50 # Use git:8 chars of sha1 64 # Use git:8 chars of sha1
(...skipping 19 matching lines...) Expand all
70 echo "archive to dir: $OUTDIR" 84 echo "archive to dir: $OUTDIR"
71 echo "archive to file: $ZIPFILE" 85 echo "archive to file: $ZIPFILE"
72 86
73 rm -rf "$OUTDIR" 87 rm -rf "$OUTDIR"
74 mkdir -p "$OUTDIR" 88 mkdir -p "$OUTDIR"
75 89
76 # Modify image for test if flag set. 90 # Modify image for test if flag set.
77 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ] 91 if [ $FLAGS_test_mod -eq $FLAGS_TRUE ]
78 then 92 then
79 echo "Modifying image for test" 93 echo "Modifying image for test"
80 cp "${DEFAULT_FROM}/rootfs.image" "${DEFAULT_FROM}/rootfs_test.image" 94 cp "${FLAGS_from}/rootfs.image" "${FLAGS_from}/rootfs_test.image"
81 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \ 95 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \
82 "${DEFAULT_FROM}/rootfs_test.image" 96 "${FLAGS_from}/rootfs_test.image"
83 fi 97 fi
84 98
85 # Zip the build 99 # Zip the build
86 echo "Compressing and archiving build..." 100 echo "Compressing and archiving build..."
87 cd "$DEFAULT_FROM" 101 cd "$FLAGS_from"
88 zip -r "$ZIPFILE" * 102 zip -r "$ZIPFILE" *
89 cd - 103 cd -
90 104
91 # Update LATEST file 105 # Update LATEST file
92 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST" 106 echo "$LAST_CHANGE" > "${FLAGS_to}/LATEST"
93 107
94 # Make sure files are readable 108 # Make sure files are readable
95 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST" 109 chmod 644 "$ZIPFILE" "${FLAGS_to}/LATEST"
96 chmod 755 "$OUTDIR" 110 chmod 755 "$OUTDIR"
97 111
98 # Purge old builds if necessary 112 # Purge old builds if necessary
99 if [ $FLAGS_keep_max -gt 0 ] 113 if [ $FLAGS_keep_max -gt 0 ]
100 then 114 then
101 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..." 115 echo "Deleting old builds (all but the newest ${FLAGS_keep_max})..."
102 cd "$FLAGS_to" 116 cd "$FLAGS_to"
103 # +2 because line numbers start at 1 and need to skip LATEST file 117 # +2 because line numbers start at 1 and need to skip LATEST file
104 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))` 118 rm -rf `ls -t1 | tail --lines=+$(($FLAGS_keep_max + 2))`
105 cd - 119 cd -
106 fi 120 fi
107 121
108 echo "Done." 122 echo "Done."
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698