pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/mk Added the guess-license target.
details: https://anonhg.NetBSD.org/pkgsrc/rev/a6a531fd30fa
branches: trunk
changeset: 373480:a6a531fd30fa
user: rillig <rillig%pkgsrc.org@localhost>
date: Tue Jan 02 22:40:32 2018 +0000
description:
Added the guess-license target.
It compares the license file from the package with the available licenses
in licenses/ and shows the diff to the best match.
This will hopefully make it easier for package authors to include the
LICENSE variable in the package Makefile. This variable being missing is
one of the most frequent error messages from pkglint (4187 out of 20044).
diffstat:
mk/license.mk | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 51 insertions(+), 3 deletions(-)
diffs (74 lines):
diff -r fc97cf37aef0 -r a6a531fd30fa mk/license.mk
--- a/mk/license.mk Tue Jan 02 21:18:48 2018 +0000
+++ b/mk/license.mk Tue Jan 02 22:40:32 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: license.mk,v 1.80 2017/05/11 12:56:21 jperkin Exp $
+# $NetBSD: license.mk,v 1.81 2018/01/02 22:40:32 rillig Exp $
#
# This file handles everything about the LICENSE variable. It is
# included automatically by bsd.pkg.mk.
@@ -97,10 +97,10 @@
# This list is not complete. Free and Open Source licenses should be
# added to the list as they are added to pkgsrc.
-
+#
# The convention is that Free or Open Source licenses do not have a
# -license suffix, and nonfree licenses end in -license.
-
+#
DEFAULT_ACCEPTABLE_LICENSES= \
apache-1.1 apache-2.0 \
arphic-public \
@@ -236,3 +236,51 @@
.endif
.endif
+
+# guess-license:
+# Extracts the current package and tries to guess its license.
+# This is useful for package developers.
+#
+# Keywords: license
+
+guess-license:
+ ${RUN} ${MAKE} extract
+ ${RUN} \
+ type wdiff > /dev/null 2>&1 || ${FAIL_MSG} "To guess the license, textproc/wdiff must be installed."; \
+ \
+ printf "%8s %s\n" "Wdiff" "License"; \
+ bestsize=1000000; \
+ bestlicense=; \
+ for pkglicense in ${WRKSRC}/COPYING ${WRKSRC}/LICENSE; do \
+ for license in ${PKGSRCDIR}/licenses/*; do \
+ if [ -f "$$pkglicense" ] && [ -f "$$license" ]; then \
+ size=`{ wdiff -3 "$$pkglicense" "$$license" || true; } | wc -c`; \
+ if [ "$$size" -lt "$$bestsize" ]; then \
+ printf "%8d %s\n" "$$size" "$${license##*/}"; \
+ bestsize="$$size"; \
+ bestlicense="$$license"; \
+ fi \
+ fi \
+ done; \
+ if [ "$$bestlicense" ]; then \
+ break; \
+ fi \
+ done; \
+ \
+ if [ "$$bestlicense" ]; then \
+ if [ "$$bestsize" -lt 3000 ]; then \
+ echo ""; \
+ echo "Line differences in license texts:"; \
+ echo ""; \
+ diff -wu "$$pkglicense" "$$bestlicense" || true; \
+ echo ""; \
+ echo "Word differences in license texts:"; \
+ echo ""; \
+ wdiff -3 "$$pkglicense" "$$bestlicense" || true; \
+ else \
+ echo ""; \
+ echo "No similar enough license found."; \
+ fi \
+ else \
+ echo "No license file found in ${WRKSRC}."; \
+ fi
Home |
Main Index |
Thread Index |
Old Index