package: Remove false positive lic warnings
RFC PATCH 1/3 package: Remove false positive lic warnings
The recipe LICENSE strings are split into their individual license and the canonicalised to easy enable matching with licenses of sources. License strings with "or-later" are replaced with "+" before comparism.
The warnings showup if and only if licenses in the sources don't match LICENSE value of the recipe.
--- meta/classes/package.bbclass | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
meta/classes/package.bbclass +16 -1
@@ -1545,6 +1545,7 @@ PKGDESTWORK = "${WORKDIR}/pkgdata" PKGDATA_VARS = "PN PE PV PR PKGE PKGV PKGR LICENSE DESCRIPTION SUMMARY RDEPENDS RPROVIDES RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS SECTION PKG ALLOW_EMPTY FILES CONFFILES FILES_INFO PACKAGE_ADD_METADATA pkg_postinst pkg_postrm pkg_preinst pkg_prerm" python emit_pkgdata() { + import oe.license from glob import glob import json import subprocess
@@ -1762,7 +1763,21 @@ fi lic = d.getVar('LICENSE_%s' % (pkg)) if not lic: lic = d.getVar('LICENSE') - bb.warn("License for package %s is %s vs %s" % (pkg, computedpkglics[pkg], lic)) + + # Splits the LICENSE values and canonicalise each license + # in the set of split license(s) + split_lic = oe.license.list_licenses(lic) + spdx_lic = set([canonical_license(d, l) for l in split_lic]) + if computedpkglics[pkg]: + computedpkglicsperpkg = set([]) + for l in computedpkglics[pkg]: + if l.endswith('-or-later'): + lic_ = l.replace('-or-later', '+') + computedpkglicsperpkg.add(lic_) + else: + computedpkglicsperpkg.add(l) + if spdx_lic - computedpkglicsperpkg: + bb.warn("License for package %s is %s vs %s" % (pkg, computedpkglicsperpkg, spdx_lic)) } emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides"
Signature · 1 line
2.25.1
RFC PATCH 2/3 package: Remove false positive lic warnings
With the IGNOREWITHLINUXSYSCALLNOTE variable set to "1" in local.conf, it removes the "WITH Linux syscall note" string attached to the license value for sources before comparism. This is to get more recipe LICENSES to match with those of the sources and reduce the number of warnings outputed.
--- meta/classes/package.bbclass | 4 ++++ 1 file changed, 4 insertions(+)
meta/classes/package.bbclass +4 -0
@@ -1774,6 +1774,10 @@ fi if l.endswith('-or-later'): lic_ = l.replace('-or-later', '+') computedpkglicsperpkg.add(lic_) + elif l.endswith(' WITH Linux-syscall-note'): + if d.getVar("IGNOREWITHLINUXSYSCALLNOTE") == "1": + lic_ = l.replace(' WITH Linux-syscall-note', '') + computedpkglicsperpkg.add(lic_) else: computedpkglicsperpkg.add(l) if spdx_lic - computedpkglicsperpkg:
Signature · 1 line
2.25.1
RFC PATCH 3/3 package: Remove false positive lic warnings
In reply to Meh Mbeh Ida DelphineAdded text to distinguish licenses from sources and those from recipes when warnings are outputed.
--- meta/classes/package.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/package.bbclass +2 -1
@@ -1780,8 +1780,9 @@ fi computedpkglicsperpkg.add(lic_) else: computedpkglicsperpkg.add(l) + # Displays warnings for licenses found in the recipes and not sources if spdx_lic - computedpkglicsperpkg: - bb.warn("License for package %s is %s vs %s" % (pkg, computedpkglicsperpkg, spdx_lic)) + bb.warn("License for package %s is %s (source SPDX headers) vs %s (LICENSE)" % (pkg, computedpkglicsperpkg, spdx_lic)) } emit_pkgdata[dirs] = "${PKGDESTWORK}/runtime ${PKGDESTWORK}/runtime-reverse ${PKGDESTWORK}/runtime-rprovides"
Signature · 1 line
2.25.1