1 |
This commit fixes the following issues:
|
2 |
|
3 |
* The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
|
4 |
|
5 |
With this commit, the variable is no longer written to the
|
6 |
generated make.conf. Instead, a config file
|
7 |
/etc/portage/repos.conf/<repo-name>.conf
|
8 |
is generated for each overlay. The repo name is read from the
|
9 |
overlay using the portage API. Internally, portage parses
|
10 |
metadata/layout.conf and profiles/repo_name to obtain the name.
|
11 |
|
12 |
References:
|
13 |
https://wiki.gentoo.org/wiki//etc/portage/make.conf
|
14 |
https://wiki.gentoo.org/wiki//etc/portage/repos.conf
|
15 |
|
16 |
* All overlays were copied into the same target directory. If the
|
17 |
same file name occurred in multiple overlays, the last overlay
|
18 |
would overwrite all previous files with this name. In particular,
|
19 |
only the metadata/layout.conf of the last overlay was retained,
|
20 |
so it was not possible to reference the other overlays e.g. via
|
21 |
the masters entry in the layout.conf or the portage-2 syntax
|
22 |
for specifying a parent profile from another overlay. Also,
|
23 |
this created problems when the overlays contained ebuilds
|
24 |
for the same package, but with differing versions, because
|
25 |
after copying, the target directory contained both versions of the
|
26 |
ebuild but only the manifest file of the last overlay.
|
27 |
|
28 |
With this commit, each overlay is copied into a separate
|
29 |
sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
|
30 |
This directory is referenced via the location entry in the
|
31 |
generated /etc/portage/repos.conf/<repo-name>.conf.
|
32 |
---
|
33 |
catalyst/base/stagebase.py | 72 ++++++++++++++++++++++++++++----------
|
34 |
catalyst/defaults.py | 1 +
|
35 |
catalyst/support.py | 18 ++++++++++
|
36 |
3 files changed, 72 insertions(+), 19 deletions(-)
|
37 |
|
38 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
|
39 |
index ac0f4f24..3d4f2a76 100644
|
40 |
--- a/catalyst/base/stagebase.py
|
41 |
+++ b/catalyst/base/stagebase.py
|
42 |
@@ -1,4 +1,5 @@
|
43 |
|
44 |
+import configparser
|
45 |
import copy
|
46 |
import os
|
47 |
import platform
|
48 |
@@ -17,7 +18,8 @@ from DeComp.compress import CompressMap
|
49 |
from catalyst import log
|
50 |
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS,
|
51 |
PORT_LOGDIR_CLEAN)
|
52 |
from catalyst.support import (CatalystError, file_locate, normpath,
|
53 |
- cmd, read_makeconf, ismount, file_check)
|
54 |
+ cmd, read_makeconf, get_repo_name,
|
55 |
ismount,
|
56 |
+ file_check)
|
57 |
from catalyst.base.targetbase import TargetBase
|
58 |
from catalyst.base.clearbase import ClearBase
|
59 |
from catalyst.base.genbase import GenBase
|
60 |
@@ -821,17 +823,48 @@ class StageBase(TargetBase, ClearBase, GenBase):
|
61 |
env=self.env)
|
62 |
self.resume.enable("setup_confdir")
|
63 |
|
64 |
+ def get_repo_conf_path(self, repo_name):
|
65 |
+ """ Construct repo conf path:
|
66 |
/etc/portage/repos.conf/{name}.conf """
|
67 |
+ return normpath(os.path.join(self.settings['repos_conf'],
|
68 |
repo_name + ".conf"))
|
69 |
+
|
70 |
+ def get_overlay_location(self, repo_name):
|
71 |
+ """ Construct overlay repo path:
|
72 |
/var/gentoo/repos/local/{name} """
|
73 |
+ return normpath(os.path.join(self.settings['local_overlay'],
|
74 |
repo_name))
|
75 |
+
|
76 |
+ def write_repo_conf(self, repo_name, config):
|
77 |
+ """ Write ConfigParser to
|
78 |
{chroot}/etc/portage/repo.conf/{name}.conf """
|
79 |
+ repo_conf = self.get_repo_conf_path(repo_name)
|
80 |
+ chroot_repo_conf = self.settings['chroot_path'] + repo_conf
|
81 |
+ log.info('Creating repo config %s.', chroot_repo_conf)
|
82 |
+ ensure_dirs(os.path.dirname(chroot_repo_conf))
|
83 |
+
|
84 |
+ try:
|
85 |
+ with open(chroot_repo_conf, 'w') as myf:
|
86 |
+ config.write(myf)
|
87 |
+ except OSError as e:
|
88 |
+ raise CatalystError('Could not write {}: {}'.format(
|
89 |
+ chroot_repo_conf, e)) from e
|
90 |
+
|
91 |
def portage_overlay(self):
|
92 |
- """ We copy the contents of our overlays to /usr/local/portage
|
93 |
"""
|
94 |
+ """ We copy the contents of our overlays to
|
95 |
/var/gentoo/repos/local/{name} """
|
96 |
if "portage_overlay" in self.settings:
|
97 |
for x in self.settings["portage_overlay"]:
|
98 |
if os.path.exists(x):
|
99 |
- log.info('Copying overlay dir %s', x)
|
100 |
- ensure_dirs(
|
101 |
- self.settings['chroot_path'] +
|
102 |
self.settings['local_overlay'])
|
103 |
- cmd("cp -a " + x + "/* " +
|
104 |
self.settings["chroot_path"] +
|
105 |
- self.settings["local_overlay"],
|
106 |
- env=self.env)
|
107 |
+ name = get_repo_name(x)
|
108 |
+
|
109 |
+ location = self.get_overlay_location(name)
|
110 |
+ config = configparser.ConfigParser()
|
111 |
+ config[name] = {'location': location}
|
112 |
+ self.write_repo_conf(name, config)
|
113 |
+
|
114 |
+ chroot_location = normpath(
|
115 |
+ self.settings['chroot_path'] + location)
|
116 |
+ log.info('Copying overlay dir %s to %s',
|
117 |
+ x, chroot_location)
|
118 |
+ ensure_dirs(chroot_location)
|
119 |
+ cmd('cp -a ' + x + '/* ' + chroot_location,
|
120 |
env=self.env)
|
121 |
+ else:
|
122 |
+ log.warning('Skipping missing overlay %s.', x)
|
123 |
|
124 |
def root_overlay(self):
|
125 |
""" Copy over the root_overlay """
|
126 |
@@ -1080,12 +1113,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
|
127 |
varname = x.split('_')[1].upper()
|
128 |
myf.write(f'{varname}="{self.settings[x]}"\n')
|
129 |
|
130 |
- if setup:
|
131 |
- # Setup the portage overlay
|
132 |
- if "portage_overlay" in self.settings:
|
133 |
- myf.write('PORTDIR_OVERLAY="%s"\n' %
|
134 |
- self.settings["local_overlay"])
|
135 |
-
|
136 |
# Set default locale for system responses. #478382
|
137 |
myf.write(
|
138 |
'\n'
|
139 |
@@ -1157,11 +1184,18 @@ class StageBase(TargetBase, ClearBase,
|
140 |
GenBase):
|
141 |
log.warning("You've been hacking. Clearing target patches:
|
142 |
%s", target)
|
143 |
clear_path(target)
|
144 |
|
145 |
- # Remove our overlay
|
146 |
- overlay = normpath(
|
147 |
- self.settings["chroot_path"] +
|
148 |
self.settings["local_overlay"])
|
149 |
- if os.path.exists(overlay):
|
150 |
- clear_path(overlay)
|
151 |
+ # Remove our overlays
|
152 |
+ if "portage_overlay" in self.settings:
|
153 |
+ for repo_path in self.settings["portage_overlay"]:
|
154 |
+ repo_name = get_repo_name(repo_path)
|
155 |
+
|
156 |
+ repo_conf = self.get_repo_conf_path(repo_name)
|
157 |
+ chroot_repo_conf = self.settings["chroot_path"] +
|
158 |
repo_conf
|
159 |
+ clear_path(chroot_repo_conf)
|
160 |
+
|
161 |
+ location = self.get_overlay_location(repo_name)
|
162 |
+ chroot_location = self.settings['chroot_path'] +
|
163 |
location
|
164 |
+ clear_path(chroot_location)
|
165 |
|
166 |
if "sticky-config" not in self.settings["options"]:
|
167 |
# re-write the make.conf to be sure it is clean
|
168 |
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
|
169 |
index c153fcc4..9660a7f3 100644
|
170 |
--- a/catalyst/defaults.py
|
171 |
+++ b/catalyst/defaults.py
|
172 |
@@ -38,6 +38,7 @@ confdefaults = {
|
173 |
"local_overlay": "/var/db/repos/local",
|
174 |
"port_conf": "/etc/portage",
|
175 |
"make_conf": "%(port_conf)s/make.conf",
|
176 |
+ "repos_conf": "%(port_conf)s/repos.conf",
|
177 |
"options": set(),
|
178 |
"pkgdir": "/var/cache/binpkgs",
|
179 |
"port_tmpdir": "/var/tmp/portage",
|
180 |
diff --git a/catalyst/support.py b/catalyst/support.py
|
181 |
index a6a6854a..b8069c7d 100644
|
182 |
--- a/catalyst/support.py
|
183 |
+++ b/catalyst/support.py
|
184 |
@@ -7,6 +7,8 @@ import shutil
|
185 |
import time
|
186 |
from subprocess import Popen
|
187 |
|
188 |
+from portage.repository.config import RepoConfig
|
189 |
+
|
190 |
from catalyst import log
|
191 |
|
192 |
BASH_BINARY = "/bin/bash"
|
193 |
@@ -179,6 +181,22 @@ def read_makeconf(mymakeconffile):
|
194 |
return makeconf
|
195 |
|
196 |
|
197 |
+def get_repo_name(repo_path):
|
198 |
+ """ Get the name of the repo at the given repo_path.
|
199 |
+
|
200 |
+ References:
|
201 |
+
|
202 |
https://wiki.gentoo.org/wiki/Repository_format/profiles/repo_name
|
203 |
+
|
204 |
https://wiki.gentoo.org/wiki/Repository_format/metadata/layout.conf#repo-name
|
205 |
+ """
|
206 |
+
|
207 |
+ repo_config = RepoConfig(None, {"location": repo_path})
|
208 |
+
|
209 |
+ if repo_config.missing_repo_name:
|
210 |
+ raise CatalystError("Missing name in repository
|
211 |
{}".format(repo_path))
|
212 |
+
|
213 |
+ return repo_config.name
|
214 |
+
|
215 |
+
|
216 |
def pathcompare(path1, path2):
|
217 |
# Change double slashes to slash
|
218 |
path1 = re.sub(r"//", r"/", path1)
|
219 |
--
|
220 |
2.28.0 |