summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/incompatible_lic.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/incompatible_lic.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/incompatible_lic.py139
1 files changed, 78 insertions, 61 deletions
diff --git a/meta/lib/oeqa/selftest/cases/incompatible_lic.py b/meta/lib/oeqa/selftest/cases/incompatible_lic.py
index 152da6332a..f4af67a239 100644
--- a/meta/lib/oeqa/selftest/cases/incompatible_lic.py
+++ b/meta/lib/oeqa/selftest/cases/incompatible_lic.py
@@ -1,10 +1,16 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
1from oeqa.selftest.case import OESelftestTestCase 6from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import bitbake 7from oeqa.utils.commands import bitbake
3 8
4class IncompatibleLicenseTests(OESelftestTestCase): 9class IncompatibleLicenseTestObsolete(OESelftestTestCase):
5 10
6 def lic_test(self, pn, pn_lic, lic): 11 def lic_test(self, pn, pn_lic, lic, error_msg=None):
7 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic) 12 if not error_msg:
13 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic)
8 14
9 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic)) 15 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic))
10 16
@@ -12,72 +18,81 @@ class IncompatibleLicenseTests(OESelftestTestCase):
12 if error_msg not in result.output: 18 if error_msg not in result.output:
13 raise AssertionError(result.output) 19 raise AssertionError(result.output)
14 20
15 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) 21 # Verify that a package with an SPDX license cannot be built when
16 # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license 22 # INCOMPATIBLE_LICENSE contains an alias (in SPDXLICENSEMAP) of this SPDX
17 def test_incompatible_spdx_license(self): 23 # license
18 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0-only')
19
20 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES)
21 # cannot be built when INCOMPATIBLE_LICENSE contains an alias (in
22 # SPDXLICENSEMAP) of this SPDX license
23 def test_incompatible_alias_spdx_license(self): 24 def test_incompatible_alias_spdx_license(self):
24 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3') 25 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE")
25
26 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES)
27 # cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded license
28 # matching this SPDX license
29 def test_incompatible_spdx_license_wildcard(self):
30 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPL-3.0-only')
31 26
32 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) 27 # Verify that a package with an SPDX license cannot be built when
33 # cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded alias 28 # INCOMPATIBLE_LICENSE contains a wildcarded alias license matching this
34 # license matching this SPDX license 29 # SPDX license
35 def test_incompatible_alias_spdx_license_wildcard(self): 30 def test_incompatible_alias_spdx_license_wildcard(self):
36 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3') 31 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry")
37
38 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
39 # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX
40 # license
41 def test_incompatible_spdx_license_alias(self):
42 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPL-3.0-only')
43 32
44 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX 33 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
45 # license cannot be built when INCOMPATIBLE_LICENSE contains this alias 34 # license cannot be built when INCOMPATIBLE_LICENSE contains this alias
46 def test_incompatible_alias_spdx_license_alias(self): 35 def test_incompatible_alias_spdx_license_alias(self):
47 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3') 36 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE")
48 37
49 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX 38 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
50 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded 39 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
51 # license matching this SPDX license 40 # license matching this SPDX license
52 def test_incompatible_spdx_license_alias_wildcard(self): 41 def test_incompatible_spdx_license_alias_wildcard(self):
53 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0') 42 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0', "*GPL-3.0 is an invalid license wildcard entry")
54 43
55 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX 44 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
56 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded 45 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
57 # alias license matching the SPDX license 46 # alias license matching the SPDX license
58 def test_incompatible_alias_spdx_license_alias_wildcard(self): 47 def test_incompatible_alias_spdx_license_alias_wildcard(self):
59 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3') 48 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry")
60 49
61 # Verify that a package with multiple SPDX licenses (from
62 # AVAILABLE_LICENSES) cannot be built when INCOMPATIBLE_LICENSE contains
63 # some of them
64 def test_incompatible_spdx_licenses(self):
65 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', 'GPL-3.0-only LGPL-3.0-only')
66 50
67 # Verify that a package with multiple SPDX licenses (from 51 # Verify that a package with multiple SPDX licenses cannot be built when
68 # AVAILABLE_LICENSES) cannot be built when INCOMPATIBLE_LICENSE contains a 52 # INCOMPATIBLE_LICENSE contains a wildcard to some of them
69 # wildcard to some of them
70 def test_incompatible_spdx_licenses_wildcard(self): 53 def test_incompatible_spdx_licenses_wildcard(self):
71 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', '*GPL-3.0-only') 54 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', '*GPL-3.0-only', "*GPL-3.0-only is an invalid license wildcard entry")
72 55
73 # Verify that a package with multiple SPDX licenses (from 56
74 # AVAILABLE_LICENSES) cannot be built when INCOMPATIBLE_LICENSE contains a 57 # Verify that a package with multiple SPDX licenses cannot be built when
75 # wildcard matching all licenses 58 # INCOMPATIBLE_LICENSE contains a wildcard matching all licenses
76 def test_incompatible_all_licenses_wildcard(self): 59 def test_incompatible_all_licenses_wildcard(self):
77 self.lic_test('incompatible-licenses', 'GPL-2.0-only GPL-3.0-only LGPL-3.0-only', '*') 60 self.lic_test('incompatible-licenses', 'GPL-2.0-only GPL-3.0-only LGPL-3.0-only', '*', "* is an invalid license wildcard entry")
61
62class IncompatibleLicenseTests(OESelftestTestCase):
63
64 def lic_test(self, pn, pn_lic, lic):
65 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic)
66
67 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic))
68
69 result = bitbake('%s --dry-run' % (pn), ignore_status=True)
70 if error_msg not in result.output:
71 raise AssertionError(result.output)
72
73 # Verify that a package with an SPDX license cannot be built when
74 # INCOMPATIBLE_LICENSE contains this SPDX license
75 def test_incompatible_spdx_license(self):
76 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0-only')
78 77
79 # Verify that a package with a non-SPDX license (neither in 78 # Verify that a package with an SPDX license cannot be built when
80 # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when 79 # INCOMPATIBLE_LICENSE contains a wildcarded license matching this SPDX
80 # license
81 def test_incompatible_spdx_license_wildcard(self):
82 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0*')
83
84 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
85 # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX
86 # license
87 def test_incompatible_spdx_license_alias(self):
88 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPL-3.0-only')
89
90 # Verify that a package with multiple SPDX licenses cannot be built when
91 # INCOMPATIBLE_LICENSE contains some of them
92 def test_incompatible_spdx_licenses(self):
93 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', 'GPL-3.0-only LGPL-3.0-only')
94
95 # Verify that a package with a non-SPDX license cannot be built when
81 # INCOMPATIBLE_LICENSE contains this license 96 # INCOMPATIBLE_LICENSE contains this license
82 def test_incompatible_nonspdx_license(self): 97 def test_incompatible_nonspdx_license(self):
83 self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense') 98 self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense')
@@ -85,8 +100,8 @@ class IncompatibleLicenseTests(OESelftestTestCase):
85class IncompatibleLicensePerImageTests(OESelftestTestCase): 100class IncompatibleLicensePerImageTests(OESelftestTestCase):
86 def default_config(self): 101 def default_config(self):
87 return """ 102 return """
88IMAGE_INSTALL_append = " bash" 103IMAGE_INSTALL:append = " bash"
89INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0" 104INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*"
90""" 105"""
91 106
92 def test_bash_default(self): 107 def test_bash_default(self):
@@ -98,7 +113,8 @@ INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
98 raise AssertionError(result.output) 113 raise AssertionError(result.output)
99 114
100 def test_bash_and_license(self): 115 def test_bash_and_license(self):
101 self.write_config(self.default_config() + '\nLICENSE_append_pn-bash = " & SomeLicense"') 116 self.disable_class("create-spdx")
117 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"')
102 error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash cannot be installed into the image because it has incompatible license(s): GPL-3.0-or-later" 118 error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash cannot be installed into the image because it has incompatible license(s): GPL-3.0-or-later"
103 119
104 result = bitbake('core-image-minimal', ignore_status=True) 120 result = bitbake('core-image-minimal', ignore_status=True)
@@ -106,30 +122,31 @@ INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
106 raise AssertionError(result.output) 122 raise AssertionError(result.output)
107 123
108 def test_bash_or_license(self): 124 def test_bash_or_license(self):
109 self.write_config(self.default_config() + '\nLICENSE_append_pn-bash = " | SomeLicense"') 125 self.disable_class("create-spdx")
126 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " | SomeLicense"')
110 127
111 bitbake('core-image-minimal') 128 bitbake('core-image-minimal')
112 129
113 def test_bash_whitelist(self): 130 def test_bash_license_exceptions(self):
114 self.write_config(self.default_config() + '\nWHITELIST_GPL-3.0_pn-core-image-minimal = "bash"') 131 self.write_config(self.default_config() + '\nINCOMPATIBLE_LICENSE_EXCEPTIONS:pn-core-image-minimal = "bash:GPL-3.0-or-later"')
115 132
116 bitbake('core-image-minimal') 133 bitbake('core-image-minimal')
117 134
118class NoGPL3InImagesTests(OESelftestTestCase): 135class NoGPL3InImagesTests(OESelftestTestCase):
119 def test_core_image_minimal(self): 136 def test_core_image_minimal(self):
120 self.write_config(""" 137 self.write_config("""
121INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0" 138INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*"
122""") 139""")
123 bitbake('core-image-minimal') 140 bitbake('core-image-minimal')
124 141
125 def test_core_image_full_cmdline(self): 142 def test_core_image_full_cmdline_weston(self):
126 self.write_config(""" 143 self.write_config("""
127INHERIT += "testimage"\n 144IMAGE_CLASSES += "testimage"
128INCOMPATIBLE_LICENSE_pn-core-image-full-cmdline = "GPL-3.0 LGPL-3.0"\n 145INCOMPATIBLE_LICENSE:pn-core-image-full-cmdline = "GPL-3.0* LGPL-3.0*"
129RDEPENDS_packagegroup-core-full-cmdline-utils_remove = "bash bc coreutils cpio ed findutils gawk grep mc mc-fish mc-helpers mc-helpers-perl sed tar time"\n 146INCOMPATIBLE_LICENSE:pn-core-image-weston = "GPL-3.0* LGPL-3.0*"
130RDEPENDS_packagegroup-core-full-cmdline-dev-utils_remove = "diffutils m4 make patch"\n 147
131RDEPENDS_packagegroup-core-full-cmdline-multiuser_remove = "gzip"\n 148require conf/distro/include/no-gplv3.inc
132""") 149""")
133 bitbake('core-image-full-cmdline') 150 bitbake('core-image-full-cmdline core-image-weston')
134 bitbake('-c testimage core-image-full-cmdline') 151 bitbake('-c testimage core-image-full-cmdline core-image-weston')
135 152