summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/aur34
-rwxr-xr-xsrc/pkgbuild-check-licenses133
2 files changed, 142 insertions, 25 deletions
diff --git a/src/aur b/src/aur
index 3c7f2cc..6e7cd99 100755
--- a/src/aur
+++ b/src/aur
@@ -96,34 +96,18 @@ main() {
################################################################
- msg2 "Checking license..."
- local free=0
- for _license in "${license[@]}"; do
- if [[ ! -e "/usr/share/licenses/common/$_license" ]]; then
- case "${_license#custom:}" in
- WTFPL)
- # accept as common, I think it should be in the licenses package.
- :;;
- BSD1|BSD2|BSD3|MIT|X11)
- # accept these as common; they can't be included in the licenses package because some of the text must be customized
- :;;
- BSD4)
- warning "The 4-clause BSD license is free but has practical problems.";;
- BSD)
- warning "License \"BSD\" is ambiguous, please use one of \"BSD{1..4}\" to specify the number of clauses."
- free=1
- ;;
- *)
- warning "License \"$_license\" is not a common license"
- free=1
- ;;
+ local s=0
+ pkgbuild-check-licenses || s=$?
+ for i in 1 2 4; do
+ if [[ $s == $(($s & $i)) ]]; then
+ case $i in
+ 1) warning "pkgbuild-check-licenses encountered an error";;
+ 2) warning "This PKGBUILD has an uncommon license";;
+ 4) warning "This PKGBUILD has a known nonfree license";;
esac
fi
done
-
- if [[ $free -eq 1 ]]; then
- plain "Please check that the license is included in the package and *specially* that it respects your freedom."
- fi
+ unset s
################################################################
diff --git a/src/pkgbuild-check-licenses b/src/pkgbuild-check-licenses
new file mode 100755
index 0000000..347b48f
--- /dev/null
+++ b/src/pkgbuild-check-licenses
@@ -0,0 +1,133 @@
+#!/bin/bash
+# pkgbuild-check-licenses
+
+# Copyright 2010 Haase Hernández
+# Copyright 2010 Joseph Graham
+# Copyright 2010 Joshua Ismael
+# Copyright 2010 Nicolás Reynolds
+# Copyright 2012-2013 Luke Shumaker
+#
+# This file is part of Parabola.
+#
+# Parabola is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Parabola is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+
+. libremessages
+
+# Unset any PKGBUILD variables inherited from the environment
+# I took these from makepkg 4.1.1-1
+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: check_deps $pkgbuild
+# Check whether a PKGBUILD package depends on non-free packages
+check_licenses() (
+ # Note that we use () instead of {} for this function; so that variables
+ # from the PKBUILD don't bubble up
+ local pkgbuild=$1
+ . "$pkgbuild"
+ if [[ -z $pkgname ]]; then
+ return 1 # not a PKGBUILD
+ fi
+ if [[ -z "${license[*]}" ]]; then
+ error "license array of ${pkgbase:-${pkgname[0]}} $(get_full_version) is not set"
+ return 1
+ fi
+
+ msg2 "Looking at license array of ${pkgbase:-${pkgname[0]}} $(get_full_version)"
+
+ local ret=$_E_OK
+ for _license in "${license[@]}"; do
+ if [[ ! -e "/usr/share/licenses/common/$_license" ]]; then
+ local s=$_E_OK
+ case "${_license#custom:}" in
+ WTFPL)
+ # accept as common, I think it should be in the licenses package.
+ :;;
+ BSD1|BSD2|BSD3|MIT|X11)
+ # accept these as common; they can't be included in the licenses package because some of the text must be customized
+ :;;
+ BSD4)
+ warning "The 4-clause BSD license is free but has practical problems.";;
+ BSD)
+ warning "License \"BSD\" is ambiguous, please use one of \"BSD{1..4}\" to specify the number of clauses."
+ s=$_E_UNCOMMON
+ ;;
+ JSON)
+ error "License \"$_license\" is a known non-free license."
+ s=$_E_NONFREE
+ ;;
+ *)
+ warning "License \"$_license\" is not a common license."
+ s=$_E_UNCOMMON
+ ;;
+ esac
+ ret=$(($ret|$s))
+ fi
+ done
+ return $ret
+)
+
+cmd=${0##*/}
+usage() {
+ echo "Usage: $cmd [OPTIONS] [PKGBUILD1 PKGBUILD2 ...]"
+ echo ''
+ echo "If no PKGBUILD is specified, \`./PKGBUILD' is implied"
+ echo ''
+ echo "Exit status (add them for combinations):"
+ echo " 0: Everything OK, no freedom issues"
+ echo " 1: Ran with error"
+ echo " 2: Uses uncommon licenses, check them"
+ echo " 4: Uses known unacceptable licenses"
+ echo ''
+ echo "Options:"
+ echo ' -f Allow running as root user'
+ echo ' -h Show this message'
+}
+_E_OK=0
+_E_ERROR=1
+_E_UNCOMMON=2
+_E_NONFREE=4
+
+main() {
+ local asroot=false
+ while getopts 'fh' arg; do
+ case "$arg" in
+ f) asroot=true;;
+ h) usage; return 0;;
+ *) usage; return 1;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ if [[ $# < 1 ]]; then
+ pkgbuilds=("`pwd`/PKGBUILD")
+ else
+ pkgbuilds=("$@")
+ fi
+
+ if [[ -w / ]] && ! $asroot; then
+ error "Run as normal user, or use the -f option to run as root."
+ return 1
+ fi
+
+ blacklist-update || return 1
+
+ local ret=0
+ for pkgbuild in "${pkgbuilds[@]}"; do
+ check_deps "$pkgbuild" || ret=$(($ret|$?))
+ done
+ return $ret
+}
+
+main "$@"