summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2018-02-19 12:58:51 +0000
committerrillig <rillig@pkgsrc.org>2018-02-19 12:58:51 +0000
commit790a34e09df5cdcf630805cc61fe7ac05a072be6 (patch)
tree5ba37f8ae2d7c004258e6d8958b71d42a0689834 /mk
parent7fe5cae088497c60d6063dda218e66f55f4dd4b1 (diff)
downloadpkgsrc-790a34e09df5cdcf630805cc61fe7ac05a072be6.tar.gz
mk/license.mk: drop the selfmade license guessing code in favor of ninka
Diffstat (limited to 'mk')
-rw-r--r--mk/license.mk59
1 files changed, 14 insertions, 45 deletions
diff --git a/mk/license.mk b/mk/license.mk
index c7405c27a79..9de4a9885e3 100644
--- a/mk/license.mk
+++ b/mk/license.mk
@@ -1,4 +1,4 @@
-# $NetBSD: license.mk,v 1.85 2018/02/03 17:38:13 kamil Exp $
+# $NetBSD: license.mk,v 1.86 2018/02/19 12:58:51 rillig Exp $
#
# This file handles everything about the LICENSE variable. It is
# included automatically by bsd.pkg.mk.
@@ -246,51 +246,20 @@ PKG_FAIL_REASON+= \
#
# Keywords: license
guess-license: .PHONY
- ${RUN} [ -d ${WRKSRC} ] || ALLOW_VULNERABLE_PACKAGES=yes ${MAKE} makedirs fetch pre-extract do-extract
+ @# Running "make extract" would fetch and build the dependencies
+ ${RUN} [ -d ${WRKSRC} ] \
+ || ALLOW_VULNERABLE_PACKAGES=yes ${MAKE} makedirs fetch pre-extract do-extract
+
${RUN} \
- ${PHASE_MSG} "Guessing package license"; \
- \
- if type ninka > /dev/null 2>&1; then \
- (cd ${WRKDIR} && ${FIND} ./* -type f -print \
- | ${XARGS} ninka \
- | ${AWK} -F ';' '{ print $$2 }' \
- | LC_ALL=C ${SORT} | uniq -c | LC_ALL=C ${SORT} -nr \
- | ${AWK} 'BEGIN { printf("%5s %s\n", "Files", "License") } { printf("%5d %s\n", $$1, $$2); }'); \
- exit 0; \
- fi; \
- \
- 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; \
+ type ninka > /dev/null 2>&1 || ${FAIL_MSG} "To guess the license, wip/ninka must be installed."; \
\
- { \
- bestsize=1000000; \
- bestlicense=; \
- 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; \
+ ${PHASE_MSG} "Guessing licenses for ${PKGNAME}"; \
\
- if [ "$$bestlicense" ]; then \
- echo ""; \
- echo "Line differences in license texts:"; \
- echo ""; \
- diff -wu "$$bestlicense" "$$pkglicense" || true; \
- echo ""; \
- echo "Word differences in license texts:"; \
- echo ""; \
- wdiff -3 "$$bestlicense" "$$pkglicense" || true; \
- else \
- echo "No license file found in ${WRKSRC}:"; \
- ls -l ${WRKSRC}; \
- fi \
- } | $${PAGER:-less}
+ : "Note that ninka can only handle one file at a time; therefore the slow loop below."; \
+ cd ${WRKDIR} \
+ && ${FIND} ./* -type f -print \
+ | while read fname; do ninka "$$fname"; done \
+ | ${AWK} -F ';' '{ print $$2 }' \
+ | LC_ALL=C ${SORT} | uniq -c | LC_ALL=C ${SORT} -nr \
+ | ${AWK} 'BEGIN { printf("%5s %s\n", "Files", "License") } { printf("%5d %s\n", $$1, $$2); }'