From a5de5ff031412c0319dc292d40ee60898d90e064 Mon Sep 17 00:00:00 2001 From: Isaac David Date: Sat, 7 Oct 2017 19:34:01 -0500 Subject: blacklist.sh: update `normalize` and `get-reason` to reflect blacklist.txt the blacklist has had a couple extra fields (ref, id) for some time, but `libreblacklist` was never made aware of the change. this updates test/lib-blacklist-test.sh for the same reason, and adds a test for comment stripping under `it_normalizes_correctly()`. --- src/lib/blacklist.sh | 8 ++++++-- test/lib-blacklist-test.sh | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/lib/blacklist.sh mode change 100644 => 100755 test/lib-blacklist-test.sh diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh old mode 100644 new mode 100755 index 249ee89..6c507f4 --- a/src/lib/blacklist.sh +++ b/src/lib/blacklist.sh @@ -24,7 +24,11 @@ # Usage: blacklist-normalize <$file # Normalizes the syntax of the blacklist on stdin. blacklist-normalize() { - sed -e '/^#/d' -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/' + sed -r -e '/^#/d' \ + -e 's/^[^:]*$/&::::/' \ + -e 's/^[^:]*:[^:]*$/&:::/' \ + -e 's/^[^:]*(:[^:]*){2}$/&::/' \ + -e 's/^[^:]*(:[^:]*){3}$/&:/' } # Usage: blacklist-cat @@ -91,5 +95,5 @@ blacklist-get-rep() { # Usage: blacklist-cat | blacklist-get-reason # Prints only the reason field of the blacklist line(s) on stdin. blacklist-get-reason() { - blacklist-normalize | cut -d: -f3- + blacklist-normalize | cut -d: -f5- } diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh old mode 100644 new mode 100755 index 49c756e..ef99f91 --- a/test/lib-blacklist-test.sh +++ b/test/lib-blacklist-test.sh @@ -6,32 +6,36 @@ describe libreblacklist _blacklist_url=https://projects.parabola.nu/blacklist.git/plain/blacklist.txt it_works_with_just_pkgname() { - v="$(libreblacklist normalize <<