Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 1 | from oeqa.selftest.case import OESelftestTestCase |
| 2 | from oeqa.utils.commands import bitbake |
| 3 | |
| 4 | class IncompatibleLicenseTests(OESelftestTestCase): |
| 5 | |
| 6 | def lic_test(self, pn, pn_lic, lic): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 7 | error_msg = 'ERROR: Nothing PROVIDES \'%s\'\n%s was skipped: it has incompatible license(s): %s' % (pn, pn, pn_lic) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 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 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 15 | # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 16 | # cannot be built when INCOMPATIBLE_LICENSE contains this SPDX license |
| 17 | def test_incompatible_spdx_license(self): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 18 | self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0-only') |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 19 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 20 | # Verify that a package with an SPDX license (from AVAILABLE_LICENSES) |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 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): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 24 | self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3') |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 25 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 30 | self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPL-3.0-only') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 31 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 36 | self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 37 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 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): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 42 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPL-3.0-only') |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 43 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 47 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 48 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 53 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 54 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 59 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 65 | self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', 'GPL-3.0-only LGPL-3.0-only') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 66 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 71 | self.lic_test('incompatible-licenses', 'GPL-3.0-only LGPL-3.0-only', '*GPL-3.0-only') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 72 | |
| 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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 77 | self.lic_test('incompatible-licenses', 'GPL-2.0-only GPL-3.0-only LGPL-3.0-only', '*') |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 78 | |
| 79 | # Verify that a package with a non-SPDX license (neither in |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 80 | # AVAILABLE_LICENSES nor in SPDXLICENSEMAP) cannot be built when |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 81 | # INCOMPATIBLE_LICENSE contains this license |
| 82 | def test_incompatible_nonspdx_license(self): |
| 83 | self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 84 | |
| 85 | class IncompatibleLicensePerImageTests(OESelftestTestCase): |
| 86 | def default_config(self): |
| 87 | return """ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 88 | IMAGE_INSTALL:append = " bash" |
| 89 | INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0 LGPL-3.0" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 90 | """ |
| 91 | |
| 92 | def test_bash_default(self): |
| 93 | self.write_config(self.default_config()) |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 94 | 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 Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 95 | |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 101 | self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"') |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 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" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 103 | |
| 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 109 | self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " | SomeLicense"') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 110 | |
| 111 | bitbake('core-image-minimal') |
| 112 | |
| 113 | def test_bash_whitelist(self): |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 114 | self.write_config(self.default_config() + '\nWHITELIST_GPL-3.0:pn-core-image-minimal = "bash"') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 115 | |
| 116 | bitbake('core-image-minimal') |
| 117 | |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 118 | class NoGPL3InImagesTests(OESelftestTestCase): |
| 119 | def test_core_image_minimal(self): |
| 120 | self.write_config(""" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 121 | INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0 LGPL-3.0" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 122 | """) |
| 123 | bitbake('core-image-minimal') |
| 124 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 125 | def test_core_image_full_cmdline_weston(self): |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 126 | self.write_config(""" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 127 | INHERIT += "testimage" |
| 128 | INCOMPATIBLE_LICENSE:pn-core-image-full-cmdline = "GPL-3.0 LGPL-3.0" |
| 129 | INCOMPATIBLE_LICENSE:pn-core-image-weston = "GPL-3.0 LGPL-3.0" |
| 130 | # Settings for full-cmdline |
| 131 | RDEPENDS: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" |
| 132 | RDEPENDS:packagegroup-core-full-cmdline-dev-utils:remove = "diffutils m4 make patch" |
| 133 | RDEPENDS:packagegroup-core-full-cmdline-multiuser:remove = "gzip" |
| 134 | # Settings for weston |
| 135 | # direct gpl3 dependencies |
| 136 | RRECOMMENDS:packagegroup-base-vfat:remove = "dosfstools" |
| 137 | PACKAGECONFIG: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 |
| 140 | IMAGE_FEATURES:remove:pn-core-image-weston = "package-management" |
| 141 | CORE_IMAGE_EXTRA_INSTALL:pn-core-image-weston += "rpm" |
| 142 | # matchbox-terminal depends on vte, which is gpl3 |
| 143 | CORE_IMAGE_BASE_INSTALL:remove:pn-core-image-weston = "matchbox-terminal" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 144 | """) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 145 | bitbake('core-image-full-cmdline core-image-weston') |
| 146 | bitbake('-c testimage core-image-full-cmdline core-image-weston') |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 147 | |