public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-10-04  8:24 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-10-04  8:24 UTC (permalink / raw
  To: gentoo-commits

commit:     9e2ed58e4695b3030e7ab2824b690bda8ed5d180
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Oct  4 08:21:41 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Oct  4 08:21:41 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=9e2ed58e

repository: check issues with distdir only if fetch failed

Perform the checks for distdir (so we have more informative output) only
if a fetch failed. As a result, if it doesn't need to fetch, it won't
check the distdir.

Follows: 97d53b0ca18c9581a054e930f3496768ae923b18
Resolves: https://github.com/pkgcore/pkgdev/issues/99
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/repository.py | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index 47eaaea0b..3a8f20b35 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -25,7 +25,7 @@ from snakeoil.strings import pluralism
 from .. import fetch
 from ..config.hint import ConfigHint, configurable
 from ..log import logger
-from ..operations import repo as _repo_ops
+from ..operations import OperationError, repo as _repo_ops
 from ..package import errors as pkg_errors
 from ..repository import configured, errors, prototype, util
 from ..repository.virtual import RestrictionRepo
@@ -51,16 +51,6 @@ class repo_operations(_repo_ops.operations):
         if distdir is None:
             distdir = domain.distdir
 
-        try:
-            os.makedirs(distdir, exist_ok=True)
-        except OSError as exc:
-            observer.error(f'failed to create distdir {distdir!r}: {exc.strerror}')
-            return ('failed to create distdir', )
-
-        if not os.access(distdir, os.W_OK):
-            observer.error(f'no write access to distdir: {distdir!r}')
-            return ('no write access to distdir', )
-
         ret = set()
 
         matches = self.repo.itermatch(restriction, sorter=sorted)
@@ -115,9 +105,23 @@ class repo_operations(_repo_ops.operations):
 
             # fetch distfiles
             pkg_ops = domain.pkg_operations(pkg, observer=observer)
-            if not pkg_ops.fetch(list(fetchables.values()), observer, distdir=distdir):
-                ret.add(key)
-                continue
+            try:
+                if not pkg_ops.fetch(list(fetchables.values()), observer, distdir=distdir):
+                    ret.add(key)
+                    continue
+            except OperationError:
+                # check for special cases of fetch failures
+                try:
+                    os.makedirs(distdir, exist_ok=True)
+                except OSError as exc:
+                    observer.error(f'failed to create distdir {distdir!r}: {exc.strerror}')
+                    return ('failed to create distdir', )
+
+                if not os.access(distdir, os.W_OK):
+                    observer.error(f'no write access to distdir: {distdir!r}')
+                    return ('no write access to distdir', )
+
+                raise
 
             # calculate checksums for fetched distfiles
             try:


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-10-16 16:38 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-10-16 16:38 UTC (permalink / raw
  To: gentoo-commits

commit:     965d3b28390321aafc5fc055df8f4e52c7f941fe
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 16 07:59:01 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 16 08:15:20 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=965d3b28

ebuild.repository: improve handling with precise restricts

When the restricts used for manifest return subset of versions of the
package, calculating the manifest drops all entries for other unmatched
versions.

We separate the behavior into 2 types: selected and unselected. For the
selected once by restricts, the behaviour shouldn't change at all - if
it did, this is a bug! For the unselected once, it should reuse the
current manifest entries. In case a distfile has missing checksums of
the required types, it will drop the entry! This behavior should occur
only if the current Manifest is broken, so we allow ourselves to do what
we want.

Resolves: https://github.com/pkgcore/pkgdev/issues/74
Resolves: https://github.com/pkgcore/pkgdev/issues/83
Resolves: https://github.com/pkgcore/pkgdev/issues/101
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/repository.py | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index 3a8f20b35..9af41e997 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -61,22 +61,25 @@ class repo_operations(_repo_ops.operations):
             # check for pkgs masked by bad metadata
             if bad_metadata := self.repo._bad_masked.match(pkgs[0].unversioned_atom):
                 for pkg in bad_metadata:
-                    e = pkg.data
-                    error_str = f"{pkg.cpvstr}: {e.msg(verbosity=observer.verbosity)}"
+                    exc = pkg.data
+                    error_str = f"{pkg.cpvstr}: {exc.msg(verbosity=observer.verbosity)}"
                     observer.error(error_str)
                     ret.add(pkg.key)
                 continue
 
-            # all pkgdir fetchables
-            pkgdir_fetchables = {}
-            for pkg in pkgs:
-                pkgdir_fetchables.update({
+            all_pkgdir_fetchables = {
+                pkg: {
                     fetchable.filename: fetchable for fetchable in
                     iflatten_instance(pkg.generate_fetchables(
                         allow_missing_checksums=True,
                         skip_default_mirrors=(not mirrors)),
                         fetch.fetchable)
-                })
+                } for pkg in self.repo.itermatch(pkgs[0].unversioned_atom)
+            }
+
+            # all pkgdir fetchables
+            pkgdir_fetchables = dict(chain.from_iterable(
+                all_pkgdir_fetchables[pkg].items() for pkg in pkgs))
 
             # fetchables targeted for (re-)manifest generation
             fetchables = {}
@@ -92,10 +95,10 @@ class repo_operations(_repo_ops.operations):
                 if os.path.exists(manifest.path):
                     try:
                         os.remove(manifest.path)
-                    except EnvironmentError as e:
+                    except EnvironmentError as exc:
                         observer.error(
                             'failed removing old manifest: '
-                            f'{key}::{self.repo.repo_id}: {e}')
+                            f'{key}::{self.repo.repo_id}: {exc}')
                         ret.add(key)
                 continue
 
@@ -104,7 +107,7 @@ class repo_operations(_repo_ops.operations):
                 continue
 
             # fetch distfiles
-            pkg_ops = domain.pkg_operations(pkg, observer=observer)
+            pkg_ops = domain.pkg_operations(pkgs[0], observer=observer)
             try:
                 if not pkg_ops.fetch(list(fetchables.values()), observer, distdir=distdir):
                     ret.add(key)
@@ -129,15 +132,19 @@ class repo_operations(_repo_ops.operations):
                     chksums = chksum.get_chksums(
                         pjoin(distdir, fetchable.filename), *write_chksums)
                     fetchable.chksums = dict(zip(write_chksums, chksums))
-            except chksum.MissingChksumHandler as e:
-                observer.error(f'failed generating chksum: {e}')
+            except chksum.MissingChksumHandler as exc:
+                observer.error(f'failed generating chksum: {exc}')
                 ret.add(key)
                 break
 
             if key not in ret:
-                fetchables.update(pkgdir_fetchables)
+                all_fetchables = {filename: fetchable
+                    for fetchables in all_pkgdir_fetchables.values()
+                    for filename, fetchable in fetchables.items()
+                    if required_chksums.issubset(fetchable.chksums)}
+                all_fetchables.update(fetchables)
                 observer.info(f"generating manifest: {key}::{self.repo.repo_id}")
-                manifest.update(sorted(fetchables.values()), chfs=write_chksums)
+                manifest.update(sorted(all_fetchables.values()), chfs=write_chksums)
 
         return ret
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-10-29 11:56 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-10-29 11:56 UTC (permalink / raw
  To: gentoo-commits

commit:     e7aeda0fdec527e99e40af05865689e27ed01cbd
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 11:45:24 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 11:56:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=e7aeda0f

ebuild.profiles: error out when using USE_EXAPND in package.mask

portage fails to parse this syntax when used for package.use files under
a profile, and pkgcore parses it incorrectly. So in case such syntax is
detected, error out (which will cause a ProfileError with pkgcheck).

Resolves: https://github.com/pkgcore/pkgcheck/issues/370
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/profiles.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/pkgcore/ebuild/profiles.py b/src/pkgcore/ebuild/profiles.py
index 34e839e9b..17805edaa 100644
--- a/src/pkgcore/ebuild/profiles.py
+++ b/src/pkgcore/ebuild/profiles.py
@@ -329,6 +329,9 @@ class ProfileNode(metaclass=caching.WeakInstMeta):
             if len(l) == 1:
                 logger.error(f'{relpath!r}, line {lineno}: missing USE flag(s): {line!r}')
                 continue
+            if any(s.endswith(':') for s in l[1:]):
+                logger.error(f'{relpath!r}, line {lineno}: USE_EXPAND syntax is invalid in this context: {line!r}')
+                continue
             d[a.key].append(misc.chunked_data(a, *split_negations(l[1:])))
 
         return ImmutableDict((k, misc._build_cp_atom_payload(v, atom(k)))


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-11-26 11:17 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-11-26 11:17 UTC (permalink / raw
  To: gentoo-commits

commit:     183ffa12e8c03080feeaab2f5bf8907f6a011fd6
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 01:23:37 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 11:17:13 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=183ffa12

pkgcore: atom: fix typo in error message

Signed-off-by: Sam James <sam <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgcore/pull/378
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/atom.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/atom.py b/src/pkgcore/ebuild/atom.py
index f8a24d61f..88de97e87 100644
--- a/src/pkgcore/ebuild/atom.py
+++ b/src/pkgcore/ebuild/atom.py
@@ -253,7 +253,7 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
                 raise errors.MalformedAtom(orig_atom, "operator requires a version")
             elif self.op == '~' and self.revision:
                 raise errors.MalformedAtom(orig_atom,
-                    "~ revision operater cannot be combined with a revision")
+                    "~ revision operator cannot be combined with a revision")
         elif self.version is not None:
             raise errors.MalformedAtom(orig_atom, 'versioned atom requires an operator')
         sf(self, "_hash", hash(orig_atom))


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-13 19:58 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-13 19:58 UTC (permalink / raw
  To: gentoo-commits

commit:     3ab961d6aa165a53b7319fefad0540ada676d6cd
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 13 19:50:38 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 13 19:50:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=3ab961d6

eclass: fix exported bash functions leak

Closes: https://bugs.gentoo.org/836210
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/eclass.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/eclass.py b/src/pkgcore/ebuild/eclass.py
index 2e970cb68..9c7d1fd20 100644
--- a/src/pkgcore/ebuild/eclass.py
+++ b/src/pkgcore/ebuild/eclass.py
@@ -384,7 +384,7 @@ class EclassDoc(AttrDict):
         # TODO: support this via pkgcore's ebd
         # source eclass to determine PROPERTIES
         p = subprocess.run(
-            ['bash', '-c',
+            ['env', '-i', 'bash', '-c',
                 f'source {shlex.quote(path)}; '
                 f'compgen -A function; '
                 f'echo "#"; '


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     c88bd73db0e50403709588e77c2e4b27ad16ffc8
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Wed Dec 21 20:38:56 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c88bd73d

Reuse the existing regex match rather than running it twice.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/ebuild_src.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/ebuild_src.py b/src/pkgcore/ebuild/ebuild_src.py
index baa29923e..0a2d836c3 100644
--- a/src/pkgcore/ebuild/ebuild_src.py
+++ b/src/pkgcore/ebuild/ebuild_src.py
@@ -250,7 +250,7 @@ class base(metadata.package):
             if line[0:1] in ('', '#'):
                 continue
             if (mo := _EAPI_str_regex.match(line)) and (eapi_str := mo.group('EAPI')):
-                eapi = _EAPI_regex.match(line).group('EAPI')
+                eapi = eapi_str
             break
         i.close()
         try:


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     f61835df6200ed8791130ce9837a5eb31e29006e
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Wed Dec 21 19:18:19 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=f61835df

s/slot/subslot/; name the parameter correctly

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/restricts.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pkgcore/ebuild/restricts.py b/src/pkgcore/ebuild/restricts.py
index 4736b192b..2ea74bc6c 100644
--- a/src/pkgcore/ebuild/restricts.py
+++ b/src/pkgcore/ebuild/restricts.py
@@ -155,8 +155,8 @@ class SubSlotDep(packages.PackageRestriction):
     __slots__ = ()
     __inst_caching__ = True
 
-    def __init__(self, slot, **kwds):
-        v = values.StrExactMatch(slot)
+    def __init__(self, subslot, **kwds):
+        v = values.StrExactMatch(subslot)
         super().__init__('subslot', v, negate=kwds.get('negate', False))
 
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     1ede34f996036605b6623dc0525df26826ac405d
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Sep 21 23:51:32 2021 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=1ede34f9

ebd_ipc: filter unpack results when needed.

The previous form was risky in that it assigned a generator
to consume from; this form of pattern can bite folks in the
ass; minimally, it makes tests trickier.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/ebd_ipc.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/pkgcore/ebuild/ebd_ipc.py b/src/pkgcore/ebuild/ebd_ipc.py
index e7947837f..403bb352a 100644
--- a/src/pkgcore/ebuild/ebd_ipc.py
+++ b/src/pkgcore/ebuild/ebd_ipc.py
@@ -1039,7 +1039,6 @@ class Unpack(IpcCommand):
     def parse_args(self, *args, **kwargs):
         args = super().parse_args(*args, **kwargs)
         self.opts.distdir = self.op.env['DISTDIR']
-        args.targets = self._filter_targets(args.targets)
         return args
 
     def _filter_targets(self, targets):
@@ -1090,7 +1089,7 @@ class Unpack(IpcCommand):
             spawn_kwargs['uid'] = os_data.portage_uid
             spawn_kwargs['gid'] = os_data.portage_gid
 
-        for filename, ext, source in args.targets:
+        for filename, ext, source in self._filter_targets(args.targets):
             self.observer.write(f'>>> Unpacking {filename} to {self.cwd}', autoline=True)
             self.observer.flush()
             dest = pjoin(self.cwd, os.path.basename(filename[:-len(ext)]))


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     409eb6072b548811e669ec5a49b65316ddd35132
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sun Aug 23 19:07:26 2020 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=409eb607

Drop dead code comment

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/conditionals.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/pkgcore/ebuild/conditionals.py b/src/pkgcore/ebuild/conditionals.py
index edcc2f33c..71b3a3e02 100644
--- a/src/pkgcore/ebuild/conditionals.py
+++ b/src/pkgcore/ebuild/conditionals.py
@@ -150,7 +150,6 @@ class DepSet(boolean.AndRestriction):
             raise DepsetParseError(dep_str, attr=attr)
 
         if transitive_use_atoms and not node_conds:
-            # localize to this scope for speed.
             element_class = transitive_use_atom
             # we can't rely on iter(self) here since it doesn't
             # descend through boolean restricts.


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-22  7:11 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-22  7:11 UTC (permalink / raw
  To: gentoo-commits

commit:     b421967e2b988f13bb6ec02657b57f109b0a7256
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Thu Dec 22 01:45:17 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 02:53:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=b421967e

Update __all__ for ebuild.restricts

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/pkgcore/ebuild/restricts.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/restricts.py b/src/pkgcore/ebuild/restricts.py
index 2ea74bc6c..8240717e8 100644
--- a/src/pkgcore/ebuild/restricts.py
+++ b/src/pkgcore/ebuild/restricts.py
@@ -5,7 +5,9 @@
 atom version restrict
 """
 
-__all__ = ("VersionMatch",)
+__all__ = ("CategoryDep", "PackageDep", "RepositoryDep", "SlotDep",
+    "StaticUseDep", "SubSlotDep", "UseDepDefault", "VersionMatch"
+)
 
 from snakeoil.klass import generic_equality
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-25 17:40 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-25 17:40 UTC (permalink / raw
  To: gentoo-commits

commit:     ce1173fe24f8466a23c502a52af38cdab42353a2
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sat Dec 24 22:23:54 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 25 17:40:11 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=ce1173fe

Fix secondary exception from when an EBD fails to start.

Further in this __init__, self.pid is initialized to the process
that is started.  If that fails- an exception is thrown- then
self.pid doesn't exist, which in turn breaks the assumptions of
`shutdown_processor()` and `.is_alive` (both of which are
designed to work if an init partially failed).

Finally, add protections to ensure a failed spawn doesn't leak
file descriptors.  Python won't reap raw FD's, so we need to
handle this gracefully.

This secondary exception is visible in pkgcore/pkgcore#296

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/383
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/processor.py | 49 ++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/src/pkgcore/ebuild/processor.py b/src/pkgcore/ebuild/processor.py
index 6157ad692..8e9bf13cd 100644
--- a/src/pkgcore/ebuild/processor.py
+++ b/src/pkgcore/ebuild/processor.py
@@ -324,6 +324,7 @@ class EbuildProcessor:
         self._eclass_caching = False
         self._outstanding_expects = []
         self._metadata_paths = None
+        self.pid = None
 
         spawn_opts = {'umask': 0o002}
         if self.userpriv:
@@ -371,25 +372,37 @@ class EbuildProcessor:
             "PKGCORE_EBD_WRITE_FD": str(max_fd - 3),
         })
 
+        cread = cwrite = dread = dwrite = None
         # open pipes used for communication
-        cread, cwrite = os.pipe()
-        dread, dwrite = os.pipe()
-
-        # allow pipe overrides except ebd-related
-        ebd_pipes = {0: 0, 1: 1, 2: 2}
-        if fd_pipes:
-            ebd_pipes.update(fd_pipes)
-        ebd_pipes[max_fd - 4] = cread
-        ebd_pipes[max_fd - 3] = dwrite
-
-        # force each ebd instance to be a process group leader so everything
-        # can be easily terminated
-        self.pid = spawn_func(
-            [spawn.BASH_BINARY, self.ebd, "daemonize"],
-            fd_pipes=ebd_pipes, returnpid=True, env=env, pgid=0, **spawn_opts)[0]
-
-        os.close(cread)
-        os.close(dwrite)
+        try:
+            cread, cwrite = os.pipe()
+            dread, dwrite = os.pipe()
+
+            # allow pipe overrides except ebd-related
+            ebd_pipes = {0: 0, 1: 1, 2: 2}
+            if fd_pipes:
+                ebd_pipes.update(fd_pipes)
+            ebd_pipes[max_fd - 4] = cread
+            ebd_pipes[max_fd - 3] = dwrite
+
+            self.pid = spawn_func(
+                [spawn.BASH_BINARY, self.ebd, "daemonize"],
+                fd_pipes=ebd_pipes, returnpid=True, env=env,
+                # force each ebd instance to be a process group leader so everything
+                # can be easily terminated
+                pgid=0,
+                **spawn_opts)[0]
+        except:
+                if cwrite is not None:
+                    os.close(cwrite)
+                if dread is not None:
+                    os.close(dread)
+                raise
+        finally:
+            if cread is not None:
+                os.close(cread)
+            if dwrite is not None:
+                os.close(dwrite)
         self.ebd_write = os.fdopen(cwrite, "w")
         self.ebd_read = os.fdopen(dread, "r")
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     9806022b0ca911da412c47227f0ca031783a09b9
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sun Dec 25 21:20:57 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:23 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=9806022b

Simplify some class attribute building.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/domain.py | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/pkgcore/ebuild/domain.py b/src/pkgcore/ebuild/domain.py
index 15f2b2179..4e33e0fc9 100644
--- a/src/pkgcore/ebuild/domain.py
+++ b/src/pkgcore/ebuild/domain.py
@@ -188,25 +188,25 @@ def load_property(
 class domain(config_domain):
 
     # XXX ouch, verify this crap and add defaults and stuff
-    _types = {
-        "profile": "ref:profile",
-        "repos": "lazy_refs:repo",
-        "vdb": "lazy_refs:repo",
-    }
-    for _thing in (
-        "root",
-        "config_dir",
-        "CHOST",
-        "CBUILD",
-        "CTARGET",
-        "CFLAGS",
-        "PATH",
-        "PORTAGE_TMPDIR",
-        "DISTCC_PATH",
-        "DISTCC_DIR",
-        "CCACHE_DIR",
-    ):
-        _types[_thing] = "str"
+    _types = dict.fromkeys(
+        (
+            "root",
+            "config_dir",
+            "CHOST",
+            "CBUILD",
+            "CTARGET",
+            "CFLAGS",
+            "PATH",
+            "PORTAGE_TMPDIR",
+            "DISTCC_PATH",
+            "DISTCC_DIR",
+            "CCACHE_DIR",
+        ),
+        "str",
+    )
+    _types["profile"] = "ref:profile"
+    _types["repos"] = "lazy_refs:repo"
+    _types["vdb"] = "lazy_refs:repo"
 
     # TODO this is missing defaults
     pkgcore_config_type = ConfigHint(
@@ -216,7 +216,7 @@ class domain(config_domain):
         allow_unknowns=True,
     )
 
-    del _types, _thing
+    del _types
 
     def __init__(
         self,


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     7e80f6fc4739ae2c67929d26b47793f90098b5f4
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 04:16:46 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:25 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=7e80f6fc

Throw an exception (py side) for any EBD var starting with '_'

Closes: https://github.com/pkgcore/pkgcore/pull/333
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/processor.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/pkgcore/ebuild/processor.py b/src/pkgcore/ebuild/processor.py
index a4eec7afe..a2f02fd45 100644
--- a/src/pkgcore/ebuild/processor.py
+++ b/src/pkgcore/ebuild/processor.py
@@ -739,8 +739,10 @@ class EbuildProcessor:
         for key, val in sorted(env_dict.items()):
             if key in self._readonly_vars:
                 continue
-            if not key[0].isalpha():
-                raise KeyError(f"{key}: bash doesn't allow digits as the first char")
+            if not key[0].isalpha() and not key.startswith("_"):
+                raise KeyError(
+                    f"{key}: bash doesn't allow digits or _ as the first char"
+                )
             if not isinstance(val, (str, list, tuple)):
                 raise ValueError(
                     f"_generate_env_str was fed a bad value; key={key}, val={val}"


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     621c460b9be22c14d42fa8ca229e60582aee8067
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 00:19:43 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=621c460b

Add a constant of the latest PMS version, and add use flag validation to EAPI.

Currently no EAPI varies the use flag parsing rules, but if it ever comes up,
this will address it.

In the process, this also will be used to move some logic out of atom.py whilst
introducing the concept of 'latest PMS' as the 'latest' rules to parse under in
the absense of an explicit directive.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/eapi.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/pkgcore/ebuild/eapi.py b/src/pkgcore/ebuild/eapi.py
index 2ec7557e0..85ba43be7 100644
--- a/src/pkgcore/ebuild/eapi.py
+++ b/src/pkgcore/ebuild/eapi.py
@@ -12,10 +12,19 @@ from snakeoil.mappings import ImmutableDict, OrderedFrozenSet, inject_getitem_as
 from snakeoil.osutils import pjoin
 from snakeoil.process.spawn import bash_version
 
+LATEST_PMS_EAPI_VER = "8"
+
+
+def get_latest_PMS_eapi():
+    """return the latest PMS EAPI object known to this version of pkgcore"""
+    return get_eapi(LATEST_PMS_EAPI_VER)
+
+
 from ..log import logger
 from . import atom, const
 
 demand_compile_regexp("_valid_EAPI_regex", r"^[A-Za-z0-9_][A-Za-z0-9+_.-]*$")
+demand_compile_regexp("_valid_use_flag", r"^[A-Za-z0-9][A-Za-z0-9+_@-]*$")
 
 eapi_optionals = ImmutableDict(
     {
@@ -461,6 +470,10 @@ class EAPI(metaclass=klass.immutable_instance):
         d["EAPI"] = self._magic
         return ImmutableDict(d)
 
+    def is_valid_use_flag(self, s: str) -> bool:
+        """returns True if the flag is parsable under this EAPI"""
+        return _valid_use_flag.match(s) is not None
+
 
 def get_eapi(magic, suppress_unsupported=True):
     """Return EAPI object for a given identifier."""


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     c782af0cd25f28f5331aa3930b5b3abfb515398c
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 00:48:56 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c782af0c

Expand EAPI object declarations of support, wire atom to use it.

Specifically, this moves strong blockers, use deps, and slot deps to
rely upon the EAPI context of the atom parse.  EAPI ultimately has say
on this, thus just remove the 15+ year old hardcoded constants and use
eapi_obj instead.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/atom.py | 34 +++++++++++++++++++---------------
 src/pkgcore/ebuild/eapi.py |  9 +++++++++
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/src/pkgcore/ebuild/atom.py b/src/pkgcore/ebuild/atom.py
index 0bcd76b6c..166d8c7b0 100644
--- a/src/pkgcore/ebuild/atom.py
+++ b/src/pkgcore/ebuild/atom.py
@@ -136,7 +136,7 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
                         if not eapi_obj.options.has_use_dep_defaults:
                             raise errors.MalformedAtom(
                                 orig_atom,
-                                f"use dep defaults are not allowed in EAPI {eapi_obj}",
+                                f"use dep defaults are not allowed in EAPI {eapi}",
                             )
 
                         # use defaults.
@@ -202,9 +202,9 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
                             slot_operator = "="
                             slot = slot[:-1]
                         slots = slot.split("/", 1)
-                elif eapi == "0":
+                elif not eapi_obj.options.has_slot_deps:
                     raise errors.MalformedAtom(
-                        orig_atom, "slot dependencies aren't allowed in EAPI 0"
+                        orig_atom, f"slot dependencies aren't allowed in EAPI {eapi}"
                     )
 
                 for chunk in slots:
@@ -245,7 +245,11 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
             atom = atom[1:]
             # hackish/slow, but lstrip doesn't take a 'prune this many' arg
             # open to alternatives
-            if eapi not in ("0", "1") and atom.startswith("!"):
+            if atom.startswith("!"):
+                if not eapi_obj.options.strong_blockers:
+                    raise MalformedAtom(
+                        f"strong blockers are not supported in EAPI {eapi}"
+                    )
                 atom = atom[1:]
                 sf(self, "blocks_strongly", True)
             else:
@@ -274,17 +278,17 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
             sf(self, "op", "")
         sf(self, "cpvstr", atom)
 
-        if eapi == "0":
-            for x in ("use", "slot"):
-                if getattr(self, x) is not None:
-                    raise errors.MalformedAtom(
-                        orig_atom, f"{x} atoms aren't supported for EAPI 0"
-                    )
-        elif eapi == "1":
-            if self.use is not None:
-                raise errors.MalformedAtom(
-                    orig_atom, "use atoms aren't supported for EAPI < 2"
-                )
+        if self.slot is not None and not eapi_obj.options.has_slot_deps:
+            raise errors.MalformedAtom(
+                orig_atom, f"{x} SLOT dep atoms aren't supported in EAPI {eapi}"
+            )
+
+        elif self.use is not None and not eapi_obj.options.has_use_deps:
+            raise errors.MalformedAtom(
+                orig_atom, "use atoms aren't supported for EAPI < 2"
+            )
+
+        # note that we're checking eapi, not eapi_obj.  eapi_obj defaults to latest PMS
         if eapi != "-1":
             if self.repo_id is not None:
                 raise errors.MalformedAtom(

diff --git a/src/pkgcore/ebuild/eapi.py b/src/pkgcore/ebuild/eapi.py
index 85ba43be7..3754402e0 100644
--- a/src/pkgcore/ebuild/eapi.py
+++ b/src/pkgcore/ebuild/eapi.py
@@ -52,6 +52,10 @@ eapi_optionals = ImmutableDict(
         "has_portdir": True,
         # Controls whether DESTTREE and INSDESTTREE are exported during src_install; see PMS.
         "has_desttree": True,
+        # Controls whether atoms support USE dependencies.
+        "has_use_deps": False,
+        # Controls wheter atoms support slot dependencies",
+        "has_slot_deps": False,
         # Controls whether ROOT, EROOT, D, and ED end with a trailing slash; see PMS.
         "trailing_slash": os.sep,
         # Controls whether SYSROOT, ESYSROOT, and BROOT are defined; see PMS.
@@ -105,6 +109,8 @@ eapi_optionals = ImmutableDict(
         "src_uri_renames": False,
         # Controls whether SRC_URI supports fetch+ and mirror+ prefixes.
         "src_uri_unrestrict": False,
+        # Controls whether strong blockers- hard deps of "things are broken after this merge" are supported for atom syntax.
+        "strong_blockers": False,
         # Controls whether or not use dependency atoms are able to control their enforced
         # value relative to another; standard use deps just enforce either on or off; EAPIs
         # supporting this allow syntax that can enforce (for example) X to be on if Y is on.
@@ -646,6 +652,7 @@ eapi1 = EAPI.register(
         eapi0.options,
         dict(
             iuse_defaults=True,
+            has_slot_deps=True,
         ),
     ),
     ebd_env_options=eapi0._ebd_env_options,
@@ -669,6 +676,8 @@ eapi2 = EAPI.register(
     optionals=_combine_dicts(
         eapi1.options,
         dict(
+            has_use_deps=True,
+            strong_blockers=True,
             doman_language_detect=True,
             transitive_use_atoms=True,
             src_uri_renames=True,


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     eb6f4edd28d8e25e7ce5aa246f246c51a8bb2211
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 00:21:59 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=eb6f4edd

Move valid_use_flag parsing out of atom, rely upon eapi obj.

EAPI objects are responsible for deciding the rules of how to parse
atoms, and this extends to use flags.  Thus just ask the EAPI obj
to tell us "is it valid?".

In moving this out of atom.py it allows us to lace that validation
into other configuration loading aspects of the code.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/atom.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/pkgcore/ebuild/atom.py b/src/pkgcore/ebuild/atom.py
index 1be4405ac..c24a6d9ef 100644
--- a/src/pkgcore/ebuild/atom.py
+++ b/src/pkgcore/ebuild/atom.py
@@ -11,13 +11,14 @@ import string
 
 from snakeoil import klass
 from snakeoil.compatibility import cmp
-from snakeoil.demandload import demand_compile_regexp
 
 from ..restrictions import boolean, packages, restriction, values
 from ..restrictions.packages import AndRestriction as PkgAndRestriction
 from ..restrictions.packages import Conditional
 from ..restrictions.values import ContainmentMatch
-from . import cpv, errors, restricts
+from . import cpv
+from . import eapi as eapi_mod
+from . import errors, restricts
 
 # namespace compatibility...
 MalformedAtom = errors.MalformedAtom
@@ -34,8 +35,6 @@ valid_repo_chars = frozenset(valid_repo_chars)
 valid_slot_chars = frozenset(valid_slot_chars)
 valid_ops = frozenset(["<", "<=", "=", "~", ">=", ">"])
 
-demand_compile_regexp("valid_use_flag", r"^[A-Za-z0-9][A-Za-z0-9+_@-]*$")
-
 
 class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
     """Currently implements gentoo ebuild atom parsing.
@@ -102,6 +101,9 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
         override_kls = False
         use_start = atom.find("[")
         slot_start = atom.find(":")
+        eapi_obj = eapi_mod.get_eapi(
+            eapi if eapi != "-1" else eapi_mod.LATEST_PMS_EAPI_VER
+        )
 
         if use_start != -1:
             # use dep
@@ -137,7 +139,7 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
 
                     if not x:
                         raise errors.MalformedAtom(orig_atom, "empty use dep detected")
-                    if not valid_use_flag.match(x):
+                    if not eapi_obj.is_valid_use_flag(x):
                         raise errors.MalformedAtom(
                             orig_atom, f"invalid USE flag: {x!r}"
                         )


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2022-12-26 17:28 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2022-12-26 17:28 UTC (permalink / raw
  To: gentoo-commits

commit:     4bd982b59ab334c2c8da7f700034dc9ca71c048a
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 00:32:13 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Dec 26 17:27:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=4bd982b5

Convert to eapi_obj usage for subslot/iuse defaults in atom parsing.

We already paid the cost of looking up the eapi obj constants, thus use it,
and remove the atom implementations awareness of magic eapi constants.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/atom.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/pkgcore/ebuild/atom.py b/src/pkgcore/ebuild/atom.py
index c24a6d9ef..0bcd76b6c 100644
--- a/src/pkgcore/ebuild/atom.py
+++ b/src/pkgcore/ebuild/atom.py
@@ -132,7 +132,13 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
                     elif x[0] == "-":
                         x = x[1:]
 
-                    if x[-1] == ")" and eapi not in ("0", "1", "2", "3"):
+                    if x[-1] == ")":
+                        if not eapi_obj.options.has_use_dep_defaults:
+                            raise errors.MalformedAtom(
+                                orig_atom,
+                                f"use dep defaults are not allowed in EAPI {eapi_obj}",
+                            )
+
                         # use defaults.
                         if x[-3:] in ("(+)", "(-)"):
                             x = x[:-3]
@@ -182,7 +188,7 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
                 slot = None
             else:
                 slots = (slot,)
-                if eapi not in ("0", "1", "2", "3", "4"):
+                if eapi_obj.options.sub_slotting:
                     if slot[0:1] in ("*", "="):
                         if len(slot) > 1:
                             raise errors.MalformedAtom(


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-01-03 18:06 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-01-03 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     36bed5c684f87e1b14bb9ccfbc44937dbfd5198b
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  2 20:04:47 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jan  2 20:04:47 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=36bed5c6

portage_conf: add support for make.profile as directory

Support /etc/portage/make.profile as a directory, and not as symbolic
link. In this state, /etc/portage/profile takes precedence over, and
this is taken as a "normal" profile. We need to make sure that
`load_profile_base` is turned off, as profiles base is irrelevant now.

Resolves: https://github.com/pkgcore/pkgcore/issues/305
Resolves: https://github.com/pkgcore/pkgcheck/issues/426
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/portage_conf.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/pkgcore/ebuild/portage_conf.py b/src/pkgcore/ebuild/portage_conf.py
index 907a1a2dd..815d563d4 100644
--- a/src/pkgcore/ebuild/portage_conf.py
+++ b/src/pkgcore/ebuild/portage_conf.py
@@ -542,13 +542,11 @@ class PortageConfig(DictMixin):
         except FileNotFoundError:
             pass
 
-    def _find_profile_path(self, profile_override):
+    def _find_profile_path(self, profile_override) -> tuple[str, bool]:
         if profile_override is None:
             make_profile = pjoin(self.dir, "make.profile")
             if not os.path.islink(make_profile):
-                raise config_errors.UserConfigError(
-                    f"invalid symlink: {make_profile!r}"
-                )
+                return make_profile, True
             path = os.path.realpath(make_profile)
         else:
             path = os.path.realpath(profile_override)
@@ -560,15 +558,17 @@ class PortageConfig(DictMixin):
                 raise config_errors.UserConfigError(
                     f"nonexistent profile: {profile_override!r}"
                 )
-        return path
+        return path, False
 
     def _add_profile(self, profile_override=None):
-        profile = self._find_profile_path(profile_override)
-        paths = profiles.OnDiskProfile.split_abspath(profile)
+        profile, was_symlink = self._find_profile_path(profile_override)
+        if was_symlink:
+            paths = profile.rsplit(os.path.sep, 1)
+        else:
+            paths = profiles.OnDiskProfile.split_abspath(profile)
         if paths is None:
             raise config_errors.UserConfigError(
-                "%r expands to %r, but no profile detected"
-                % (pjoin(self.dir, "make.profile"), profile)
+                f"{pjoin(self.dir, 'make.profile')!r} expands to {profile!r}, but no profile detected"
             )
 
         user_profile_path = pjoin(self.dir, "profile")
@@ -579,6 +579,7 @@ class PortageConfig(DictMixin):
                     "parent_path": paths[0],
                     "parent_profile": paths[1],
                     "user_path": user_profile_path,
+                    "load_profile_base": not was_symlink,
                 }
             )
         else:
@@ -587,6 +588,7 @@ class PortageConfig(DictMixin):
                     "class": "pkgcore.ebuild.profiles.OnDiskProfile",
                     "basepath": paths[0],
                     "profile": paths[1],
+                    "load_profile_base": not was_symlink,
                 }
             )
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-01-17 20:50 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-01-17 20:50 UTC (permalink / raw
  To: gentoo-commits

commit:     805b7c32b2fa5baaac276386c58f5aff3458087d
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 26 21:49:08 2022 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 20:49:47 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=805b7c32

refactor(portage_conf): Use f'' syntax for GENTOO_MIRRORS listcomp

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/portage_conf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/portage_conf.py b/src/pkgcore/ebuild/portage_conf.py
index 9e5fffac7..7d9d131aa 100644
--- a/src/pkgcore/ebuild/portage_conf.py
+++ b/src/pkgcore/ebuild/portage_conf.py
@@ -153,7 +153,7 @@ class PortageConfig(DictMixin):
 
         self.root = kwargs.pop("root", make_conf.get("ROOT", "/"))
         gentoo_mirrors = [
-            x.rstrip("/") + "/distfiles"
+            f"{x.rstrip('/')}/distfiles"
             for x in make_conf.pop("GENTOO_MIRRORS", "").split()
         ]
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-02-04 19:52 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-02-04 19:52 UTC (permalink / raw
  To: gentoo-commits

commit:     cdcf8dfa018c2c40368a60e2cc44dcba7f9fa4f5
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  4 19:50:13 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Feb  4 19:50:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=cdcf8dfa

ebuild.repository: fix traversal from root of overlays

Resolves: https://github.com/pkgcore/pkgcheck/issues/418
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/repository.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index ce61c4544..800e6e5dd 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -399,8 +399,10 @@ class UnconfiguredTree(prototype.tree):
             path_chunks = path.split(os.path.sep)
         else:
             path = os.path.realpath(os.path.abspath(path))
-            relpath = path[len(os.path.realpath(self.location)) :].strip("/")
-            path_chunks = relpath.split(os.path.sep)
+            if relpath := path[len(os.path.realpath(self.location)) :].strip("/"):
+                path_chunks = relpath.split(os.path.sep)
+            else:
+                path_chunks = ()
 
         if os.path.isfile(path):
             if not path.endswith(".ebuild"):


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-06-30 20:08 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-06-30 20:08 UTC (permalink / raw
  To: gentoo-commits

commit:     b274e2aa89271710357abea944cddd1a1a331877
Author:     Eric Huber <echuber2 <AT> illinois <DOT> edu>
AuthorDate: Thu Jun 29 06:42:16 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jun 30 20:08:44 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=b274e2aa

manifest: fix missing errors when all ebuilds for package are masked bad

If all of a package's ebuild files have been masked bad, that package
gets filtered out of the iterator for the previous loop in this
function, so a followup loop over the masked bad packages can help to
emit the unreported errors.

Resolves: https://github.com/pkgcore/pkgdev/issues/55
Co-authored-by: YiFei Zhu <zhuyifei1999 <AT> gmail.com>
Authored-by: Eric Huber <echuber2 <AT> illinois.edu>
Closes: https://github.com/pkgcore/pkgcore/pull/406
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/repository.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/pkgcore/ebuild/repository.py b/src/pkgcore/ebuild/repository.py
index 800e6e5dd..164aa0c97 100644
--- a/src/pkgcore/ebuild/repository.py
+++ b/src/pkgcore/ebuild/repository.py
@@ -161,6 +161,18 @@ class repo_operations(_repo_ops.operations):
                 observer.info(f"generating manifest: {key}::{self.repo.repo_id}")
                 manifest.update(sorted(all_fetchables.values()), chfs=write_chksums)
 
+        # edge case: If all ebuilds for a package were masked bad,
+        # then it was filtered out of the iterator for the above loop,
+        # so we handle unreported bad packages here.
+        missed_bad_set = set()
+        for pkg in self.repo._bad_masked:
+            if pkg.key not in ret:
+                observer.error(
+                    f"{pkg.cpvstr}: {pkg.data.msg(verbosity=observer.verbosity)}"
+                )
+                missed_bad_set.add(pkg.key)
+        ret.update(missed_bad_set)
+
         return ret
 
 


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-10-23 17:35 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-10-23 17:35 UTC (permalink / raw
  To: gentoo-commits

commit:     6749d045ad29ea56eec1e380335594c37d53efde
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 23 17:03:29 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 23 17:03:29 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=6749d045

eclassdoc: parse default and initial values

A little bit ugly, but does the job.
Resolves: https://github.com/pkgcore/pkgcore/issues/297

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/eclass.py | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/pkgcore/ebuild/eclass.py b/src/pkgcore/ebuild/eclass.py
index 9859f6571..f1a0cacdf 100644
--- a/src/pkgcore/ebuild/eclass.py
+++ b/src/pkgcore/ebuild/eclass.py
@@ -173,7 +173,7 @@ class ParseEclassDoc:
         """Return default field mapping for the block."""
         return {name: default for name, _required, _func, default in self.tags.values()}
 
-    def parse(self, lines, line_ind):
+    def parse(self, lines, line_ind, _next_line):
         """Parse an eclass block."""
         blocks = []
         data = self.defaults
@@ -260,6 +260,15 @@ class EclassVarBlock(ParseEclassDoc):
         }
         super().__init__(tags)
 
+    def parse(self, lines, line_ind, next_line):
+        data = dict(super().parse(lines, line_ind, next_line))
+        var_name = data["name"]
+        if mo := re.search(rf"{var_name}=(?P<value>.*)", next_line):
+            data["initial_value"] = mo.group("value")
+        if mo := re.search(rf": \${{{var_name}:?=(?P<value>.*)}}", next_line):
+            data["default_value"] = mo.group("value")
+        return AttrDict(data)
+
 
 # For backwards compatibility, can be removed after 2022-12-31
 class EclassVarBlockCompat(ParseEclassDoc):
@@ -492,13 +501,13 @@ class EclassDoc(AttrDict):
                     block = []
                     block_start = line_ind + 1
                     while line_ind < len(lines):
-                        line = lines[line_ind]
+                        next_line = line = lines[line_ind]
                         if not line.startswith(prefix):
                             break
                         line = line[len(prefix) + 1 :]
                         block.append(line)
                         line_ind += 1
-                    blocks.append((tag, block, block_start))
+                    blocks.append((tag, block, block_start, next_line))
                 line_ind += 1
 
         # set default fields
@@ -526,9 +535,9 @@ class EclassDoc(AttrDict):
         duplicates = {k: set() for k in ParseEclassDoc.blocks}
 
         # parse identified blocks
-        for tag, block, block_start in blocks:
+        for tag, block, block_start, next_line in blocks:
             block_obj = ParseEclassDoc.blocks[tag]
-            block_data = block_obj.parse(block, block_start)
+            block_data = block_obj.parse(block, block_start, next_line)
             # check if duplicate blocks exist and merge data
             if block_obj.key is None:
                 # main @ECLASS block
@@ -619,6 +628,10 @@ class EclassDoc(AttrDict):
             rst.extend(_header_only("-", "Variables"))
             for var in external_vars:
                 vartype = ""
+                if default_value := getattr(var, "default_value", None):
+                    vartype += f" ?= *{default_value}*"
+                elif initial_value := getattr(var, "initial_value", None):
+                    vartype += f" = *{initial_value}*"
                 if var.required:
                     vartype += " (REQUIRED)"
                 if var.pre_inherit:


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2023-12-26 17:45 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2023-12-26 17:45 UTC (permalink / raw
  To: gentoo-commits

commit:     1a54ac9c95fd230234f4c680ceda79a3de668b7f
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Mon Dec 25 21:45:08 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=1a54ac9c

atom: limit the start of a slot to left of use components.

It's a minor redundant protection + optimization, but
it's worth ensuring the only spot considered for a slot prefix
is left of any use restrictions.

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/atom.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/atom.py b/src/pkgcore/ebuild/atom.py
index f8725f607..0dc046fa4 100644
--- a/src/pkgcore/ebuild/atom.py
+++ b/src/pkgcore/ebuild/atom.py
@@ -99,7 +99,8 @@ class atom(boolean.AndRestriction, metaclass=klass.generic_equality):
         orig_atom = atom
         override_kls = False
         use_start = atom.find("[")
-        slot_start = atom.find(":")
+        # ensure slot or repo anchoring is left of use flags.
+        slot_start = atom.find(":", 0, use_start)
         eapi_obj = eapi_mod.get_eapi(
             eapi if eapi != "-1" else eapi_mod.LATEST_PMS_EAPI_VER
         )


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
@ 2024-06-13 16:40 Arthur Zamarin
  0 siblings, 0 replies; 24+ messages in thread
From: Arthur Zamarin @ 2024-06-13 16:40 UTC (permalink / raw
  To: gentoo-commits

commit:     8dafaea39bf9bc9eb168e334837b6d2b7ee7d32d
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 11 14:39:25 2024 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 16:39:40 2024 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=8dafaea3

ebuild.profiles: Fix case where a parent path omits the repo identifier

According "SPECIFIC FILE DESCRIPTIONS" in `man portage`, it is valid to
have a parent path like `:path/to/profile` where the repo identifier is
missing. This refers to a path in the current repo.

Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgcore/pull/435
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/profiles.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pkgcore/ebuild/profiles.py b/src/pkgcore/ebuild/profiles.py
index 384e41e22..fea1eacc7 100644
--- a/src/pkgcore/ebuild/profiles.py
+++ b/src/pkgcore/ebuild/profiles.py
@@ -254,6 +254,8 @@ class ProfileNode(metaclass=caching.WeakInstMeta):
                                     f"unknown repo {repo_id!r}"
                                 )
                                 continue
+                    else:
+                        location = repo_config.location
                     l.append(
                         (
                             abspath(pjoin(location, "profiles", profile_path)),


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-06-13 16:40 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-26 17:45 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/ Arthur Zamarin
  -- strict thread matches above, loose matches on Subject: below --
2024-06-13 16:40 Arthur Zamarin
2023-10-23 17:35 Arthur Zamarin
2023-06-30 20:08 Arthur Zamarin
2023-02-04 19:52 Arthur Zamarin
2023-01-17 20:50 Arthur Zamarin
2023-01-03 18:06 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-26 17:28 Arthur Zamarin
2022-12-25 17:40 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-12-22  7:11 Arthur Zamarin
2022-12-13 19:58 Arthur Zamarin
2022-11-26 11:17 Arthur Zamarin
2022-10-29 11:56 Arthur Zamarin
2022-10-16 16:38 Arthur Zamarin
2022-10-04  8:24 Arthur Zamarin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox