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