From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 362FE15800A for ; Tue, 29 Aug 2023 17:37:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 672712BC014; Tue, 29 Aug 2023 17:37:23 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4EE672BC014 for ; Tue, 29 Aug 2023 17:37:23 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3FE9C335C39 for ; Tue, 29 Aug 2023 17:37:22 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A0549F2F for ; Tue, 29 Aug 2023 17:37:20 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1693330508.73b2cc0ecf48fec9242823009e0de953981913b3.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/ebuild/, src/pkgcore/ebuild/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/ebuild/repository.py tests/ebuild/test_repository.py X-VCS-Directories: tests/ebuild/ src/pkgcore/ebuild/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 73b2cc0ecf48fec9242823009e0de953981913b3 X-VCS-Branch: master Date: Tue, 29 Aug 2023 17:37:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: fb11f931-08f6-4076-88ec-7a58826bc6f2 X-Archives-Hash: 342cb3939aec94fb66947afc78147a8d commit: 73b2cc0ecf48fec9242823009e0de953981913b3 Author: Arthur Zamarin gentoo org> AuthorDate: Tue Aug 29 17:35:08 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Tue Aug 29 17:35:08 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=73b2cc0e ebuild.repository: require .group extension for stabilization groups After further consideration, it seems that the requiring .group extension will make our life easier, with exact format, and save us from backup files, readme or similar. https://github.com/pkgcore/pkgcore/pull/412#discussion_r1307738865 Suggested-by: Michał Górny gentoo.org> Follows: d00711f2d6cbae14a57088ef78caa3daf72069aa Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcore/ebuild/repository.py | 35 ++++++++++++++++++++--------------- tests/ebuild/test_repository.py | 21 +++++++++++---------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py index 50f115cc1..49bd72e19 100644 --- a/src/pkgcore/ebuild/repository.py +++ b/src/pkgcore/ebuild/repository.py @@ -676,22 +676,27 @@ class UnconfiguredTree(prototype.tree): @klass.jit_attr def stabilization_groups(self): """Return a mapping of stabilization groups to packages.""" - stabilization_groups = {} base_dir = pjoin(self.location, "metadata", "stabilization-groups") - for dirname, _dirs, files in os.walk(base_dir): - dirbase = dirname.removeprefix(base_dir) - for file in files: - pkgs = set() - for lineno, line in enumerate(readlines_utf8(pjoin(dirname, file)), 1): - try: - if line := line.split("#", maxsplit=1)[0].strip(): - pkgs.add(atom(line)) - except ebuild_errors.MalformedAtom as exc: - logger.error( - f"{dirname.removeprefix(self.location)}/{file}, line {lineno}: parsing error: {exc}" - ) - group = f"{dirbase}/{file}".removeprefix("/") - stabilization_groups[group] = frozenset(pkgs) + group_files = { + pjoin(dirname, file) + .removeprefix(base_dir + "/") + .removesuffix(".group"): pjoin(dirname, file) + for dirname, _dirs, files in os.walk(base_dir) + for file in files + if file.endswith(".group") + } + stabilization_groups = {} + for group_name, group_file in group_files.items(): + pkgs = set() + for lineno, line in enumerate(readlines_utf8(group_file), 1): + try: + if line := line.split("#", maxsplit=1)[0].strip(): + pkgs.add(atom(line)) + except ebuild_errors.MalformedAtom as exc: + logger.error( + f"{group_file.removeprefix(self.location)}, line {lineno}: parsing error: {exc}" + ) + stabilization_groups[group_name] = frozenset(pkgs) return ImmutableDict(stabilization_groups) def _regen_operation_helper(self, **kwds): diff --git a/tests/ebuild/test_repository.py b/tests/ebuild/test_repository.py index fceb70b37..2ba4eda57 100644 --- a/tests/ebuild/test_repository.py +++ b/tests/ebuild/test_repository.py @@ -202,17 +202,18 @@ class TestUnconfiguredTree: def test_stabilization_groups(self, tmp_path, caplog): base = tmp_path / "metadata/stabilization-groups" (base / "pkgcore").mkdir(parents=True) - (base / "gentoo").write_text( - textwrap.dedent( - """\ - # some text here - dev-python/pkgcore - dev-python/pytest # comment - @bad_atom@ - """ - ) + (base / "gentoo.group").write_text( + """\ + # some text here + dev-python/pkgcore + dev-python/pytest # comment + @bad_atom@ + """ + ) + (base / "pkgcore" / "snakeoil.group").write_text( + """dev-python/snakeoil # comment""" ) - (base / "pkgcore" / "snakeoil").write_text("""dev-python/snakeoil # comment""") + (base / "pkgcore" / "pkgdev").write_text("""dev-python/pkgdev # comment""") mirrors = self.mk_tree(tmp_path).stabilization_groups assert set(mirrors.keys()) == {"gentoo", "pkgcore/snakeoil"} assert set(mirrors["gentoo"]) == {