Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 6 | from oeqa.selftest.case import OESelftestTestCase |
| 7 | from oeqa.utils.commands import bitbake |
| 8 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 9 | class IncompatibleLicenseTestObsolete(OESelftestTestCase): |
| 10 | |
| 11 | def lic_test(self, pn, pn_lic, lic, error_msg=None): |
| 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) |
| 14 | |
| 15 | self.write_config("INCOMPATIBLE_LICENSE += \"%s\"" % (lic)) |
| 16 | |
| 17 | result = bitbake('%s --dry-run' % (pn), ignore_status=True) |
| 18 | if error_msg not in result.output: |
| 19 | raise AssertionError(result.output) |
| 20 | |
| 21 | # Verify that a package with an SPDX license cannot be built when |
| 22 | # INCOMPATIBLE_LICENSE contains an alias (in SPDXLICENSEMAP) of this SPDX |
| 23 | # license |
| 24 | def test_incompatible_alias_spdx_license(self): |
| 25 | self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE") |
| 26 | |
| 27 | # Verify that a package with an SPDX license cannot be built when |
| 28 | # INCOMPATIBLE_LICENSE contains a wildcarded alias license matching this |
| 29 | # SPDX license |
| 30 | def test_incompatible_alias_spdx_license_wildcard(self): |
| 31 | self.lic_test('incompatible-license', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry") |
| 32 | |
| 33 | # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX |
| 34 | # license cannot be built when INCOMPATIBLE_LICENSE contains this alias |
| 35 | def test_incompatible_alias_spdx_license_alias(self): |
| 36 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', 'GPLv3', "is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE") |
| 37 | |
| 38 | # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX |
| 39 | # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded |
| 40 | # license matching this SPDX license |
| 41 | def test_incompatible_spdx_license_alias_wildcard(self): |
| 42 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPL-3.0', "*GPL-3.0 is an invalid license wildcard entry") |
| 43 | |
| 44 | # Verify that a package with an alias (from SPDXLICENSEMAP) to an SPDX |
| 45 | # license cannot be built when INCOMPATIBLE_LICENSE contains a wildcarded |
| 46 | # alias license matching the SPDX license |
| 47 | def test_incompatible_alias_spdx_license_alias_wildcard(self): |
| 48 | self.lic_test('incompatible-license-alias', 'GPL-3.0-only', '*GPLv3', "*GPLv3 is an invalid license wildcard entry") |
| 49 | |
| 50 | |
| 51 | # Verify that a package with multiple SPDX licenses cannot be built when |
| 52 | # INCOMPATIBLE_LICENSE contains a wildcard to some of them |
| 53 | def test_incompatible_spdx_licenses_wildcard(self): |
| 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") |
| 55 | |
| 56 | |
| 57 | # Verify that a package with multiple SPDX licenses cannot be built when |
| 58 | # INCOMPATIBLE_LICENSE contains a wildcard matching all licenses |
| 59 | def test_incompatible_all_licenses_wildcard(self): |
| 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 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 62 | class IncompatibleLicenseTests(OESelftestTestCase): |
| 63 | |
| 64 | def lic_test(self, pn, pn_lic, lic): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 65 | 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] | 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 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 73 | # Verify that a package with an SPDX license cannot be built when |
| 74 | # INCOMPATIBLE_LICENSE contains this SPDX license |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 75 | def test_incompatible_spdx_license(self): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 76 | 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] | 77 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 78 | # Verify that a package with an SPDX license cannot be built when |
| 79 | # INCOMPATIBLE_LICENSE contains a wildcarded license matching this SPDX |
| 80 | # license |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 81 | def test_incompatible_spdx_license_wildcard(self): |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 82 | self.lic_test('incompatible-license', 'GPL-3.0-only', 'GPL-3.0*') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 83 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 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): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 88 | 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] | 89 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 90 | # Verify that a package with multiple SPDX licenses cannot be built when |
| 91 | # INCOMPATIBLE_LICENSE contains some of them |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 92 | def test_incompatible_spdx_licenses(self): |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 93 | 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] | 94 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 95 | # Verify that a package with a non-SPDX license cannot be built when |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 96 | # INCOMPATIBLE_LICENSE contains this license |
| 97 | def test_incompatible_nonspdx_license(self): |
| 98 | self.lic_test('incompatible-nonspdx-license', 'FooLicense', 'FooLicense') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 99 | |
| 100 | class IncompatibleLicensePerImageTests(OESelftestTestCase): |
| 101 | def default_config(self): |
| 102 | return """ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 103 | IMAGE_INSTALL:append = " bash" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 104 | INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 105 | """ |
| 106 | |
| 107 | def test_bash_default(self): |
| 108 | self.write_config(self.default_config()) |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 109 | 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] | 110 | |
| 111 | result = bitbake('core-image-minimal', ignore_status=True) |
| 112 | if error_msg not in result.output: |
| 113 | raise AssertionError(result.output) |
| 114 | |
| 115 | def test_bash_and_license(self): |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 116 | self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " & SomeLicense"') |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 117 | 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] | 118 | |
| 119 | result = bitbake('core-image-minimal', ignore_status=True) |
| 120 | if error_msg not in result.output: |
| 121 | raise AssertionError(result.output) |
| 122 | |
| 123 | def test_bash_or_license(self): |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 124 | self.write_config(self.default_config() + '\nLICENSE:append:pn-bash = " | SomeLicense"') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 125 | |
| 126 | bitbake('core-image-minimal') |
| 127 | |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 128 | def test_bash_license_exceptions(self): |
| 129 | self.write_config(self.default_config() + '\nINCOMPATIBLE_LICENSE_EXCEPTIONS:pn-core-image-minimal = "bash:GPL-3.0-or-later"') |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 130 | |
| 131 | bitbake('core-image-minimal') |
| 132 | |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 133 | class NoGPL3InImagesTests(OESelftestTestCase): |
| 134 | def test_core_image_minimal(self): |
| 135 | self.write_config(""" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 136 | INCOMPATIBLE_LICENSE:pn-core-image-minimal = "GPL-3.0* LGPL-3.0*" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 137 | """) |
| 138 | bitbake('core-image-minimal') |
| 139 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 140 | def test_core_image_full_cmdline_weston(self): |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 141 | self.write_config(""" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 142 | IMAGE_CLASSES += "testimage" |
Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 143 | INCOMPATIBLE_LICENSE:pn-core-image-full-cmdline = "GPL-3.0* LGPL-3.0*" |
| 144 | INCOMPATIBLE_LICENSE:pn-core-image-weston = "GPL-3.0* LGPL-3.0*" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 145 | # Settings for full-cmdline |
| 146 | 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" |
| 147 | RDEPENDS:packagegroup-core-full-cmdline-dev-utils:remove = "diffutils m4 make patch" |
| 148 | RDEPENDS:packagegroup-core-full-cmdline-multiuser:remove = "gzip" |
| 149 | # Settings for weston |
| 150 | # direct gpl3 dependencies |
| 151 | RRECOMMENDS:packagegroup-base-vfat:remove = "dosfstools" |
| 152 | PACKAGECONFIG:remove:pn-bluez5 = "readline" |
| 153 | # dnf pulls in gpg which is gpl3; it also pulls in python3-rpm which pulls in rpm-build which pulls in bash |
| 154 | # so install rpm but not dnf |
| 155 | IMAGE_FEATURES:remove:pn-core-image-weston = "package-management" |
| 156 | CORE_IMAGE_EXTRA_INSTALL:pn-core-image-weston += "rpm" |
| 157 | # matchbox-terminal depends on vte, which is gpl3 |
| 158 | CORE_IMAGE_BASE_INSTALL:remove:pn-core-image-weston = "matchbox-terminal" |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 159 | """) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 160 | bitbake('core-image-full-cmdline core-image-weston') |
| 161 | bitbake('-c testimage core-image-full-cmdline core-image-weston') |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 162 | |