Skip to contentSkip to conversation

classes: base|package: check pkgs lics are subset of recipe lics only once

PATCH Superseded Quentin Schulz 2 participants 2 messages Apr 16, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes: base|package: check pkgs lics are subset of recipe lics only once

Yocto bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=10130

Move logic checking that all packages licenses are only a subset of recipe licenses from base.bbclass to the package.bbclass so that it's evaluated only once, during packaging.

As explained in the linked bugzilla entry, if a package license is not part of the recipe license, the warning message gets shown an unreasonable amount of time because it's evaluated every time a recipe is parsed.

---

- We may not want this patch if we find it important that this warning is displayed at parsing time and not only after packaging has been done (which means dryruns aren't going to detect this issue anymore).
- Do we want separate patches for each class?
- The original bug report isn't very explicit, so hopefully I'm actually fixing it :) adding Paul, the reporter, in Cc so he can confirm.

 meta/classes/base.bbclass    | 13 -------------
 meta/classes/package.bbclass | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 14 deletions(-)
meta/classes/base.bbclass +0 -13
index 45f9435fd8..7aa2e144eb 100644
@@ -584,19 +584,6 @@ python () {
                         bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
                         raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
 
-        # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a
-        # superset of all per-package licenses. We do not do advanced (pattern)
-        # matching of license expressions - just check that all license strings
-        # in LICENSE_<pkg> are found in LICENSE.
-        license_set = oe.license.list_licenses(license)
-        for pkg in d.getVar('PACKAGES').split():
-            pkg_license = d.getVar('LICENSE_' + pkg)
-            if pkg_license:
-                unlisted = oe.license.list_licenses(pkg_license) - license_set
-                if unlisted:
-                    bb.warn("LICENSE_%s includes licenses (%s) that are not "
-                            "listed in LICENSE" % (pkg, ' '.join(unlisted)))
-
     needsrcrev = False
     srcuri = d.getVar('SRC_URI')
     for uri in srcuri.split():
meta/classes/package.bbclass +12 -1
index d4c6a90e84..1e87108e43 100644
@@ -1322,9 +1322,20 @@ python populate_packages () {
     os.umask(oldumask)
     os.chdir(workdir)
 
-    # Handle LICENSE_EXCLUSION
+    license_set = oe.license.list_licenses(d.getVar('LICENSE'))
     package_list = []
     for pkg in packages:
+        # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a
+        # superset of all per-package licenses. We do not do advanced (pattern)
+        # matching of license expressions - just check that all license strings
+        # in LICENSE_<pkg> are found in LICENSE.
+        pkg_license = d.getVar('LICENSE_' + pkg)
+        if pkg_license:
+            unlisted = oe.license.list_licenses(pkg_license) - license_set
+            if unlisted:
+                bb.warn("LICENSE_%s includes licenses (%s) that are not "
+                        "listed in LICENSE" % (pkg, ' '.join(unlisted)))
+        # Handle LICENSE_EXCLUSION
         licenses = d.getVar('LICENSE_EXCLUSION-' + pkg)
         if licenses:
             msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 65 lines · Quentin Schulz

Yocto bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=10130

Move logic checking that all packages licenses are only a subset of recipe licenses from base.bbclass to the package.bbclass so that it's evaluated only once, during packaging.

As explained in the linked bugzilla entry, if a package license is not part of the recipe license, the warning message gets shown an unreasonable amount of time because it's evaluated every time a recipe is parsed.

---

- We may not want this patch if we find it important that this warning is displayed at parsing time and not only after packaging has been done (which means dryruns aren't going to detect this issue anymore).
- Do we want separate patches for each class?
- The original bug report isn't very explicit, so hopefully I'm actually fixing it :) adding Paul, the reporter, in Cc so he can confirm.

 meta/classes/base.bbclass    | 13 -------------
 meta/classes/package.bbclass | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 14 deletions(-)
meta/classes/base.bbclass +0 -13
index 45f9435fd8..7aa2e144eb 100644
@@ -584,19 +584,6 @@ python () {
                         bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
                         raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
 
-        # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a
-        # superset of all per-package licenses. We do not do advanced (pattern)
-        # matching of license expressions - just check that all license strings
-        # in LICENSE_<pkg> are found in LICENSE.
-        license_set = oe.license.list_licenses(license)
-        for pkg in d.getVar('PACKAGES').split():
-            pkg_license = d.getVar('LICENSE_' + pkg)
-            if pkg_license:
-                unlisted = oe.license.list_licenses(pkg_license) - license_set
-                if unlisted:
-                    bb.warn("LICENSE_%s includes licenses (%s) that are not "
-                            "listed in LICENSE" % (pkg, ' '.join(unlisted)))
-
     needsrcrev = False
     srcuri = d.getVar('SRC_URI')
     for uri in srcuri.split():
meta/classes/package.bbclass +5 -1
index d4c6a90e84..1e87108e43 100644
@@ -1322,9 +1322,20 @@ python populate_packages () {
     os.umask(oldumask)
     os.chdir(workdir)
 
-    # Handle LICENSE_EXCLUSION
+    license_set = oe.license.list_licenses(d.getVar('LICENSE'))
     package_list = []
     for pkg in packages:
+        # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a
+        # superset of all per-package licenses. We do not do advanced (pattern)
+        # matching of license expressions - just check that all license strings
+        # in LICENSE_<pkg> are found in LICENSE.

meta/classes/package.bbclass python populate_packages () { · line 1341

Quoted 10 lines
meta/classes/package.bbclass +7 -0
+        pkg_license = d.getVar('LICENSE_' + pkg)
+        if pkg_license:
+            unlisted = oe.license.list_licenses(pkg_license) - license_set
+            if unlisted:
+                bb.warn("LICENSE_%s includes licenses (%s) that are not "
+                        "listed in LICENSE" % (pkg, ' '.join(unlisted)))
+        # Handle LICENSE_EXCLUSION
         licenses = d.getVar('LICENSE_EXCLUSION-' + pkg)
         if licenses:
             msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)

I think that this check really belongs in insane.bbclass as its a validation checking issue. I'd love to move this away from parse time and to runtime only! I do think its something for the insane class framework where we can configure it to warn or error for example.

Cheers,

Richard