blob: 6279d7424597138719b698c5492340e1bb93c981 [file] [log] [blame]
Brad Bishop15ae2502019-06-18 21:44:24 -04001from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import bitbake
3
Andrew Geissler9aee5002022-03-30 16:27:02 +00004class IncompatibleLicenseTestObsolete(OESelftestTestCase):
5
6 def lic_test(self, pn, pn_lic, lic, error_msg=None):
7 if not error_msg:
8 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic)
9
10 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic))
11
12 result = bitbake('%s --dry-run' % (pn), ignore_status=True)
13 if error_msg not in result.output:
14 raise AssertionError(result.output)
15
16 # Verify that a package with an SPDX license cannot be built when
17 # INCOMPATIBLE_LICENSE contains an alias (in SPDXLICENSEMAP) of this SPDX
18 # license
19 def test_incompatible_alias_spdx_license(self):
20 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE")
21
22 # Verify that a package with an SPDX license cannot be built when
23 # INCOMPATIBLE_LICENSE contains a wildcarded alias license matching this
24 # SPDX license
25 def test_incompatible_alias_spdx_license_wildcard(self):
26 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry")
27
28 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
29 # license cannot be built when INCOMPATIBLE_LICENSE contains this alias
30 def test_incompatible_alias_spdx_license_alias(self):
31 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE")
32
33 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
34 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
35 # license matching this SPDX license
36 def test_incompatible_spdx_license_alias_wildcard(self):
37 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0', "*GPL-3.0 is an invalid license wildcard entry")
38
39 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
40 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
41 # alias license matching the SPDX license
42 def test_incompatible_alias_spdx_license_alias_wildcard(self):
43 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry")
44
45
46 # Verify that a package with multiple SPDX licenses cannot be built when
47 # INCOMPATIBLE_LICENSE contains a wildcard to some of them
48 def test_incompatible_spdx_licenses_wildcard(self):
49 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")
50
51
52 # Verify that a package with multiple SPDX licenses cannot be built when
53 # INCOMPATIBLE_LICENSE contains a wildcard matching all licenses
54 def test_incompatible_all_licenses_wildcard(self):
55 self.lic_test('incompatible-licenses', 'GPL-2.0-only GPL-3.0-only LGPL-3.0-only', '*', "* is an invalid license wildcard entry")
56
Brad Bishop15ae2502019-06-18 21:44:24 -040057class IncompatibleLicenseTests(OESelftestTestCase):
58
59 def lic_test(self, pn, pn_lic, lic):
Andrew Geissler82c905d2020-04-13 13:39:40 -050060 error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic)
Brad Bishop15ae2502019-06-18 21:44:24 -040061
62 self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic))
63
64 result = bitbake('%s --dry-run' % (pn), ignore_status=True)
65 if error_msg not in result.output:
66 raise AssertionError(result.output)
67
Andrew Geissler9aee5002022-03-30 16:27:02 +000068 # Verify that a package with an SPDX license cannot be built when
69 # INCOMPATIBLE_LICENSE contains this SPDX license
Brad Bishop15ae2502019-06-18 21:44:24 -040070 def test_incompatible_spdx_license(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060071 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0-only')
Brad Bishop15ae2502019-06-18 21:44:24 -040072
Andrew Geissler9aee5002022-03-30 16:27:02 +000073 # Verify that a package with an SPDX license cannot be built when
74 # INCOMPATIBLE_LICENSE contains a wildcarded license matching this SPDX
75 # license
Andrew Geissler82c905d2020-04-13 13:39:40 -050076 def test_incompatible_spdx_license_wildcard(self):
Andrew Geissler9aee5002022-03-30 16:27:02 +000077 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0*')
Andrew Geissler82c905d2020-04-13 13:39:40 -050078
Brad Bishop15ae2502019-06-18 21:44:24 -040079 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
80 # license cannot be built when INCOMPATIBLE_LICENSE contains this SPDX
81 # license
82 def test_incompatible_spdx_license_alias(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060083 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPL-3.0-only')
Brad Bishop15ae2502019-06-18 21:44:24 -040084
Andrew Geissler9aee5002022-03-30 16:27:02 +000085 # Verify that a package with multiple SPDX licenses cannot be built when
86 # INCOMPATIBLE_LICENSE contains some of them
Andrew Geissler82c905d2020-04-13 13:39:40 -050087 def test_incompatible_spdx_licenses(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060088 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', 'GPL-3.0-only LGPL-3.0-only')
Andrew Geissler82c905d2020-04-13 13:39:40 -050089
Andrew Geissler9aee5002022-03-30 16:27:02 +000090 # Verify that a package with a non-SPDX license cannot be built when
Brad Bishop15ae2502019-06-18 21:44:24 -040091 # INCOMPATIBLE_LICENSE contains this license
92 def test_incompatible_nonspdx_license(self):
93 self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense')
Brad Bishopf3f93bb2019-10-16 14:33:32 -040094
95class IncompatibleLicensePerImageTests(OESelftestTestCase):
96 def default_config(self):
97 return """
Patrick Williams213cb262021-08-07 19:21:33 -050098IMAGE_INSTALL:append = " bash"
Andrew Geissler9aee5002022-03-30 16:27:02 +000099INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*"
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400100"""
101
102 def test_bash_default(self):
103 self.write_config(self.default_config())
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600104 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"
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400105
106 result = bitbake('core-image-minimal', ignore_status=True)
107 if error_msg not in result.output:
108 raise AssertionError(result.output)
109
110 def test_bash_and_license(self):
Patrick Williams213cb262021-08-07 19:21:33 -0500111 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"')
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600112 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"
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400113
114 result = bitbake('core-image-minimal', ignore_status=True)
115 if error_msg not in result.output:
116 raise AssertionError(result.output)
117
118 def test_bash_or_license(self):
Patrick Williams213cb262021-08-07 19:21:33 -0500119 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " | SomeLicense"')
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400120
121 bitbake('core-image-minimal')
122
Andrew Geissler9aee5002022-03-30 16:27:02 +0000123 def test_bash_license_exceptions(self):
124 self.write_config(self.default_config() + '\nINCOMPATIBLE_LICENSE_EXCEPTIONS:pn-core-image-minimal = "bash:GPL-3.0-or-later"')
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400125
126 bitbake('core-image-minimal')
127
Brad Bishop64c979e2019-11-04 13:55:29 -0500128class NoGPL3InImagesTests(OESelftestTestCase):
129 def test_core_image_minimal(self):
130 self.write_config("""
Andrew Geissler9aee5002022-03-30 16:27:02 +0000131INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*"
Brad Bishop64c979e2019-11-04 13:55:29 -0500132""")
133 bitbake('core-image-minimal')
134
Patrick Williams213cb262021-08-07 19:21:33 -0500135 def test_core_image_full_cmdline_weston(self):
Brad Bishop64c979e2019-11-04 13:55:29 -0500136 self.write_config("""
Patrick Williams213cb262021-08-07 19:21:33 -0500137INHERIT += "testimage"
Andrew Geissler9aee5002022-03-30 16:27:02 +0000138INCOMPATIBLE_LICENSE:pn-core-image-full-cmdline = "GPL-3.0* LGPL-3.0*"
139INCOMPATIBLE_LICENSE:pn-core-image-weston = "GPL-3.0* LGPL-3.0*"
Patrick Williams213cb262021-08-07 19:21:33 -0500140# Settings for full-cmdline
141RDEPENDS: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"
142RDEPENDS:packagegroup-core-full-cmdline-dev-utils:remove = "diffutils m4 make patch"
143RDEPENDS:packagegroup-core-full-cmdline-multiuser:remove = "gzip"
144# Settings for weston
145# direct gpl3 dependencies
146RRECOMMENDS:packagegroup-base-vfat:remove = "dosfstools"
147PACKAGECONFIG:remove:pn-bluez5 = "readline"
148# dnf pulls in gpg which is gpl3; it also pulls in python3-rpm which pulls in rpm-build which pulls in bash
149# so install rpm but not dnf
150IMAGE_FEATURES:remove:pn-core-image-weston = "package-management"
151CORE_IMAGE_EXTRA_INSTALL:pn-core-image-weston += "rpm"
152# matchbox-terminal depends on vte, which is gpl3
153CORE_IMAGE_BASE_INSTALL:remove:pn-core-image-weston = "matchbox-terminal"
Brad Bishop64c979e2019-11-04 13:55:29 -0500154""")
Patrick Williams213cb262021-08-07 19:21:33 -0500155 bitbake('core-image-full-cmdline core-image-weston')
156 bitbake('-c testimage core-image-full-cmdline core-image-weston')
Brad Bishop64c979e2019-11-04 13:55:29 -0500157