summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIsaac David <isacdaavid@isacdaavid.info>2017-10-14 00:54:20 -0500
committerIsaac David <isacdaavid@isacdaavid.info>2017-10-14 00:54:20 -0500
commit313d1ee619363eca0b8b0742a2d58c9ce18877fd (patch)
tree11c1d7b920f0019423b4e5c7477c30e02b2efd75 /src
parent2a7b161e6aa234aa5d434f47d3aedbe48ff7b251 (diff)
blacklist get-rep: re-implement to query repos instead of blacklist.txt
Rationale: https://lists.parabola.nu/pipermail/dev/2017-October/005936.html This makes get-rep a general-purpose tool for finding replacements and providers of any package, not just blacklisted-ones. It works equally well reading from full blacklist.txt lines, just pkgname lines, and unwittingly; a single line with many pkgnames. Some caveats for further discussion: - This changes behavior from showing just one replacement/provider to _all_ replacements and providers (including pkgname itself) in the repos. - By "repos" I mean the repos the executing machine is configured to access. This could be changed in the future with `expac --config` if more package databases are desired (e.g. different architecture). - Results are shown using the "repo/pkgname ..." format rather than just "pkgname ...". I think this makes the program more useful. - Results aren't reordered to ensure that the first provider of pkgname is pkgname itself. Order will be as expected otherwise, by virtue of expac parsing repos in order.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/lib/blacklist.sh19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
index e3d976b..c092ed3 100755
--- a/src/lib/blacklist.sh
+++ b/src/lib/blacklist.sh
@@ -93,7 +93,24 @@ blacklist-get-pkg() {
# Usage: blacklist-cat | blacklist-get-rep
# Prints only the replacement package field of the blacklist line(s) on stdin.
blacklist-get-rep() {
- blacklist-normalize | cut -d: -f2
+ local -a targets=($(blacklist-get-pkg))
+ expac -Ss '%r/%n %n %P %R' | awk -v arr="${targets[*]}" '
+ {
+ gsub("[=<>]+[^[:blank:]]*", "", $0) # discard versioning
+ # build pkg -> providers table from pkg -> provides
+ for (provided = 2; provided <= NF; ++provided) {
+ if (! seen[$1 " " $provided]++) {
+ providers[$provided] = providers[$provided] $1 " "
+ }
+ }
+ }
+ END {
+ split(arr, targets, " ")
+ for (pkg in targets) {
+ sub("[ \t]+$", "", providers[targets[pkg]])
+ print providers[targets[pkg]]
+ }
+ }'
}
# Usage: blacklist-cat | blacklist-get-url