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 | if [ $A -eq 1 ] && \ |
---|
27 | [ "${DA_SHOOT_SELF_IN_FOOT:-x}" != "yesplease" ]; then |
---|
28 | for i in "$@"; do |
---|
29 | if echo "$i" | grep -q '\.dsc$' && \ |
---|
30 | grep -Fqx 'Architecture: any' "$i"; then |
---|
31 | echo "ERROR: Won't build an 'Architecture: any' package with -A" >&2 |
---|
32 | exit 1 |
---|
33 | fi |
---|
34 | done |
---|
35 | fi |
---|
36 | exit 0 |
---|
37 | |
---|
38 | # Display a horizontal rule on stderr. |
---|
39 | hr () { |
---|
40 | for i in $(seq 60); do echo -n '═' >&2; done; echo >&2 |
---|
41 | } |
---|
42 | |
---|
43 | # Run $prog with the provided arguments, with display annotations and |
---|
44 | # success/failure tracking. |
---|
45 | t () { |
---|
46 | while true; do |
---|
47 | tput bold >&2 |
---|
48 | hr |
---|
49 | echo "Running: $prog $@" >&2 |
---|
50 | tput sgr0 >&2 |
---|
51 | if $prog "$@"; then |
---|
52 | succ=$succ\ $1 |
---|
53 | break |
---|
54 | else |
---|
55 | tput bold >&2 |
---|
56 | tput setf 4; echo -n "Failed: " >&2 |
---|
57 | tput sgr0 >&2 |
---|
58 | echo -n "$prog $@ [a/R/f] " >&2 |
---|
59 | read -r x || exit $? |
---|
60 | if [ "$x" = "a" ]; then exit 1; fi |
---|
61 | if [ "$x" = "f" ]; then fail=$fail\ $1 break; fi |
---|
62 | fi |
---|
63 | done |
---|
64 | echo >&2 |
---|
65 | } |
---|
66 | |
---|
67 | for code in $DEBIAN_CODES; do |
---|
68 | t "$code"-amd64 -A "$@" |
---|
69 | [ $A -eq 1 ] || t "$code"-i386 "$@" |
---|
70 | done |
---|
71 | |
---|
72 | tput bold >&2 |
---|
73 | hr |
---|
74 | echo "Done: $prog \$dist $@" >&2 |
---|
75 | tput setf 2 >&2; echo -n "Succeeded:" >&2 |
---|
76 | tput sgr0 >&2; echo "$succ" >&2 |
---|
77 | if [ -n "$fail" ]; then |
---|
78 | tput bold >&2; tput setf 4 >&2; echo -n "Failed:" >&2 |
---|
79 | tput sgr0 >&2; echo "$fail" >&2 |
---|
80 | exit 1 |
---|
81 | fi |
---|
82 | exit 0 |
---|