1 | #!/bin/sh |
---|
2 | |
---|
3 | # Usage: da [-A] PROGRAM ARGUMENTS |
---|
4 | |
---|
5 | # Runs PROGRAM over each of the build schroot names, like so: |
---|
6 | # |
---|
7 | # PROGRAM SCHROOTNAME ARGUMENTS |
---|
8 | # |
---|
9 | # On one architecture of each Debian/Ubuntu version, passes the -A |
---|
10 | # option before ARGUMENTS. If -A is passed to this script, the |
---|
11 | # program only gets run over one schroot per Debian/Ubuntu version. |
---|
12 | # At the end of the run, the script will display which schroots the |
---|
13 | # command succeeded and failed for. |
---|
14 | |
---|
15 | # Typically this script is used to build Debathena packages, in which |
---|
16 | # case PROGRAM is sbuildhack and ARGUMENTS is a path to a .dsc file. |
---|
17 | |
---|
18 | . $(dirname "$0")/debian-versions.sh |
---|
19 | |
---|
20 | A=0 |
---|
21 | if [ "$1" = -A ]; then A=1; shift; fi |
---|
22 | prog="$1"; shift |
---|
23 | succ= |
---|
24 | fail= |
---|
25 | |
---|
26 | # Display a horizontal rule on stderr. |
---|
27 | hr () { |
---|
28 | for i in $(seq 60); do echo -n '═' >&2; done; echo >&2 |
---|
29 | } |
---|
30 | |
---|
31 | # Run $prog with the provided arguments, with display annotations and |
---|
32 | # success/failure tracking. |
---|
33 | t () { |
---|
34 | while true; do |
---|
35 | tput bold >&2 |
---|
36 | hr |
---|
37 | echo "Running: $prog $@" >&2 |
---|
38 | tput sgr0 >&2 |
---|
39 | if $prog "$@"; then |
---|
40 | succ=$succ\ $1 |
---|
41 | break |
---|
42 | else |
---|
43 | tput bold >&2 |
---|
44 | tput setf 4; echo -n "Failed: " >&2 |
---|
45 | tput sgr0 >&2 |
---|
46 | echo -n "$prog $@ [a/R/f] " >&2 |
---|
47 | read -r x || exit $? |
---|
48 | if [ "$x" = "a" ]; then exit 1; fi |
---|
49 | if [ "$x" = "f" ]; then fail=$fail\ $1 break; fi |
---|
50 | fi |
---|
51 | done |
---|
52 | echo >&2 |
---|
53 | } |
---|
54 | |
---|
55 | for code in $DEBIAN_CODES; do |
---|
56 | if [ "$code" = "sarge" ]; then |
---|
57 | t sarge-i386 -A "$@" |
---|
58 | continue |
---|
59 | fi |
---|
60 | t "$code"-amd64 -A "$@" |
---|
61 | [ $A -eq 1 ] || t "$code"-i386 "$@" |
---|
62 | done |
---|
63 | |
---|
64 | tput bold >&2 |
---|
65 | hr |
---|
66 | echo "Done: $prog \$dist $@" >&2 |
---|
67 | tput setf 2 >&2; echo -n "Succeeded:" >&2 |
---|
68 | tput sgr0 >&2; echo "$succ" >&2 |
---|
69 | if [ -n "$fail" ]; then |
---|
70 | tput bold >&2; tput setf 4 >&2; echo -n "Failed:" >&2 |
---|
71 | tput sgr0 >&2; echo "$fail" >&2 |
---|
72 | exit 1 |
---|
73 | fi |
---|
74 | exit 0 |
---|