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,
                 }
             )
 

Reply via email to