diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-22 18:49:59 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-22 18:49:59 -0400 |
commit | 62c6567f5a01ee700d1fae99855898d8f85d76f4 (patch) | |
tree | d614eb272d8ca374b7aa3f1922b00c862bd6800c /src | |
parent | 4ff2981b13f10192f9725592c0364a5377932c6d (diff) |
add a lib/blacklist.sh, use it for pkgbuild-check-nonfree
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/blacklist.sh | 55 | ||||
-rwxr-xr-x | src/pkgbuild-check-nonfree | 43 |
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 |