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,

Reply via email to