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:           Fri Jan  5 07:54:39 UTC 2018

Modified Files:
        pkgsrc/mk: license.mk

Log Message:
Improved license detection for the guess-license target.

Before, the first file that looked like a license file was considered.
The others were completely ignored. This led to a wrong license for
cross/arm-none-eabi-gcc. To prevent these cases in the future, the license
is only guessed if there is exactly one file with a typical license name.

This approach is still naive, but at least a little more precise. Replacing
the guess-license with a determine-licenses is much more complicated
though, since each source code file may have its own license declared, and
handling all these special cases leads to very complex license expressions
(like "gnu-gpl-v3 for all files, except for special.c, which is apache-2.0
or mit). This is very hard to do correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.82 pkgsrc/mk/license.mk:1.83
--- pkgsrc/mk/license.mk:1.82   Wed Jan  3 00:41:37 2018
+++ pkgsrc/mk/license.mk        Fri Jan  5 07:54:39 2018
@@ -1,4 +1,4 @@
-# $NetBSD: license.mk,v 1.82 2018/01/03 00:41:37 rillig Exp $
+# $NetBSD: license.mk,v 1.83 2018/01/05 07:54:39 rillig Exp $
 #
 # This file handles everything about the LICENSE variable. It is
 # included automatically by bsd.pkg.mk.
@@ -248,23 +248,22 @@ guess-license:
        ${PHASE_MSG} "Guessing package license"; \
        type wdiff > /dev/null 2>&1 || ${FAIL_MSG} "To guess the license, textproc/wdiff must be installed."; \
        \
+       pkgfiles=`find ${WRKSRC} -type f -print | ${EGREP} '/COPYING|/LICEN[CS]E|/COPYRIGHT' | LC_ALL=C ${SORT}`; \
+       case $$pkgfiles in *'${.newline}'*) printf "The package has more than one license file:\n\n%s\n" "$$pkgfiles"; exit; esac; \
+       \
        { \
-       printf "%8s   %s\n" "Wdiff" "License"; \
        bestsize=1000000; \
        bestlicense=; \
-       for pkglicense in ${WRKSRC}/COPYING ${WRKSRC}/LICENSE ${WRKSRC}/COPYRIGHT; 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; \
+       pkglicense="$$pkgfiles"; \
+       ${PRINTF} "%8s   %s\n" "Wdiff" "License"; \
+       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; \
        \



Home | Main Index | Thread Index | Old Index