Gentoo Archives: gentoo-commits

From: Arthur Zamarin <arthurzam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/
Date: Tue, 03 Jan 2023 18:06:34
Message-Id: 1672689887.36bed5c684f87e1b14bb9ccfbc44937dbfd5198b.arthurzam@gentoo
1 commit: 36bed5c684f87e1b14bb9ccfbc44937dbfd5198b
2 Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 2 20:04:47 2023 +0000
4 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 2 20:04:47 2023 +0000
6 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=36bed5c6
7
8 portage_conf: add support for make.profile as directory
9
10 Support /etc/portage/make.profile as a directory, and not as symbolic
11 link. In this state, /etc/portage/profile takes precedence over, and
12 this is taken as a "normal" profile. We need to make sure that
13 `load_profile_base` is turned off, as profiles base is irrelevant now.
14
15 Resolves: https://github.com/pkgcore/pkgcore/issues/305
16 Resolves: https://github.com/pkgcore/pkgcheck/issues/426
17 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
18
19 src/pkgcore/ebuild/portage_conf.py | 20 +++++++++++---------
20 1 file changed, 11 insertions(+), 9 deletions(-)
21
22 diff --git a/src/pkgcore/ebuild/portage_conf.py b/src/pkgcore/ebuild/portage_conf.py
23 index 907a1a2dd..815d563d4 100644
24 --- a/src/pkgcore/ebuild/portage_conf.py
25 +++ b/src/pkgcore/ebuild/portage_conf.py
26 @@ -542,13 +542,11 @@ class PortageConfig(DictMixin):
27 except FileNotFoundError:
28 pass
29
30 - def _find_profile_path(self, profile_override):
31 + def _find_profile_path(self, profile_override) -> tuple[str, bool]:
32 if profile_override is None:
33 make_profile = pjoin(self.dir, "make.profile")
34 if not os.path.islink(make_profile):
35 - raise config_errors.UserConfigError(
36 - f"invalid symlink: {make_profile!r}"
37 - )
38 + return make_profile, True
39 path = os.path.realpath(make_profile)
40 else:
41 path = os.path.realpath(profile_override)
42 @@ -560,15 +558,17 @@ class PortageConfig(DictMixin):
43 raise config_errors.UserConfigError(
44 f"nonexistent profile: {profile_override!r}"
45 )
46 - return path
47 + return path, False
48
49 def _add_profile(self, profile_override=None):
50 - profile = self._find_profile_path(profile_override)
51 - paths = profiles.OnDiskProfile.split_abspath(profile)
52 + profile, was_symlink = self._find_profile_path(profile_override)
53 + if was_symlink:
54 + paths = profile.rsplit(os.path.sep, 1)
55 + else:
56 + paths = profiles.OnDiskProfile.split_abspath(profile)
57 if paths is None:
58 raise config_errors.UserConfigError(
59 - "%r expands to %r, but no profile detected"
60 - % (pjoin(self.dir, "make.profile"), profile)
61 + f"{pjoin(self.dir, 'make.profile')!r} expands to {profile!r}, but no profile detected"
62 )
63
64 user_profile_path = pjoin(self.dir, "profile")
65 @@ -579,6 +579,7 @@ class PortageConfig(DictMixin):
66 "parent_path": paths[0],
67 "parent_profile": paths[1],
68 "user_path": user_profile_path,
69 + "load_profile_base": not was_symlink,
70 }
71 )
72 else:
73 @@ -587,6 +588,7 @@ class PortageConfig(DictMixin):
74 "class": "pkgcore.ebuild.profiles.OnDiskProfile",
75 "basepath": paths[0],
76 "profile": paths[1],
77 + "load_profile_base": not was_symlink,
78 }
79 )