diff options
author | 2024-01-11 21:43:40 -0800 | |
---|---|---|
committer | 2024-01-12 09:07:44 +0200 | |
commit | f756179726eb700b9d1998d4d1bd16270d8ce1d4 (patch) | |
tree | 7b0d4a46aa3e981a85c52d54390b66f339d2c606 | |
parent | fix: tweak CPV parsing rules to match PMS. (diff) | |
download | pkgcore-f756179726eb700b9d1998d4d1bd16270d8ce1d4.tar.gz pkgcore-f756179726eb700b9d1998d4d1bd16270d8ce1d4.tar.bz2 pkgcore-f756179726eb700b9d1998d4d1bd16270d8ce1d4.zip |
fix: child repository not inheriting license groups when it defines none
If the child repository defines no license groups, the previous code would
exit out before it integrated the parents license groups.
This fixes that, and adds tests for it.
Signed-off-by: Brian Harring <ferringb@gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/424
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgcore/ebuild/repo_objs.py | 8 | ||||
-rw-r--r-- | tests/ebuild/test_repository.py | 22 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/pkgcore/ebuild/repo_objs.py b/src/pkgcore/ebuild/repo_objs.py index 3359305b..47422dc1 100644 --- a/src/pkgcore/ebuild/repo_objs.py +++ b/src/pkgcore/ebuild/repo_objs.py @@ -526,11 +526,13 @@ class Licenses(metaclass=WeakInstMeta): d = read_dict(self.license_groups_path, splitter=" ") for k, v in d.items(): d[k] = set(v.split()) - except EnvironmentError: - return mappings.ImmutableDict() + except EnvironmentError as e: + if e.errno != errno.ENOENT: + logger.error(f"failed reading parsing license_groups: {e}") + d = {} except BashParseError as pe: logger.error(f"failed parsing license_groups: {pe}") - return mappings.ImmutableDict() + d = {} for li in self._license_instances: for k, v in li.groups.items(): if k in d: diff --git a/tests/ebuild/test_repository.py b/tests/ebuild/test_repository.py index 71366ba2..10c0b93b 100644 --- a/tests/ebuild/test_repository.py +++ b/tests/ebuild/test_repository.py @@ -296,7 +296,7 @@ class TestSlavedTree(TestUnconfiguredTree): repo = self.mk_tree(slave_repo) assert set(repo.licenses) == set(master_licenses + slave_licenses) - def test_license_groups(self, master_repo, slave_repo): + def test_license_groups(self, master_repo, slave_repo, caplog): master_licenses = ("GPL-2", "BSD") slave_licenses = ("BSD-2", "MIT") @@ -324,6 +324,26 @@ class TestSlavedTree(TestUnconfiguredTree): } assert "BSD" in repo.licenses.groups["MISC-FREE"] + # verify it warns when parsing fails + (slave_repo / "profiles" / "license_groups").write_text('X"') + caplog.clear() + repo = self.mk_tree(slave_repo) + assert set(repo.licenses.groups) == {"FREE", "OSI-APPROVED"} + assert caplog.text + + # verify it warns when the file exists but it can't read it. + (slave_repo / "profiles" / "license_groups").write_text("") + (slave_repo / "profiles" / "license_groups").chmod(000) + caplog.clear() + repo = self.mk_tree(slave_repo) + assert set(repo.licenses.groups) == {"FREE", "OSI-APPROVED"} + assert caplog.text + + # verify it handles a missing license group. + (slave_repo / "profiles" / "license_groups").unlink() + repo = self.mk_tree(slave_repo) + assert set(repo.licenses.groups) == {"FREE", "OSI-APPROVED"} + def test_package_deprecated(self, slave_repo, master_repo): (master_repo / "profiles" / "package.deprecated").write_text( textwrap.dedent( |