summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/blacklist.sh55
-rwxr-xr-xsrc/pkgbuild-check-nonfree43
2 files changed, 59 insertions, 39 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-
+}
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index ada95b5..e20e1a3 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -20,7 +20,7 @@
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
. libremessages
-. /usr/share/libretools/conf.sh
+. /usr/share/libretools/blacklist.sh
# Unset any PKGBUILD variables inherited from the environment
# I took these from makepkg 4.1.1-1
@@ -28,40 +28,6 @@ unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
unset md5sums replaces depends conflicts backup source install changelog build
unset makedepends optdepends options noextract
-# Usage: blacklist_lookup $pkg
-# Look up the blacklist entry for $pkg
-blacklist_lookup() {
- local pkg=$1
- sed 's/^/^/;s/$/:/' "$XDG_CONFIG_HOME/libretools/blacklist.txt" |
- grep -F "^$pkg:" |
- sed 's/^^//;s/:*$//'
-}
-
-# Usage: update_blacklist $url
-# Update the cached blacklist file
-update_blacklist() {
- local remote_blacklist="$1"
- local local_blacklist="$XDG_CONFIG_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 "$XDG_CONFIG_HOME/libretools/blacklist.txt" ]]; then
- warning "Using local copy of blacklist"
- else
- error "Download failed, exiting"
- return 1
- fi
-
- fi
-}
-
# Usage: check_deps $pkgbuild
# Check whether a PKGBUILD package depends on non-free packages
check_deps() (
@@ -85,8 +51,8 @@ check_deps() (
)
local ret=0
for pkg in "${pkgs[@]}"; do
- local line="$(blacklist_lookup $pkg)"
- local rep="$(cut -d: -f2 <<<"$line:")"
+ local line="$(blacklist-lookup "$pkg")"
+ local rep="$(blacklist-get-rep <<<"$line")"
if [[ -z $line ]]; then
# not mentioned in blacklist; free
plain "$pkg: free"
@@ -144,8 +110,7 @@ main() {
return 1
fi
- load_conf_libretools || return 1 # load ${BLACKLIST}
- update_blacklist "$BLACKLIST" || return 1
+ blacklist-update || return 1
local ret=0
for pkgbuild in "${pkgbuilds[@]}"; do