* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
@ 2023-08-28 17:49 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2023-08-28 17:49 UTC (permalink / raw
To: gentoo-commits
commit: d00711f2d6cbae14a57088ef78caa3daf72069aa
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 28 17:43:08 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Aug 28 17:43:08 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=d00711f2
ebuild.repository: add support for stabilization groups
This is a special metadata files that can be used to group packages
for stabilization bugs.
Resolves: https://github.com/pkgcore/pkgcore/issues/411
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/ebuild/repository.py | 24 ++++++++++++++++++++++++
tests/ebuild/test_repository.py | 25 +++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index 164aa0c97..50f115cc1 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -16,6 +16,7 @@ from snakeoil import chksum, klass
from snakeoil.bash import read_dict
from snakeoil.containers import InvertedContains
from snakeoil.data_source import local_source
+from snakeoil.fileutils import readlines_utf8
from snakeoil.mappings import ImmutableDict
from snakeoil.obj import make_kls
from snakeoil.osutils import listdir_dirs, listdir_files, pjoin
@@ -34,7 +35,9 @@ from ..restrictions import packages
from ..util import packages as pkgutils
from . import cpv, digest, ebd, ebuild_src
from . import eclass_cache as eclass_cache_mod
+from . import errors as ebuild_errors
from . import processor, repo_objs, restricts
+from .atom import atom
from .eapi import get_eapi
@@ -670,6 +673,27 @@ class UnconfiguredTree(prototype.tree):
pkg_deprecated.update(repo.config.pkg_deprecated)
return packages.OrRestriction(*pkg_deprecated)
+ @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)
+ return ImmutableDict(stabilization_groups)
+
def _regen_operation_helper(self, **kwds):
return _RegenOpHelper(
self,
diff --git a/tests/ebuild/test_repository.py b/tests/ebuild/test_repository.py
index 85a248d8d..fceb70b37 100644
--- a/tests/ebuild/test_repository.py
+++ b/tests/ebuild/test_repository.py
@@ -199,6 +199,31 @@ class TestUnconfiguredTree:
atom("<just/newer-than-42"),
}
+ 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 / "pkgcore" / "snakeoil").write_text("""dev-python/snakeoil # comment""")
+ mirrors = self.mk_tree(tmp_path).stabilization_groups
+ assert set(mirrors.keys()) == {"gentoo", "pkgcore/snakeoil"}
+ assert set(mirrors["gentoo"]) == {
+ atom("dev-python/pkgcore"),
+ atom("dev-python/pytest"),
+ }
+ assert set(mirrors["pkgcore/snakeoil"]) == {
+ atom("dev-python/snakeoil"),
+ }
+ assert "line 4: parsing error:" in caplog.text
+
class TestSlavedTree(TestUnconfiguredTree):
def mk_tree(self, path, *args, **kwds):
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
@ 2024-01-12 7:13 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2024-01-12 7:13 UTC (permalink / raw
To: gentoo-commits
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(
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
@ 2023-12-26 17:45 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2023-12-26 17:45 UTC (permalink / raw
To: gentoo-commits
commit: f9b39f8d7a18859450c6351ef77e72ef032621be
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 25 21:42:12 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 26 17:43:58 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=f9b39f8d
Fix: parsing bug that allows a revision to be part of a package
The previous logic was just checking for a trailing version component;
it wasn't checking for a trailing revision.
Relates to issue: #419
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/ebuild/cpv.py | 8 ++++----
tests/ebuild/test_cpv.py | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/pkgcore/ebuild/cpv.py b/src/pkgcore/ebuild/cpv.py
index 774051e07..b7149fc1e 100644
--- a/src/pkgcore/ebuild/cpv.py
+++ b/src/pkgcore/ebuild/cpv.py
@@ -38,11 +38,11 @@ def isvalid_pkg_name(chunks):
if not all(not s or _pkg_re.match(s) for s in chunks):
return False
# the package name must not end with a hyphen followed by anything that
- # looks like a version -- need to ensure that we've gotten more than one
+ # looks like a version or revision -- need to ensure that we've gotten more than one
# chunk, i.e. at least one hyphen
- if len(chunks) > 1 and isvalid_version_re.match(chunks[-1]):
- return False
- return True
+ if len(chunks) == 1:
+ return True
+ return not (isvalid_version_re.match(chunks[-1]) or isvalid_rev(chunks[-1]))
def isvalid_rev(s: str):
diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index e014d751d..1a778a936 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -52,6 +52,7 @@ class TestCPV:
"+dfa",
"timidity--9f",
"ormaybe---13_beta",
+ "bar-11-r3",
)
good_cp = (
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
@ 2022-12-22 7:11 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2022-12-22 7:11 UTC (permalink / raw
To: gentoo-commits
commit: 0517f1315251e5693ef994b2e2ae20d5aef13c6c
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Thu Dec 22 01:45:29 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 07:11:40 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=0517f131
Fix use default dep matching when working against IUSE defaults.
Tests are added to validate, but essentially an atom like `sys-libs/libxcrypt[abi_x86_32(-),abi_x86_64(-),system(-)]`
would fail to match IUSE='+system' due to the restriction using the unstripped
iuse for a set check.
With that fixed, the resolver- at least on my system- now actually can generate
solutions that are sane/correct.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/381
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/ebuild/restricts.py | 20 ++++++++++----------
tests/ebuild/test_atom.py | 23 ++++++++++++++++++++++-
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/src/pkgcore/ebuild/restricts.py b/src/pkgcore/ebuild/restricts.py
index 8240717e8..3b847fa55 100644
--- a/src/pkgcore/ebuild/restricts.py
+++ b/src/pkgcore/ebuild/restricts.py
@@ -222,8 +222,8 @@ class _UseDepDefaultContainment(values.ContainmentMatch):
def match(self, val):
reduced_vals = self.vals
- iuse, use = val
- if reduced_vals.issubset(iuse):
+ iuse_stripped, use = val
+ if reduced_vals.issubset(iuse_stripped):
# use normal pathways.
return values.ContainmentMatch.match(self, use)
if self.if_missing == self.negate:
@@ -234,7 +234,7 @@ class _UseDepDefaultContainment(values.ContainmentMatch):
# to reach here, either we're trying to force all flags false and the default is False,
# or we're trying to force all flags on, and the default is on.
# recall that negate is unfortunately a double negative in labeling...
- reduced_vals = reduced_vals.intersection(iuse)
+ reduced_vals = reduced_vals.intersection(iuse_stripped)
if reduced_vals:
return values.ContainmentMatch.match(self, use, _values_override=reduced_vals)
# nothing to match means all are missing, but the default makes them considered a match.
@@ -243,12 +243,12 @@ class _UseDepDefaultContainment(values.ContainmentMatch):
def force_False(self, pkg, attr, val):
reduced_vals = self.vals
# see comments in .match for clarification of logic.
- iuse, use = val
- if reduced_vals.issubset(iuse):
+ iuse_stripped, use = val
+ if reduced_vals.issubset(iuse_stripped):
return values.ContainmentMatch.force_False(self, pkg, 'use', use)
if self.if_missing == self.negate:
return False
- reduced_vals = reduced_vals.intersection(iuse)
+ reduced_vals = reduced_vals.intersection(iuse_stripped)
if reduced_vals:
return values.ContainmentMatch.force_False(self, pkg, 'use', use, reduced_vals)
return True
@@ -256,12 +256,12 @@ class _UseDepDefaultContainment(values.ContainmentMatch):
def force_True(self, pkg, attr, val):
reduced_vals = self.vals
# see comments in .match for clarification of logic.
- iuse, use = val
- if reduced_vals.issubset(iuse):
+ iuse_stripped, use = val
+ if reduced_vals.issubset(iuse_stripped):
return values.ContainmentMatch.force_True(self, pkg, 'use', use)
if self.if_missing == self.negate:
return False
- reduced_vals = reduced_vals.intersection(iuse)
+ reduced_vals = reduced_vals.intersection(iuse_stripped)
if reduced_vals:
return values.ContainmentMatch.force_True(self, pkg, 'use', use, reduced_vals)
return True
@@ -287,7 +287,7 @@ class UseDepDefault(packages.PackageRestrictionMulti):
else:
v = values.AlwaysTrue
- super().__init__(('iuse', 'use'), v)
+ super().__init__(('iuse_stripped', 'use'), v)
def _parse_nontransitive_use(sequence):
diff --git a/tests/ebuild/test_atom.py b/tests/ebuild/test_atom.py
index ceb4c4959..0893b817a 100644
--- a/tests/ebuild/test_atom.py
+++ b/tests/ebuild/test_atom.py
@@ -2,15 +2,16 @@ from functools import partial
from pickle import dumps, loads
import pytest
+from snakeoil.compatibility import cmp
from pkgcore.ebuild import atom, errors, restricts
from pkgcore.ebuild.cpv import CPV
from pkgcore.restrictions.boolean import AndRestriction
from pkgcore.test.misc import FakePkg, FakeRepo
-from snakeoil.compatibility import cmp
from ..restrictions.utils import TestRestriction
+
def assert_equal_bidirectional(o1, o2):
# logic bugs hidden behind short circuiting comparisons for metadata
# is why we test the comparison *both* ways.
@@ -547,3 +548,23 @@ class TestAtom(TestRestriction):
def test_get_atom_without_use_deps(self, original, wanted):
orig_atom = self.kls(original)
assert str(orig_atom.get_atom_without_use_deps) == wanted
+
+ @pytest.mark.parametrize(('dep', 'iuse', 'use', 'wanted', 'eapi'), (
+ ("x(-)", {'x'}, {'x'}, True, '5'),
+ ("x(-)", {'x'}, (), False, '5'),
+ ("x(+)", (), (), True, '5'),
+ ("x(-)", (), (), False, '5'),
+ ("x(-),y(-)", (), (), False, '5'),
+ ("x(-),y(-)", {'x', 'y'}, ("x", "y"), True, '5'),
+ ("x(+),y(-)", (), (), False, '5'),
+ ("x(+),y(-)", {"y"}, (), False, '5'),
+ ("x(+),y(-)", {'y'}, {"y"}, True, '5'),
+ # verify that it's not sensitive to iuse defaults
+ ("x(-)", {"+x"}, {"x"}, True, '5'),
+ ("x(+)", {"-x"}, {"x"}, True, '5'),
+ ))
+ def test_use_dep_defaults(self, dep, iuse, use, wanted, eapi):
+ pkg = FakePkg("dev-util/diffball-1", eapi=eapi, iuse=frozenset(iuse), use=frozenset(use))
+ a = self.kls(f'dev-util/diffball[{dep}]')
+ #import pdb;pdb.set_trace()
+ assert a.match(pkg) == wanted
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
@ 2022-10-08 10:09 Arthur Zamarin
0 siblings, 0 replies; 5+ messages in thread
From: Arthur Zamarin @ 2022-10-08 10:09 UTC (permalink / raw
To: gentoo-commits
commit: 3fa274977405f73221055c7287880a9dc3038765
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 7 18:52:15 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Oct 8 09:58:19 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=3fa27497
profiles: support package.bashrc files
Add support for `profile-bashrcs` profile format, which adds support for
per-profile bashrc mechanism `package.bashrc`, which enables to specify
per restriction the extra bashrc files to run.
See portage(5) for format details.
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/ebuild/domain.py | 9 +++---
src/pkgcore/ebuild/inspect_profile.py | 9 ++++++
src/pkgcore/ebuild/profiles.py | 26 ++++++++++++++++
src/pkgcore/ebuild/repo_objs.py | 2 +-
tests/ebuild/test_profiles.py | 56 +++++++++++++++++++++++++++++++++++
5 files changed, 97 insertions(+), 5 deletions(-)
diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index 47f31ef2f..a1f231e9f 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -596,10 +596,11 @@ class domain(config_domain):
return self
def get_package_bashrcs(self, pkg):
- for source in self.profile.bashrcs:
- yield source
- for source in self.bashrcs:
- yield source
+ yield from self.profile.bashrcs
+ for restrict, bashrcs in self.profile.pkg_bashrcs:
+ if restrict.match(pkg):
+ yield from bashrcs
+ yield from self.bashrcs
if not os.path.exists(self.ebuild_hook_dir):
return
# matching portage behavior... it's whacked.
diff --git a/src/pkgcore/ebuild/inspect_profile.py b/src/pkgcore/ebuild/inspect_profile.py
index a0be246c1..dc8c5942d 100644
--- a/src/pkgcore/ebuild/inspect_profile.py
+++ b/src/pkgcore/ebuild/inspect_profile.py
@@ -187,6 +187,15 @@ class bashrcs(_base, metaclass=_register_command):
out.write(bashrc.path)
+class package_bashrc(_base, metaclass=_register_command):
+ """inspect package.bashrc"""
+
+ def __call__(self, namespace, out, err):
+ for package, bashrcs in namespace.profile.pkg_bashrcs:
+ bashrcs = ", ".join(s.path for s in bashrcs)
+ out.write(f'{package}: {bashrcs}')
+
+
class keywords(_base, metaclass=_register_command):
"""inspect package.keywords"""
diff --git a/src/pkgcore/ebuild/profiles.py b/src/pkgcore/ebuild/profiles.py
index 4607639cb..34e839e9b 100644
--- a/src/pkgcore/ebuild/profiles.py
+++ b/src/pkgcore/ebuild/profiles.py
@@ -452,6 +452,27 @@ class ProfileNode(metaclass=caching.WeakInstMeta):
return local_source(path)
return None
+ @load_property("package.bashrc", allow_recurse=True)
+ def pkg_bashrc(self, data):
+ repo_config = self.repoconfig
+ if repo_config is None or 'profile-bashrcs' not in repo_config.profile_formats:
+ return ()
+
+ d = defaultdict(list)
+ for line, lineno, relpath in data:
+ l = line.split()
+ try:
+ a = self.eapi_atom(l[0])
+ except ebuild_errors.MalformedAtom as exc:
+ logger.error(f'{relpath!r}, line {lineno}: parsing error: {exc}')
+ continue
+ if len(l) == 1:
+ logger.error(f'{relpath!r}, line {lineno}: missing bashrc files: {line!r}')
+ continue
+ for filename in l[1:]:
+ d[a].append(local_source(pjoin(self.path, 'bashrc', filename)))
+ return tuple((k, tuple(v)) for k, v in d.items())
+
@load_property('eapi', fallback='0')
def eapi(self, data):
# handle fallback
@@ -522,6 +543,7 @@ class EmptyRootNode(ProfileNode):
deprecated = None
pkg_use = masked_use = stable_masked_use = forced_use = stable_forced_use = misc.ChunkedDataDict()
forced_use.freeze()
+ pkg_bashrc = ()
pkg_use_force = pkg_use_mask = ImmutableDict()
pkg_provided = system = profile_set = ((), ())
@@ -747,6 +769,10 @@ class ProfileStack:
def bashrcs(self):
return tuple(x.bashrc for x in self.stack if x.bashrc is not None)
+ @klass.jit_attr
+ def pkg_bashrcs(self):
+ return tuple(chain.from_iterable(x.pkg_bashrc for x in self.stack))
+
bashrc = klass.alias_attr("bashrcs")
path = klass.alias_attr("node.path")
diff --git a/src/pkgcore/ebuild/repo_objs.py b/src/pkgcore/ebuild/repo_objs.py
index 633c858e3..78371e29a 100644
--- a/src/pkgcore/ebuild/repo_objs.py
+++ b/src/pkgcore/ebuild/repo_objs.py
@@ -682,7 +682,7 @@ class RepoConfig(syncable.tree, klass.ImmutableInstance, metaclass=WeakInstMeta)
default_hashes = ('size', 'blake2b', 'sha512')
default_required_hashes = ('size', 'blake2b')
- supported_profile_formats = ('pms', 'portage-1', 'portage-2', 'profile-set')
+ supported_profile_formats = ('pms', 'portage-1', 'portage-2', 'profile-bashrcs', 'profile-set')
supported_cache_formats = ('md5-dict', 'pms')
__inst_caching__ = True
diff --git a/tests/ebuild/test_profiles.py b/tests/ebuild/test_profiles.py
index 8f920825c..a7abfe9f2 100644
--- a/tests/ebuild/test_profiles.py
+++ b/tests/ebuild/test_profiles.py
@@ -545,6 +545,17 @@ class TestPmsProfileNode(profile_mixin):
self.write_file(tmp_path, "profile.bashrc", '')
assert self.klass(path).bashrc is not None
+ def test_pkg_bashrc(self, tmp_path, caplog):
+ path = tmp_path / self.profile
+ assert not self.klass(path).pkg_bashrc
+ self.write_file(tmp_path, "package.bashrc", "@dsfg", profile=self.profile)
+ assert not self.klass(path).pkg_bashrc
+ self.write_file(tmp_path, "package.bashrc", "dev-util/foo", profile=self.profile)
+ assert not self.klass(path).pkg_bashrc
+ self.write_file(tmp_path, "package.bashrc", "dev-util/foo file1 file2\ndev-util/bar file3", profile=self.profile)
+ assert not self.klass(path).pkg_bashrc
+ assert not caplog.text
+
class TestPortage1ProfileNode(TestPmsProfileNode):
@@ -593,6 +604,51 @@ class TestPortage2ProfileNode(TestPortage1ProfileNode):
(tmp_path / "metadata" / "layout.conf").write_text("masters = ''\nprofile-formats = portage-2")
+class TestProfileBashrcProfileNode(TestPmsProfileNode):
+
+ profile = os.path.join("profiles", "default")
+
+ def assert_pkg_bashrc(self, actual, expected):
+ assert expected == {
+ str(k): [s.path for s in v]
+ for k, v in actual
+ }
+
+ def setup_repo(self, tmp_path):
+ (tmp_path / "profiles" / "repo_name").write_bytes(binascii.b2a_hex(os.urandom(10)))
+ (tmp_path / "metadata").mkdir()
+ (tmp_path / "metadata" / "layout.conf").write_text("masters = ''\nprofile-formats = profile-bashrcs")
+
+ def test_pkg_bashrc(self, tmp_path, caplog):
+ path = tmp_path / self.profile
+ assert not self.klass(path).pkg_bashrc
+ self.parsing_checks(tmp_path, "package.bashrc", "pkg_bashrc")
+ assert not caplog.text
+
+ caplog.clear()
+ self.write_file(tmp_path, "package.bashrc", "@dsfg", profile=self.profile)
+ assert not self.klass(path).pkg_bashrc
+ assert "line 1: parsing error: invalid package atom: '@dsfg'" in caplog.text
+
+ caplog.clear()
+ self.write_file(tmp_path, "package.bashrc", "dev-util/foo", profile=self.profile)
+ assert not self.klass(path).pkg_bashrc
+ assert "line 1: missing bashrc files: 'dev-util/foo'" in caplog.text
+
+ caplog.clear()
+ self.write_file(tmp_path, "package.bashrc", "dev-util/foo file1", profile=self.profile)
+ self.assert_pkg_bashrc(self.klass(path).pkg_bashrc, {"dev-util/foo": [str(path / "bashrc/file1")]})
+ assert not caplog.text
+
+ caplog.clear()
+ self.write_file(tmp_path, "package.bashrc", "dev-util/foo file1 file2\ndev-util/bar file3", profile=self.profile)
+ self.assert_pkg_bashrc(self.klass(path).pkg_bashrc, {
+ "dev-util/foo": [str(path / "bashrc/file1"), str(path / "bashrc/file2")],
+ "dev-util/bar": [str(path / "bashrc/file3")],
+ })
+ assert not caplog.text
+
+
class TestProfileSetProfileNode(TestPmsProfileNode):
profile = os.path.join("profiles", "default")
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-12 7:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-28 17:49 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/ Arthur Zamarin
-- strict thread matches above, loose matches on Subject: below --
2024-01-12 7:13 Arthur Zamarin
2023-12-26 17:45 Arthur Zamarin
2022-12-22 7:11 Arthur Zamarin
2022-10-08 10:09 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox