summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2020-08-14 23:05:30 -0400
committerAndreas Grapentin <andreas@grapentin.org>2022-01-18 17:31:51 +0100
commit206fba418e7311f9d1d311ad11f22929d38dd7fe (patch)
treee9eb80cd2b4b086aa533c93a077712cd176b5b9f
parent8a71cd066b756ef1f7a10f0a41b6783ec6fe73b3 (diff)
allow building replacements for existing blacklist entries
libremakepkg will refuse to build a blacklisted package, if no libre replacement had been published before the next repo sync this change warns instead, and prompts for confirmation see note in src/chroot-tools/hooks-check.sh::check_pkgbuild_nonfree()
-rw-r--r--src/chroot-tools/hooks-check.sh25
-rwxr-xr-xsrc/lib/blacklist.sh8
-rwxr-xr-xsrc/pkgbuild-check-nonfree20
-rwxr-xr-xsrc/pkgbuild-summarize-nonfree24
4 files changed, 50 insertions, 27 deletions
diff --git a/src/chroot-tools/hooks-check.sh b/src/chroot-tools/hooks-check.sh
index 13f8916..8d6a01b 100644
--- a/src/chroot-tools/hooks-check.sh
+++ b/src/chroot-tools/hooks-check.sh
@@ -16,11 +16,30 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+source "$(librelib blacklist)"
+
hook_check_pkgbuild+=("check_pkgbuild_nonfree")
check_pkgbuild_nonfree() {
- local s=0
- sudo -EH -u "$LIBREUSER" pkgbuild-check-nonfree -f || s=$?
- pkgbuild-summarize-nonfree $s
+ local retval=0
+
+ sudo -EH -u "$LIBREUSER" pkgbuild-check-nonfree -f || retval=$?
+ pkgbuild-summarize-nonfree -w $retval
+
+ if (( $retval & ($_E_DEP_NONFREE | $_E_PKG_NONFREE) ))
+ then
+ # this may fail when a blacklist entry exists for this package,
+ # but no libre replacement was published before the next repo sync
+ # in such cases, blacklist.sh::blacklist-get-rep() will not find
+ # it in the repos, and will treat it as a non-free package, aborting the build
+ # perhaps that logic could be adapted to silently allow this case to pass,
+ # but it's probably bestjto ask the user, instead
+ warning "Are you making a libre replacement for this package? [y/N]"
+ read -N 1 -s < /dev/tty ; echo ;
+ [[ $REPLY =~ ^[Yy]$ ]] && retval=0
+ fi
+
+ return $retval
}
#hook_check_pkgbuild+=("check_pkgbuild_namcap")
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
index 6b1898d..834f254 100755
--- a/src/lib/blacklist.sh
+++ b/src/lib/blacklist.sh
@@ -23,6 +23,14 @@
# make sure XDG_CACHE_HOME is set
source "$(librelib conf)"
+declare -ri _E_OK=0 2> /dev/null || true
+declare -ri _E_ERROR=1 2> /dev/null || true
+declare -ri _E_LIC_UNKNOWN=2 2> /dev/null || true
+declare -ri _E_LIC_NOGPL=4 2> /dev/null || true
+declare -ri _E_LIC_NONFREE=8 2> /dev/null || true
+declare -ri _E_DEP_NONFREE=16 2> /dev/null || true
+declare -ri _E_PKG_NONFREE=32 2> /dev/null || true
+
# Usage: blacklist-normalize <$file
# Normalizes the syntax of the blacklist on stdin.
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index 6cd6b1c..f0ca5c6 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -30,10 +30,9 @@
# i appologize that i deleted your vim metadata - no wait, not sorry :)
-source "$(librelib blacklist)"
-source "$(librelib conf)"
-source "$(librelib messages)"
-
+. "$(librelib messages)"
+. "$(librelib conf)"
+. "$(librelib blacklist)"
usage() {
print "Usage: %s [OPTIONS] [PKGBUILD1 PKGBUILD2 ...]" "${0##*/}"
@@ -195,24 +194,23 @@ check_dep() {
[[ $# == 1 ]] || panic 'malformed call to check_dep'
local pkg=$1
- local line rep
+ local line replacement
line="$(blacklist-cat|blacklist-lookup "$pkg")"
- rep="$(blacklist-get-rep <<<"$line")"
-
+ replacement="$(blacklist-get-rep <<<"$line")"
if [[ -z $line ]]; then
# not mentioned in blacklist; free
info '%s: not blacklisted' "$pkg"
return $_E_OK
- elif [[ -z $rep ]]; then
- # non-free with no replacement
+ elif [[ -z $replacement ]]; then
+ # non-free with no replacement yet in the repos
plain '%s: blacklisted' "$pkg"
return $_E_DEP_NONFREE
else
# non-free with free replacement
- if [[ "$rep" == "$pkg" ]]; then
+ if [[ "$replacement" == "$pkg" ]]; then
info '%s: repackaged with the same name' "$pkg"
else
- info '%s: replaced by %s' "$pkg" "$rep"
+ info '%s: replaced by %s' "$pkg" "$replacement"
fi
return $_E_OK
fi
diff --git a/src/pkgbuild-summarize-nonfree b/src/pkgbuild-summarize-nonfree
index d622cf6..af220a8 100755
--- a/src/pkgbuild-summarize-nonfree
+++ b/src/pkgbuild-summarize-nonfree
@@ -19,16 +19,9 @@
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+source "$(librelib blacklist)"
source "$(librelib messages)"
-# Make sure these match pkgbuild-check-nonfree
-declare -ri _E_ERROR=1
-declare -ri _E_LIC_UNKNOWN=2
-declare -ri _E_LIC_NOGPL=4
-declare -ri _E_LIC_NONFREE=8
-declare -ri _E_DEP_NONFREE=16
-declare -ri _E_PKG_NONFREE=32
-
usage() {
print "Usage: %s [OPTIONS] STATUS" "${0##*/}"
@@ -41,14 +34,17 @@ usage() {
print 'Options:'
flag '-q' 'Be quiet'
flag '-h' 'Show this message'
+ flag '-w' 'Treat blacklist entries as warnings'
}
main() {
local quiet=false
- while getopts 'qh' arg; do
+ local warn=false
+ while getopts 'qhw' arg; do
case "$arg" in
q) quiet=true;;
h) usage; exit $EXIT_SUCCESS;;
+ w) warn=true;;
*) usage >&2; exit $EXIT_INVALIDARGUMENT;;
esac
done
@@ -93,11 +89,13 @@ parse() {
error "This PKGBUILD has a non-free license"
ret=$EXIT_FAILURE;;
$_E_DEP_NONFREE)
- error "This PKGBUILD depends on blacklisted package(s)"
- ret=$EXIT_FAILURE;;
+ $warn && warning "This PKGBUILD depends on blacklisted package(s)" || \
+ error "This PKGBUILD depends on blacklisted package(s)"
+ $warn || ret=$EXIT_FAILURE;;
$_E_PKG_NONFREE)
- error "This PKGBUILD is for a blacklisted package"
- ret=$EXIT_FAILURE;;
+ $warn && warning "This PKGBUILD is for a blacklisted package" || \
+ error "This PKGBUILD is for a blacklisted package"
+ $warn || ret=$EXIT_FAILURE;;
esac
fi
done