<div dir="ltr"><div>It wouldn&#39;t be too hard to add a condition that checks the (image-specific) whitelist, I just wanted to gather a bit of feedback for the overall idea :)</div><div><br></div><div>Alex<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 9 Oct 2019 at 20:15, Christopher Larson &lt;<a href="mailto:kergoth@gmail.com">kergoth@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Does this obey the whitelist? Can I whitelist a gplv3 package to get it installed, ideally with a warning rather than silent or error? I don&#39;t have the code in front of me at the moment. I have a class in meta-mentor that does this sort of check, so wanted to see how the implementations compare. On a related note, <a href="https://github.com/MentorEmbedded/meta-mentor/blob/master/meta-mentor-common/classes/incompatible-recipe-check.bbclass" target="_blank">https://github.com/MentorEmbedded/meta-mentor/blob/master/meta-mentor-common/classes/incompatible-recipe-check.bbclass</a> + <a href="https://github.com/MentorEmbedded/meta-mentor/blob/95d05dcc12651a7b246f91b240120f92d196b0de/meta-mel-support/recipes-core/packagegroups/packagegroup-tools-benchmark.bb#L10" target="_blank">https://github.com/MentorEmbedded/meta-mentor/blob/95d05dcc12651a7b246f91b240120f92d196b0de/meta-mel-support/recipes-core/packagegroups/packagegroup-tools-benchmark.bb#L10</a> might be of interest to you in your gplv2 work, perhaps? Specifically handling the whitelisting.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 9, 2019 at 8:45 AM Alexander Kanavin &lt;<a href="mailto:alex.kanavin@gmail.com" target="_blank">alex.kanavin@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The use case is setting INCOMPATIBLE_LICENSE per image,<br>
rather than as an awkward, and too strict global setting.<br>
<br>
This for example would allow building development images with gplv3 tools,<br>
but production images without them, and checking that nothing gpl3-licensed<br>
gets into the latter.<br>
<br>
Examples are provided via the selftest: three scenarios are tested:<br>
<br>
- bash is added to the image, with a default gpl3 license; this is rejected<br>
- bash is added to the image, with a &quot;gpl3 &amp; other&quot; license; this is also rejected<br>
- bash is added to the image, with a &quot;gpl3 | other&quot; license; this is accepted, but<br>
only &#39;other&#39; is added to the license manifest (this was already handled correctly<br>
previously).<br>
<br>
Eventually, this would allow deprecating the meta-gplv2 layer, while still<br>
enforcing the no-gpl3 rule where possible and needed.<br>
<br>
Signed-off-by: Alexander Kanavin &lt;<a href="mailto:alex.kanavin@gmail.com" target="_blank">alex.kanavin@gmail.com</a>&gt;<br>
---<br>
 meta/classes/license_image.bbclass            |  2 ++<br>
 .../oeqa/selftest/cases/incompatible_lic.py   | 29 +++++++++++++++++++<br>
 2 files changed, 31 insertions(+)<br>
<br>
diff --git a/meta/classes/license_image.bbclass b/meta/classes/license_image.bbclass<br>
index 3f102d0fbc3..e5cb1b8c77d 100644<br>
--- a/meta/classes/license_image.bbclass<br>
+++ b/meta/classes/license_image.bbclass<br>
@@ -47,6 +47,8 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):<br>
         for pkg in sorted(pkg_dic):<br>
             if bad_licenses:<br>
                 try:<br>
+                    if incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg][&quot;LICENSE&quot;]):<br>
+                        bb.fatal(&quot;Package %s has an incompatible license %s and cannot be installed into the image.&quot; %(pkg, pkg_dic[pkg][&quot;LICENSE&quot;]))<br>
                     (pkg_dic[pkg][&quot;LICENSE&quot;], pkg_dic[pkg][&quot;LICENSES&quot;]) = \<br>
                         oe.license.manifest_licenses(pkg_dic[pkg][&quot;LICENSE&quot;],<br>
                         bad_licenses, canonical_license, d)<br>
diff --git a/meta/lib/oeqa/selftest/cases/incompatible_lic.py b/meta/lib/oeqa/selftest/cases/incompatible_lic.py<br>
index 8fb93af8a89..e80c9783122 100644<br>
--- a/meta/lib/oeqa/selftest/cases/incompatible_lic.py<br>
+++ b/meta/lib/oeqa/selftest/cases/incompatible_lic.py<br>
@@ -39,3 +39,32 @@ class IncompatibleLicenseTests(OESelftestTestCase):<br>
     # INCOMPATIBLE_LICENSE contains this license<br>
     def test_incompatible_nonspdx_license(self):<br>
         self.lic_test(&#39;incompatible-nonspdx-license&#39;, &#39;FooLicense&#39;, &#39;FooLicense&#39;)<br>
+<br>
+class IncompatibleLicensePerImageTests(OESelftestTestCase):<br>
+    def default_config(self):<br>
+        return &quot;&quot;&quot;<br>
+IMAGE_INSTALL_append = &quot;bash&quot;<br>
+INCOMPATIBLE_LICENSE_pn-core-image-minimal = &quot;GPL-3.0 LGPL-3.0&quot;<br>
+&quot;&quot;&quot;<br>
+<br>
+    def test_bash_default(self):<br>
+        self.write_config(self.default_config())<br>
+        error_msg = &quot;ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash has an incompatible license GPLv3+ and cannot be installed into the image.&quot;<br>
+<br>
+        result = bitbake(&#39;core-image-minimal&#39;, ignore_status=True)<br>
+        if error_msg not in result.output:<br>
+            raise AssertionError(result.output)<br>
+<br>
+    def test_bash_and_license(self):<br>
+        self.write_config(self.default_config() + &#39;\nLICENSE_append_pn-bash = &quot; &amp; SomeLicense&quot;&#39;)<br>
+        error_msg = &quot;ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash has an incompatible license GPLv3+ &amp; SomeLicense and cannot be installed into the image.&quot;<br>
+<br>
+        result = bitbake(&#39;core-image-minimal&#39;, ignore_status=True)<br>
+        if error_msg not in result.output:<br>
+            raise AssertionError(result.output)<br>
+<br>
+    def test_bash_or_license(self):<br>
+        self.write_config(self.default_config() + &#39;\nLICENSE_append_pn-bash = &quot; | SomeLicense&quot;&#39;)<br>
+<br>
+        bitbake(&#39;core-image-minimal&#39;)<br>
+<br>
-- <br>
2.17.1<br>
<br>
-- <br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr">Christopher Larson<br>kergoth at gmail dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Senior Software Engineer, Mentor Graphics</div></div></div></div>
</blockquote></div>