blob: 904b5b4094a264a6eebc26a7a083086d79d135ab [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import bitbake
3
4class IncompatibleLicenseTests(OESelftestTestCase):
5
6 def lic_test(self, pn, pn_lic, lic):
7 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has an incompatible license: %s' % (pn, pn, pn_lic)
8
9 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic))
10
11 result = bitbake('%s --dry-run' % (pn), ignore_status=True)
12 if error_msg not in result.output:
13 raise AssertionError(result.output)
14
15 # Verify that a package with an SPDX license (from SRC_DISTRIBUTE_LICENSES)
16 # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license
17 def test_incompatible_spdx_license(self):
18 self.lic_test('incompatible-license', 'GPL-3.0', 'GPL-3.0')
19
20 # Verify that a package with an SPDX license (from SRC_DISTRIBUTE_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 self.lic_test('incompatible-license', 'GPL-3.0', 'GPLv3')
25
26 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
27 # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX
28 # license
29 def test_incompatible_spdx_license_alias(self):
30 self.lic_test('incompatible-license-alias', 'GPLv3', 'GPL-3.0')
31
32 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
33 # license cannot be built when INCOMPATIBLE_LICENSE contains this alias
34 def test_incompatible_alias_spdx_license_alias(self):
35 self.lic_test('incompatible-license-alias', 'GPLv3', 'GPLv3')
36
37 # Verify that a package with a non-SPDX license (neither in
38 # SRC_DISTRIBUTE_LICENSES nor in SPDXLICENSEMAP) cannot be built when
39 # INCOMPATIBLE_LICENSE contains this license
40 def test_incompatible_nonspdx_license(self):
41 self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense')
Brad Bishopf3f93bb2019-10-16 14:33:32 -040042
43class IncompatibleLicensePerImageTests(OESelftestTestCase):
44 def default_config(self):
45 return """
46IMAGE_INSTALL_append = "bash"
47INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
48"""
49
50 def test_bash_default(self):
51 self.write_config(self.default_config())
52 error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash has an incompatible license GPLv3+ and cannot be installed into the image."
53
54 result = bitbake('core-image-minimal', ignore_status=True)
55 if error_msg not in result.output:
56 raise AssertionError(result.output)
57
58 def test_bash_and_license(self):
59 self.write_config(self.default_config() + '\nLICENSE_append_pn-bash = " & SomeLicense"')
60 error_msg = "ERROR: core-image-minimal-1.0-r0 do_rootfs: Package bash has an incompatible license GPLv3+ & SomeLicense and cannot be installed into the image."
61
62 result = bitbake('core-image-minimal', ignore_status=True)
63 if error_msg not in result.output:
64 raise AssertionError(result.output)
65
66 def test_bash_or_license(self):
67 self.write_config(self.default_config() + '\nLICENSE_append_pn-bash = " | SomeLicense"')
68
69 bitbake('core-image-minimal')
70
71 def test_bash_whitelist(self):
72 self.write_config(self.default_config() + '\nWHITELIST_GPL-3.0_pn-core-image-minimal = "bash"')
73
74 bitbake('core-image-minimal')
75
Brad Bishop64c979e2019-11-04 13:55:29 -050076class NoGPL3InImagesTests(OESelftestTestCase):
77 def test_core_image_minimal(self):
78 self.write_config("""
79INCOMPATIBLE_LICENSE_pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
80""")
81 bitbake('core-image-minimal')
82
83 def test_core_image_full_cmdline(self):
84 self.write_config("""
85INHERIT += "testimage"\n
86INCOMPATIBLE_LICENSE_pn-core-image-full-cmdline = "GPL-3.0 LGPL-3.0"\n
87RDEPENDS_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
88RDEPENDS_packagegroup-core-full-cmdline-dev-utils_remove = "diffutils m4 make patch"\n
89RDEPENDS_packagegroup-core-full-cmdline-multiuser_remove = "gzip"\n
90""")
91 bitbake('core-image-full-cmdline')
92 bitbake('-c testimage core-image-full-cmdline')
93