[22687] | 1 | #!/bin/sh |
---|
[22688] | 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 | |
---|
[22748] | 18 | . $(dirname "$0")/debian-versions.sh |
---|
[22739] | 19 | |
---|
[22687] | 20 | A=0 |
---|
| 21 | if [ "$1" = -A ]; then A=1; shift; fi |
---|
| 22 | prog="$1"; shift |
---|
| 23 | succ= |
---|
| 24 | fail= |
---|
[22688] | 25 | |
---|
| 26 | # Display a horizontal rule on stderr. |
---|
[22687] | 27 | hr () { |
---|
| 28 | for i in $(seq 60); do echo -n '═' >&2; done; echo >&2 |
---|
| 29 | } |
---|
[22688] | 30 | |
---|
| 31 | # Run $prog with the provided arguments, with display annotations and |
---|
| 32 | # success/failure tracking. |
---|
[22687] | 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 | } |
---|
[22688] | 54 | |
---|
[22739] | 55 | for code in $DEBIAN_CODES; do |
---|
| 56 | t "$code"-amd64 -A "$@" |
---|
| 57 | [ $A -eq 1 ] || t "$code"-i386 "$@" |
---|
| 58 | done |
---|
[22688] | 59 | |
---|
[22687] | 60 | tput bold >&2 |
---|
| 61 | hr |
---|
| 62 | echo "Done: $prog \$dist $@" >&2 |
---|
| 63 | tput setf 2 >&2; echo -n "Succeeded:" >&2 |
---|
| 64 | tput sgr0 >&2; echo "$succ" >&2 |
---|
| 65 | if [ -n "$fail" ]; then |
---|
| 66 | tput bold >&2; tput setf 4 >&2; echo -n "Failed:" >&2 |
---|
| 67 | tput sgr0 >&2; echo "$fail" >&2 |
---|
| 68 | exit 1 |
---|
| 69 | fi |
---|
| 70 | exit 0 |
---|