summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/lib/libreblacklist14
-rwxr-xr-xsrc/pkgbuild-check-nonfree2
-rw-r--r--test/libreblacklist-test.sh38
3 files changed, 46 insertions, 8 deletions
diff --git a/src/lib/libreblacklist b/src/lib/libreblacklist
index 2f73a06..293f3ac 100755
--- a/src/lib/libreblacklist
+++ b/src/lib/libreblacklist
@@ -73,25 +73,25 @@ blacklist-update() (
blacklist-lookup() {
local pkg=$1
# we accept that $pkg contains no regex-nes
- blacklist-cat | grep "^$pkg:" || true
+ blacklist-normalize | grep "^$pkg:" || true
}
-# Usage: blacklist-{cat|lookup} | blacklist-get-pkg
+# Usage: blacklist-cat | blacklist-get-pkg
# Outputs only the package name field of the blacklist line(s) on stdin.
blacklist-get-pkg() {
- cut -d: -f1
+ blacklist-normalize | cut -d: -f1
}
-# Usage: blacklist-{cat|lookup} | blacklist-get-rep
+# Usage: blacklist-cat | blacklist-get-rep
# Outputs only the replacement package field of the blacklist line(s) on stdin.
blacklist-get-rep() {
- cut -d: -f2
+ blacklist-normalize | cut -d: -f2
}
-# Usage: blacklist-{cat|lookup} | blacklist-get-reason
+# Usage: blacklist-cat | blacklist-get-reason
# Outputs only the reason field of the blacklist line(s) on stdin.
blacklist-get-reason() {
- cut -d: -f3-
+ blacklist-normalize | cut -d: -f3-
}
if [[ "${0##*/}" == libreblacklist ]]; then
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index c37b0bf..be9d20d 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -51,7 +51,7 @@ check_deps() (
)
local ret=0
for pkg in "${pkgs[@]}"; do
- local line="$(blacklist-lookup "$pkg")"
+ local line="$(blacklist-cat|blacklist-lookup "$pkg")"
local rep="$(blacklist-get-rep <<<"$line")"
if [[ -z $line ]]; then
# not mentioned in blacklist; free
diff --git a/test/libreblacklist-test.sh b/test/libreblacklist-test.sh
new file mode 100644
index 0000000..f2fd457
--- /dev/null
+++ b/test/libreblacklist-test.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env roundup
+
+describe libreblacklist
+
+it_works_with_just_pkgname() {
+ v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::' ]]
+ v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]]
+ v="$(libreblacklist get-rep <<<skype)"; [[ -z $v ]]
+ v="$(libreblacklist get-reason <<<skype)"; [[ -z $v ]]
+}
+
+it_works_with_everything_set() {
+ line='linux:linux-libre:nonfree blobs and firmwares'
+ v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]]
+ v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'linux' ]]
+ v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'linux-libre' ]]
+ v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'nonfree blobs and firmwares' ]]
+}
+
+it_normalizes_correctly() {
+ v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::' ]]
+ v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::' ]]
+ v="$(libreblacklist normalize <<<pkg::)"; [[ $v == 'pkg::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep)"; [[ $v == 'pkg:rep:' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:)"; [[ $v == 'pkg:rep:' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:reason)"; [[ $v == 'pkg:rep:reason' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:reason:)"; [[ $v == 'pkg:rep:reason:' ]]
+}
+
+it_works_with_colons_in_reason() {
+ line='package:replacement:my:reason'
+ v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]]
+ v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'package' ]]
+ v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'replacement' ]]
+ v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]]
+}
+
+# TODO: test blacklist-update, but I don't want tests to use network