2 # aur-repo-filter - filter packages in the Arch Linux repositories
3 [[ -v AUR_DEBUG
]] && set -o xtrace
5 PS4
='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
6 arch_repo
=(core extra testing community
{,-testing} multilib
{,-testing})
11 # The command line will hit ARG_MAX on approximately 70k packages;
12 # spread arguments with xargs (and printf, as a shell built-in).
15 xargs -a <(printf -- "--satisfies=%s\n" "$@") pacsift
"${sift_args[@]}" <&-
20 pacinfo
"${info_args[@]}" |
awk -F'[:<=>]' '
21 /Name:/ { pkgname=$2; }
22 /Repository:/ { repo=$2
23 print repo, pkgname, pkgname; }
24 /Provides:/ { print repo, pkgname, $2; }
25 /Replaces:/ { print repo, pkgname, $2; }
30 plain
>&2 'usage: %s [-d repo] [-S]' "$argv0"
34 source /usr
/share
/makepkg
/util
/parseopts.sh
37 opt_long
=('all' 'sync' 'config:' 'database:' 'sysroot:')
38 opt_hidden
=('dump-options' 'repo:')
40 if ! parseopts
"$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
45 unset argv_repo sift_args info_args
51 shift; argv_repo
+=("$1") ;;
53 shift; sift_args
+=(--config="$1")
54 info_args
+=(--config="$1") ;;
56 shift; sift_args
+=(--sysroot="$1")
57 info_args
+=(--sysroot="$1") ;;
59 printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"}
60 printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
67 if (( sync_repo )); then
69 elif [[ -v argv_repo ]]; then
70 sift_args+=(--exact "${argv_repo[@]/#/--repo=}")
72 sift_args+=(--exact "${arch_repo[@]/#/--repo=}")
75 # check for interactive terminal
78 Warning: Input is read from the terminal. You either know what you
79 Warning: are doing, or you forgot to pipe data into $argv0.
80 Warning: Press CTRL-D to exit.
84 # associative array for input package names
88 while IFS= read -r str; do
89 # store unversioned string as key
92 # store version + operator as value (1 if unavailable)
93 if (( ${#str} - ${#name} )); then
94 pkgset[$name]=${str:${#name}}
99 # store original versioned string
103 # exit on empty stdin
104 if ! (( ${#pkgset[@]} )); then
108 # Standard input is taken as "provides
[<cmp><version
>]", where pacsift
109 # checks for a package satisfying this condition. Results are printed
110 # as "repository
/package
", and piped to pacinfo to relate the names of
111 # the original provides to its corresponding package(s).
112 satisfies "${strset[@]}" | provides | while read -r repo package virtual; do
113 if [[ ${pkgset[$package]} ]]; then
114 printf '%s\n' "$package"
117 if [[ $virtual != "$package" ]]; then
118 version=${pkgset[$virtual]:-1}
124 1) printf >&2 'dependency %s satisfied by %s/%s\n' "$virtual" "$repo" "$package"
125 printf '%s\n' "$virtual" ;;
126 *) printf >&2 'dependency %s%s satisfied by %s/%s\n' "$virtual" "$version" "$repo" "$package"
127 printf '%s\n' "$virtual" ;;
131 # vim: set et sw=4 sts=4 ft=sh: