blob: fd3b3f409e3f0b59c6b9c1cf87402dba7610b4ae [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):
Andrew Geissler82c905d2020-04-13 13:39:40 -05007 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 -04008
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
Andrew Geissler82c905d2020-04-13 13:39:40 -050015 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES)
Brad Bishop15ae2502019-06-18 21:44:24 -040016 # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license
17 def test_incompatible_spdx_license(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060018 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0-only')
Brad Bishop15ae2502019-06-18 21:44:24 -040019
Andrew Geissler82c905d2020-04-13 13:39:40 -050020 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES)
Brad Bishop15ae2502019-06-18 21:44:24 -040021 # cannot be built when INCOMPATIBLE_LICENSE contains an alias (in
22 # SPDXLICENSEMAP) of this SPDX license
23 def test_incompatible_alias_spdx_license(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060024 self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3')
Brad Bishop15ae2502019-06-18 21:44:24 -040025
Andrew Geissler82c905d2020-04-13 13:39:40 -050026 # 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):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060030 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPL-3.0-only')
Andrew Geissler82c905d2020-04-13 13:39:40 -050031
32 # Verify that a package with an SPDX license (from AVAILABLE_LICENSES)
33 # cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded alias
34 # license matching this SPDX license
35 def test_incompatible_alias_spdx_license_wildcard(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060036 self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3')
Andrew Geissler82c905d2020-04-13 13:39:40 -050037
Brad Bishop15ae2502019-06-18 21:44:24 -040038 # 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):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060042 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPL-3.0-only')
Brad Bishop15ae2502019-06-18 21:44:24 -040043
44 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
45 # license cannot be built when INCOMPATIBLE_LICENSE contains this alias
46 def test_incompatible_alias_spdx_license_alias(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060047 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3')
Andrew Geissler82c905d2020-04-13 13:39:40 -050048
49 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
50 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
51 # license matching this SPDX license
52 def test_incompatible_spdx_license_alias_wildcard(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060053 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0')
Andrew Geissler82c905d2020-04-13 13:39:40 -050054
55 # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX
56 # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded
57 # alias license matching the SPDX license
58 def test_incompatible_alias_spdx_license_alias_wildcard(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060059 self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3')
Andrew Geissler82c905d2020-04-13 13:39:40 -050060
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):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060065 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 -050066
67 # Verify that a package with multiple SPDX licenses (from
68 # AVAILABLE_LICENSES) cannot be built when INCOMPATIBLE_LICENSE contains a
69 # wildcard to some of them
70 def test_incompatible_spdx_licenses_wildcard(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060071 self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', '*GPL-3.0-only')
Andrew Geissler82c905d2020-04-13 13:39:40 -050072
73 # Verify that a package with multiple SPDX licenses (from
74 # AVAILABLE_LICENSES) cannot be built when INCOMPATIBLE_LICENSE contains a
75 # wildcard matching all licenses
76 def test_incompatible_all_licenses_wildcard(self):
Andrew Geissler90fd73c2021-03-05 15:25:55 -060077 self.lic_test('incompatible-licenses', 'GPL-2.0-only GPL-3.0-only LGPL-3.0-only', '*')
Brad Bishop15ae2502019-06-18 21:44:24 -040078
79 # Verify that a package with a non-SPDX license (neither in
Andrew Geissler82c905d2020-04-13 13:39:40 -050080 # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when
Brad Bishop15ae2502019-06-18 21:44:24 -040081 # INCOMPATIBLE_LICENSE contains this license
82 def test_incompatible_nonspdx_license(self):
83 self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense')
Brad Bishopf3f93bb2019-10-16 14:33:32 -040084
85class IncompatibleLicensePerImageTests(OESelftestTestCase):
86 def default_config(self):
87 return """
Patrick Williams213cb262021-08-07 19:21:33 -050088IMAGE_INSTALL:append = " bash"
89INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040090"""
91
92 def test_bash_default(self):
93 self.write_config(self.default_config())
Andrew Geissler90fd73c2021-03-05 15:25:55 -060094 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 -040095
96 result = bitbake('core-image-minimal', ignore_status=True)
97 if error_msg not in result.output:
98 raise AssertionError(result.output)
99
100 def test_bash_and_license(self):
Patrick Williams213cb262021-08-07 19:21:33 -0500101 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"')
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600102 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 -0400103
104 result = bitbake('core-image-minimal', ignore_status=True)
105 if error_msg not in result.output:
106 raise AssertionError(result.output)
107
108 def test_bash_or_license(self):
Patrick Williams213cb262021-08-07 19:21:33 -0500109 self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " | SomeLicense"')
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400110
111 bitbake('core-image-minimal')
112
113 def test_bash_whitelist(self):
Patrick Williams213cb262021-08-07 19:21:33 -0500114 self.write_config(self.default_config() + '\nWHITELIST_GPL-3.0:pn-core-image-minimal = "bash"')
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400115
116 bitbake('core-image-minimal')
117
Brad Bishop64c979e2019-11-04 13:55:29 -0500118class NoGPL3InImagesTests(OESelftestTestCase):
119 def test_core_image_minimal(self):
120 self.write_config("""
Patrick Williams213cb262021-08-07 19:21:33 -0500121INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0 LGPL-3.0"
Brad Bishop64c979e2019-11-04 13:55:29 -0500122""")
123 bitbake('core-image-minimal')
124
Patrick Williams213cb262021-08-07 19:21:33 -0500125 def test_core_image_full_cmdline_weston(self):
Brad Bishop64c979e2019-11-04 13:55:29 -0500126 self.write_config("""
Patrick Williams213cb262021-08-07 19:21:33 -0500127INHERIT += "testimage"
128INCOMPATIBLE_LICENSE:pn-core-image-full-cmdline = "GPL-3.0 LGPL-3.0"
129INCOMPATIBLE_LICENSE:pn-core-image-weston = "GPL-3.0 LGPL-3.0"
130# Settings for full-cmdline
131RDEPENDS: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"
132RDEPENDS:packagegroup-core-full-cmdline-dev-utils:remove = "diffutils m4 make patch"
133RDEPENDS:packagegroup-core-full-cmdline-multiuser:remove = "gzip"
134# Settings for weston
135# direct gpl3 dependencies
136RRECOMMENDS:packagegroup-base-vfat:remove = "dosfstools"
137PACKAGECONFIG:remove:pn-bluez5 = "readline"
138# dnf pulls in gpg which is gpl3; it also pulls in python3-rpm which pulls in rpm-build which pulls in bash
139# so install rpm but not dnf
140IMAGE_FEATURES:remove:pn-core-image-weston = "package-management"
141CORE_IMAGE_EXTRA_INSTALL:pn-core-image-weston += "rpm"
142# matchbox-terminal depends on vte, which is gpl3
143CORE_IMAGE_BASE_INSTALL:remove:pn-core-image-weston = "matchbox-terminal"
Brad Bishop64c979e2019-11-04 13:55:29 -0500144""")
Patrick Williams213cb262021-08-07 19:21:33 -0500145 bitbake('core-image-full-cmdline core-image-weston')
146 bitbake('-c testimage core-image-full-cmdline core-image-weston')
Brad Bishop64c979e2019-11-04 13:55:29 -0500147