pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/mk
Module Name: pkgsrc
Committed By: rillig
Date: Tue Jan 2 22:40:32 UTC 2018
Modified Files:
pkgsrc/mk: license.mk
Log Message:
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).
To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 pkgsrc/mk/license.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: pkgsrc/mk/license.mk
diff -u pkgsrc/mk/license.mk:1.80 pkgsrc/mk/license.mk:1.81
--- pkgsrc/mk/license.mk:1.80 Thu May 11 12:56:21 2017
+++ pkgsrc/mk/license.mk Tue Jan 2 22:40:32 2018
@@ -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 @@ PKG_FAIL_REASON+= \
.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