-
Notifications
You must be signed in to change notification settings - Fork 89
/
aur-srcver
executable file
·105 lines (85 loc) · 2.18 KB
/
aur-srcver
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# aur-srcver - update and print package revisions
readonly argv0=srcver
readonly PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
readonly AUR_COLOR=${AUR_COLOR-auto}
srcver_pkgbuild_info() {
env -C "$1" -i bash -c '
PATH= source PKGBUILD
if [[ -v epoch ]]; then
fullver=$epoch:$pkgver-$pkgrel
else
fullver=$pkgver-$pkgrel
fi
printf %s\\t%s\\n "${pkgbase:-$pkgname}" "$fullver"
'
}
trap_exit() {
if ! [[ -o xtrace ]]; then
rm -rf "$tmp"
fi
}
usage() {
plain 'usage: %s [--noprepare] <pkgbase> [<pkgbase> ...]' "$argv0" >&2
exit 1
}
source /usr/share/makepkg/util/message.sh
source /usr/share/makepkg/util/parseopts.sh
if [[ ( -t 1 && -t 2 && ! -o xtrace && $AUR_COLOR == auto ) || $AUR_COLOR == always ]] ; then
colorize
fi
opt_short=j:
opt_long=('no-prepare' 'jobs:')
opt_hidden=('dump-options' 'noprepare')
if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
usage
fi
set -- "${OPTRET[@]}"
makepkg_args=('--nobuild' '--nodeps' '--skipinteg' '--log')
num_procs=$(("$(nproc)" + 2))
while true; do
case "$1" in
--noprepare|--no-prepare)
makepkg_args+=(--noprepare) ;;
-j|--jobs)
shift; num_procs=$1 ;;
--dump-options)
printf -- '--%s\n' "${opt_long[@]}"
printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
exit ;;
--)
shift; break ;;
esac
shift
done
if ! (( $# )); then
usage
fi
tmp=$(mktemp -dt "$argv0".XXXXXXXX) || exit
trap 'trap_exit' EXIT
i=0
for n in "$@"; do
if (( i++ >= num_procs )); then
wait -n
fi
{ mkdir -p "$tmp/$n"
if ! env -C "$n" nice -n 20 makepkg "${makepkg_args[@]}" >"$tmp/$n"/log 2>&1; then
echo $? >"$tmp/$n"/failed
fi
} &
done
wait
failed=()
for n in "$@"; do
if [[ -e $tmp/$n/failed ]]; then
failed+=("$n")
else
srcver_pkgbuild_info "$n"
fi
done
for f in "${failed[@]}"; do
warning 'makepkg %s failed for package %s' "${makepkg_args[*]}" "$f"
cat "$tmp/$f"/log >&2
plain '8<----' >&2
done
# vim: set et sw=4 sts=4 ft=sh: