2 # aur-vercmp - check packages for AUR updates
3 [[ -v AUR_DEBUG
]] && set -o xtrace
6 PS4
='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
9 format
=check target
=aur all
=0 quiet
=0
12 # shellcheck disable=SC2155
13 local str
=$
(printf '%s,' "$@")
14 printf '%s' "${str%,}"
18 if [[ $1 == "$2" ]]; then
19 printf '%d' 0 # common case
25 cmp_equal_or_newer
() {
26 local pkg v_cmp v_in op
28 while read -r pkg v_cmp v_in
; do
30 -) op
=2 ;; # - on field 2
31 *) op
=$
(my_vercmp
"$v_in" "$v_cmp") ;;
35 -1) plain
>&2 '%s %s is newer than %s' "$pkg" "$v_cmp" "$v_in" >&2
36 printf '%s\n' "$pkg" ;;
37 0) printf '%s\n' "$pkg" ;;
38 1) msg2
>&2 '%s %s -> %s' "$pkg" "$v_cmp" "$v_in" ;;
39 2) msg2
>&2 '%s (none) -> %s' "$pkg" "$v_in" ;;
45 local pkg v_cmp v_in op
47 while read -r pkg v_cmp v_in
; do
49 -) op
=2 ;; # - on field 3
50 *) op
=$
(my_vercmp
"$v_in" "$v_cmp") ;;
53 (( ! all
)) && (( op
> -1 )) && continue;
54 (( quiet
)) && { printf '%s\n' "$pkg"; continue; }
57 -1) printf '%s %s -> %s\n' "$pkg" "$v_in" "$v_cmp" ;;
58 0) printf '%s %s = %s\n' "$pkg" "$v_in" "$v_cmp" ;;
59 1) printf '%s %s <- %s\n' "$pkg" "$v_in" "$v_cmp" ;;
60 2) printf '%s (none) -> %s\n' "$pkg" "$v_cmp" ;;
66 aur query
-t info
- | aur format
-f '%n\t%v\n'
70 if [[ ! -v AUR_DEBUG
]]; then
73 printf >&2 'AUR_DEBUG: %s: temporary files at %s\n' "$argv0" "$tmp"
78 plain
>&2 'usage: %s [-acq] [-p path]' "$argv0"
82 source /usr
/share
/makepkg
/util
/message.sh
84 if [[ ! -v NO_COLOR
]] && [[ ! -v AUR_DEBUG
]]; then
85 [[ -t 2 ]] && colorize
89 opt_long
=('all' 'current' 'path:' 'quiet' 'upair:')
90 opt_hidden
=('dump-options')
92 if opts
=$
(getopt
-o "$opt_short" -l "$(args_csv "${opt_long[@]}" "${opt_hidden[@]}")" -n "$argv0" -- "$@"); then
113 printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"}
114 printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
121 # shellcheck disable=SC2174
122 mkdir -pm 0700 -- "${TMPDIR:-/tmp}/aurutils-
$UID"
123 tmp=$(mktemp --tmpdir "aurutils-
$UID/$argv0.XXXXXXXX
") || exit
124 trap 'trap_exit' EXIT
126 # check for interactive terminal
129 Warning: Input is read from the terminal. You either know what you
130 Warning: are doing, or you forgot to pipe data into $argv0.
131 Warning: Press CTRL-D to exit.
138 check) cmp() { cmp_checkupdates; }
139 upair=${upair-1} ;; # join unpaired of target
140 equal) cmp() { cmp_equal_or_newer; }
141 upair=${upair-2} ;; # join unpaired of input
146 aur) awk '{print $1}' "$tmp" | parse_aur ;;
147 file) awk '{print $0}' "$aux" ;;
148 esac | sort -k 1b,1 | join -a "$upair" -e - -o 0,1.2,2.2 - "$tmp" | cmp
150 # vim: set et sw=4 sts=4 ft=sh: