source: trunk/debathena/scripts/da @ 25941

Revision 25941, 2.2 KB checked in by jdreed, 11 years ago (diff)
Support overriding of DEBIAN_CODES
  • Property svn:executable set to *
Line 
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: ${DA_SCRIPTS_DIR="$(dirname "$0")"}
19. "$DA_SCRIPTS_DIR"/debian-versions.sh
20
21if [ -n "$DEBIAN_CODES_OVERRIDE" ]; then
22    echo "Will override DEBIAN_CODES with: $DEBIAN_CODES_OVERRIDE"
23    echo -n "Continue? [y/N]"
24    read a
25    [ "$a" = "y" ] || exit 0
26    DEBIAN_CODES="$DEBIAN_CODES_OVERRIDE"
27fi
28
29A=0
30if [ "$1" = -A ]; then A=1; shift; fi
31prog="$1"; shift
32succ=
33fail=
34
35if [ $A -eq 1 ] && \
36    [ "${DA_SHOOT_SELF_IN_FOOT:-x}" != "yesplease" ]; then
37    for i in "$@"; do
38        if echo "$i" | grep -q '\.dsc$' && \
39            grep -Fqx 'Architecture: any' "$i"; then
40            echo "ERROR: Won't build an 'Architecture: any' package with -A" >&2
41            exit 1
42        fi
43    done
44fi
45
46
47# Display a horizontal rule on stderr.
48hr () {
49    for i in $(seq 60); do echo -n '═' >&2; done; echo >&2
50}
51
52# Run $prog with the provided arguments, with display annotations and
53# success/failure tracking.
54t () {
55    while true; do
56        tput bold >&2
57        hr
58        echo "Running: $prog $@" >&2
59        tput sgr0 >&2
60        if $prog "$@"; then
61            succ=$succ\ $1
62            break
63        else
64            tput bold >&2
65            tput setf 4; echo -n "Failed: " >&2
66            tput sgr0 >&2
67            echo -n "$prog $@ [a/R/f] " >&2
68            read -r x || exit $?
69            if [ "$x" = "a" ]; then exit 1; fi
70            if [ "$x" = "f" ]; then fail=$fail\ $1 break; fi
71        fi
72    done
73    echo >&2
74}
75
76for code in $DEBIAN_CODES; do
77    t "$code"-amd64 -A "$@"
78    [ $A -eq 1 ] || t "$code"-i386 "$@"
79done
80
81tput bold >&2
82hr
83echo "Done: $prog \$dist $@" >&2
84tput setf 2 >&2; echo -n "Succeeded:" >&2
85tput sgr0 >&2; echo "$succ" >&2
86if [ -n "$fail" ]; then
87    tput bold >&2; tput setf 4 >&2; echo -n "Failed:" >&2
88    tput sgr0 >&2; echo "$fail" >&2
89    exit 1
90fi
91exit 0
Note: See TracBrowser for help on using the repository browser.