2 # aur-srcver - update and print package revisions
3 [[ -v AUR_DEBUG
]] && set -o xtrace
6 PS4
='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
9 makepkg_args
=('--nobuild' '--nodeps' '--skipinteg')
10 num_procs
=$
(( "$(nproc)" + 2 ))
13 if [[ ! -v AUR_DEBUG
]]; then
16 printf >&2 'AUR_DEBUG: %s: temporary files at %s\n' "$argv0" "$tmp"
21 printf >&2 'usage: %s [--no-prepare] <pkgbase> [<pkgbase> ...]\n' "$argv0"
25 source /usr
/share
/makepkg
/util
/parseopts.sh
26 source /usr
/share
/makepkg
/util
/pkgbuild.sh
29 opt_long
=('no-prepare' 'jobs:' 'buildscript:')
30 opt_hidden
=('dump-options' 'noprepare' 'env:')
32 if ! parseopts
"$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
40 --noprepare|
--no-prepare)
41 makepkg_args
+=(--noprepare) ;;
43 shift ;; # deprecated flag, has no effect
45 shift; num_procs
=$1 ;;
48 makepkg_args
+=(-p "$1") ;;
50 printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"}
51 printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
59 # Single hyphen to denote input taken from stdin
61 if (( $# == 1 )) && [[ $1 == "-" || $1 == "/dev
/stdin
" ]]; then
69 # shellcheck disable=SC2174
70 mkdir -pm 0700 "${TMPDIR:-/tmp}/aurutils-
$UID"
71 tmp=$(mktemp -d --tmpdir "aurutils-
$UID/$argv0.XXXXXXXX
") || exit
74 # A pipeline `foo | bar &` causes `bar` to detach from the script. In
75 # this case, aur-srcver returns immediately with `makepkg` processes
76 # still running in the background. Read all input into an array to
77 # avoid this. (cf. aur-view, #958)
86 for n in "${packages[@]}"; do
87 if (( i++ >= num_procs )); then
93 if ! env -C "$n" nice -n 20 makepkg "${makepkg_args[@]}" >"$tmp/$n"/log 2>&1; then
94 echo $? >"$tmp/$n"/failed
101 for d in "$tmp"/*/; do # iterate over directories
104 if [[ -e $tmp/$n/failed ]]; then
107 # Precautions when sourcing the PKGBUILD have no effect here,
108 # because makepkg already sourced the PKGBUILD above.
109 # shellcheck disable=SC1090
110 ( source "$n/${buildscript-PKGBUILD}"
112 fullver=$(get_full_version)
113 printf '%s\t%s\n' "${pkgbase:-$pkgname}" "$fullver"
118 if (( ${#failed[@]} )); then
119 printf >&2 '8<----\n'
122 for f in "${failed[@]}"; do
123 printf >&2 '%s: makepkg %s failed for package %s\n' "$argv0" "${makepkg_args[*]}" "$f"
125 cat "$tmp/$f"/log >&2
126 printf >&2 '8<----\n'
129 # vim: set et sw=4 sts=4 ft=sh: