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