diff options
Diffstat (limited to 'src/lib/blacklist.sh')
-rwxr-xr-x | src/lib/blacklist.sh | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh index 84333e8..d36502e 100755 --- a/src/lib/blacklist.sh +++ b/src/lib/blacklist.sh @@ -99,24 +99,21 @@ 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() { - 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]] - } - }' + # TODO(lukeshu): I am confident that this could be done more + # efficiently with Python+pyalpm than with awk+expac. + blacklist-normalize | awk -F: ' + # trust blacklist.txt for packages re-packaged with the same name + # (otherwise there would be a bootstrapping problem). + $2 == $1 { + print $2 + } + # but otherwise, do not trust blacklist.txt to have an accurate + # state of the repos and what replacements exist. + $2 != $1 { + cmd="expac -S '\''%r/%n %P : %R '\'' | sed -E '\''s/[=<>]+\\S*//g'\'' | grep '\'' " $1 " .*:.* " $1 " '\'' | awk '\''{print $1}'\''" + cmd | getline rep + print rep + }' } # Usage: blacklist-cat | blacklist-get-url |