summaryrefslogtreecommitdiff
path: root/src/lib/blacklist.sh
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-22 18:49:59 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-22 18:49:59 -0400
commit62c6567f5a01ee700d1fae99855898d8f85d76f4 (patch)
treed614eb272d8ca374b7aa3f1922b00c862bd6800c /src/lib/blacklist.sh
parent4ff2981b13f10192f9725592c0364a5377932c6d (diff)
add a lib/blacklist.sh, use it for pkgbuild-check-nonfree
Diffstat (limited to 'src/lib/blacklist.sh')
-rw-r--r--src/lib/blacklist.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
new file mode 100644
index 0000000..925a5cc
--- /dev/null
+++ b/src/lib/blacklist.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+blacklist-normalize() {
+ sed -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/'
+}
+
+blacklist-cat() {
+ blacklist-normalize < "$XDG_CACHE_HOME/libretools/blacklist.txt"
+}
+
+blacklist-update() (
+ set -euE
+ . /usr/share/libretools/conf.sh
+ . libremessages
+ load_files libretools
+ check_vars BLACKLIST
+
+ local remote_blacklist="$BLACKLIST"
+ local local_blacklist="$XDG_CACHE_HOME/libretools/blacklist.txt"
+
+ stat_busy "Downloading blacklist of proprietary software packages"
+
+ mkdir -p "${local_blacklist%/*}"
+ if wget -N -q -O "${local_blacklist}.part" "$remote_blacklist" 2>/dev/null; then
+ stat_done
+ mv "${local_blacklist}.part" "$local_blacklist"
+ else
+ stat_done
+ rm "${local_blacklist}.part"
+ if [[ -e "$local_blacklist" ]]; then
+ warning "Using local copy of blacklist"
+ else
+ error "Download failed, exiting"
+ return 1
+ fi
+
+ fi
+)
+
+blacklist-lookup() {
+ local pkg=$1
+ blacklist-cat | sed 's/^/^/' | grep -F "^$pkg:" | sed 's/^^//'
+}
+
+blacklist-get-pkg() {
+ cut -d: -f1
+}
+
+blacklist-get-rep() {
+ cut -d: -f2
+}
+
+blacklist-get-reason() {
+ cut -d: -f3-
+}