public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
Date: Fri, 12 Jan 2024 07:13:16 +0000 (UTC)	[thread overview]
Message-ID: <1705043264.f756179726eb700b9d1998d4d1bd16270d8ce1d4.arthurzam@gentoo> (raw)

commit:     f756179726eb700b9d1998d4d1bd16270d8ce1d4
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Fri Jan 12 05:43:40 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 12 07:07:44 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=f7561797

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 <AT> gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/424
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/repo_objs.py |  8 +++++---
 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 3359305bb..47422dc12 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 71366ba2e..10c0b93b1 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(


             reply	other threads:[~2024-01-12  7:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  7:13 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-12-26 17:45 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/ Arthur Zamarin
2023-08-28 17:49 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-10-08 10:09 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1705043264.f756179726eb700b9d1998d4d1bd16270d8ce1d4.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox