Received: by mail.netbsd.org (Postfix, from userid 605) id 52B9A84E40; Fri, 5 Jan 2018 07:54:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id D0BEC84E3F for ; Fri, 5 Jan 2018 07:54:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id tqBljnerxLno for ; Fri, 5 Jan 2018 07:54:41 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 5A37D84CDD for ; Fri, 5 Jan 2018 07:54:41 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 7CF74FBDE; Fri, 5 Jan 2018 07:54:39 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_151513887967720" MIME-Version: 1.0 Date: Fri, 5 Jan 2018 07:54:39 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/mk To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20180105075439.7CF74FBDE@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_151513887967720 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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. --_----------=_151513887967720 Content-Disposition: inline Content-Length: 1995 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii 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; \ \ --_----------=_151513887967720--