Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/base/, etc/
Date: Wed, 29 Nov 2017 17:20:49
Message-Id: 1511313381.d5f54e2693f4277fee370927ef18265ebcc52ac1.dolsen@gentoo
1 commit: d5f54e2693f4277fee370927ef18265ebcc52ac1
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 9 09:14:04 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 22 01:16:21 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d5f54e26
7
8 base/stagebase.py: Seperate out the writing of the make.conf file
9
10 By sepaerating out the writing of the make.conf file, it keeps all code to do so in one place.
11 I also fixed the code to correctly set the target chroot directories for PORTDIR, DISTDIR,
12 PKGDIR and PORTDIR_OVERLAY.
13 The same code also re-writes make.conf toggling any PORTDIR_OVERLAY setting
14 during the clean() run.
15
16 Add target_distdir and target_pkgdir settings to defaults and catalyst.conf.
17 This allows for more flexibility between host and target settings. They can be individually
18 configured this way.
19
20 Update target an source mounts from the configured settings.
21
22 catalyst/base/stagebase.py | 194 ++++++++++++++++++++++++---------------------
23 catalyst/defaults.py | 2 +
24 etc/catalyst.conf | 2 +
25 3 files changed, 106 insertions(+), 92 deletions(-)
26
27 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
28 index 532f0997..67382b9a 100644
29 --- a/catalyst/base/stagebase.py
30 +++ b/catalyst/base/stagebase.py
31 @@ -213,8 +213,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
32 self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"]
33 # initialize our source mounts
34 self.mountmap = SOURCE_MOUNT_DEFAULTS.copy()
35 - # update them from settings
36 + # update these from settings
37 + self.mountmap["portdir"] = self.settings["portdir"]
38 self.mountmap["distdir"] = self.settings["distdir"]
39 + self.target_mounts["portdir"] = normpath(self.settings["repo_basedir"] +
40 + "/" + self.settings["repo_name"])
41 + self.target_mounts["distdir"] = self.settings["target_distdir"]
42 + self.target_mounts["packagedir"] = self.settings["target_pkgdir"]
43 if "snapcache" not in self.settings["options"]:
44 self.mounts.remove("portdir")
45 self.mountmap["portdir"] = None
46 @@ -1051,96 +1056,106 @@ class StageBase(TargetBase, ClearBase, GenBase):
47 if os.path.exists(hosts_file):
48 os.rename(hosts_file, hosts_file + '.catalyst')
49 shutil.copy('/etc/hosts', hosts_file)
50 + # write out the make.conf
51 + try:
52 + self.write_make_conf(setup=True)
53 + except OSError as e:
54 + raise CatalystError('Could not write %s: %s' % (
55 + normpath(self.settings["chroot_path"] +
56 + self.settings["make_conf"]), e))
57 + self.resume.enable("chroot_setup")
58
59 - # Modify and write out make.conf (for the chroot)
60 - makepath = normpath(self.settings["chroot_path"] +
61 - self.settings["make_conf"])
62 - clear_path(makepath)
63 - myf = open(makepath, "w")
64 - myf.write("# These settings were set by the catalyst build script "
65 - "that automatically\n# built this stage.\n")
66 - myf.write("# Please consult "
67 - "/usr/share/portage/config/make.conf.example "
68 - "for a more\n# detailed example.\n")
69 -
70 - for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS",
71 - "ASFLAGS"]:
72 - if not flags in self.settings:
73 - continue
74 - if flags in ["LDFLAGS", "ASFLAGS"]:
75 - myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n"
76 - % flags)
77 - if (flags is not "CFLAGS" and
78 - self.settings[flags] == self.settings["CFLAGS"]):
79 - myf.write('%s="${CFLAGS}"\n' % flags)
80 - elif isinstance(self.settings[flags], list):
81 - myf.write('%s="%s"\n'
82 - % (flags, ' '.join(self.settings[flags])))
83 - else:
84 - myf.write('%s="%s"\n'
85 - % (flags, self.settings[flags]))
86 -
87 - if "CBUILD" in self.settings:
88 - myf.write("# This should not be changed unless you know exactly"
89 - " what you are doing. You\n# should probably be "
90 - "using a different stage, instead.\n")
91 - myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n')
92 -
93 - if "CHOST" in self.settings:
94 - myf.write("# WARNING: Changing your CHOST is not something "
95 - "that should be done lightly.\n# Please consult "
96 - "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable "
97 - "before changing.\n")
98 - myf.write('CHOST="' + self.settings["CHOST"] + '"\n')
99 -
100 - # Figure out what our USE vars are for building
101 - myusevars = []
102 - if "HOSTUSE" in self.settings:
103 - myusevars.extend(self.settings["HOSTUSE"])
104 -
105 - if "use" in self.settings:
106 - myusevars.extend(self.settings["use"])
107 -
108 - if myusevars:
109 - myf.write("# These are the USE and USE_EXPAND flags that were "
110 - "used for\n# building in addition to what is provided "
111 - "by the profile.\n")
112 - myusevars = sorted(set(myusevars))
113 - myf.write('USE="' + ' '.join(myusevars) + '"\n')
114 - if '-*' in myusevars:
115 - log.warning(
116 - 'The use of -* in %s/use will cause portage to ignore\n'
117 - 'package.use in the profile and portage_confdir.\n'
118 - "You've been warned!", self.settings['spec_prefix'])
119 -
120 - myuseexpandvars = {}
121 - if "HOSTUSEEXPAND" in self.settings:
122 - for hostuseexpand in self.settings["HOSTUSEEXPAND"]:
123 - myuseexpandvars.update(
124 - {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]})
125 -
126 - if myuseexpandvars:
127 - for hostuseexpand in myuseexpandvars:
128 - myf.write(hostuseexpand + '="' +
129 - ' '.join(myuseexpandvars[hostuseexpand]) + '"\n')
130 -
131 - myf.write('PORTDIR="%s"\n' % self.settings['portdir'])
132 - myf.write('DISTDIR="%s"\n' % self.settings['distdir'])
133 - myf.write('PKGDIR="%s"\n' % self.settings['packagedir'])
134 -
135 + def write_make_conf(self, setup=True):
136 + # Modify and write out make.conf (for the chroot)
137 + makepath = normpath(self.settings["chroot_path"] +
138 + self.settings["make_conf"])
139 + clear_path(makepath)
140 + myf = open(makepath, "w")
141 + myf.write("# These settings were set by the catalyst build script "
142 + "that automatically\n# built this stage.\n")
143 + myf.write("# Please consult "
144 + "/usr/share/portage/config/make.conf.example "
145 + "for a more\n# detailed example.\n")
146 +
147 + for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS",
148 + "ASFLAGS"]:
149 + if not flags in self.settings:
150 + continue
151 + if flags in ["LDFLAGS", "ASFLAGS"]:
152 + myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n"
153 + % flags)
154 + if (flags is not "CFLAGS" and
155 + self.settings[flags] == self.settings["CFLAGS"]):
156 + myf.write('%s="${CFLAGS}"\n' % flags)
157 + elif isinstance(self.settings[flags], list):
158 + myf.write('%s="%s"\n'
159 + % (flags, ' '.join(self.settings[flags])))
160 + else:
161 + myf.write('%s="%s"\n'
162 + % (flags, self.settings[flags]))
163 +
164 + if "CBUILD" in self.settings:
165 + myf.write("# This should not be changed unless you know exactly"
166 + " what you are doing. You\n# should probably be "
167 + "using a different stage, instead.\n")
168 + myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n')
169 +
170 + if "CHOST" in self.settings:
171 + myf.write("# WARNING: Changing your CHOST is not something "
172 + "that should be done lightly.\n# Please consult "
173 + "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable "
174 + "before changing.\n")
175 + myf.write('CHOST="' + self.settings["CHOST"] + '"\n')
176 +
177 + # Figure out what our USE vars are for building
178 + myusevars = []
179 + if "HOSTUSE" in self.settings:
180 + myusevars.extend(self.settings["HOSTUSE"])
181 +
182 + if "use" in self.settings:
183 + myusevars.extend(self.settings["use"])
184 +
185 + if myusevars:
186 + myf.write("# These are the USE and USE_EXPAND flags that were "
187 + "used for\n# building in addition to what is provided "
188 + "by the profile.\n")
189 + myusevars = sorted(set(myusevars))
190 + myf.write('USE="' + ' '.join(myusevars) + '"\n')
191 + if '-*' in myusevars:
192 + log.warning(
193 + 'The use of -* in %s/use will cause portage to ignore\n'
194 + 'package.use in the profile and portage_confdir.\n'
195 + "You've been warned!", self.settings['spec_prefix'])
196 +
197 + myuseexpandvars = {}
198 + if "HOSTUSEEXPAND" in self.settings:
199 + for hostuseexpand in self.settings["HOSTUSEEXPAND"]:
200 + myuseexpandvars.update(
201 + {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]})
202 +
203 + if myuseexpandvars:
204 + for hostuseexpand in myuseexpandvars:
205 + myf.write(hostuseexpand + '="' +
206 + ' '.join(myuseexpandvars[hostuseexpand]) + '"\n')
207 + # write out a shipable version
208 + target_portdir = normpath(self.settings["repo_basedir"] + "/" +
209 + self.settings["repo_name"])
210 +
211 + myf.write('PORTDIR="%s"\n' % target_portdir)
212 + myf.write('DISTDIR="%s"\n' % self.settings['target_distdir'])
213 + myf.write('PKGDIR="%s"\n' % self.settings['target_pkgdir'])
214 + if setup:
215 # Setup the portage overlay
216 if "portage_overlay" in self.settings:
217 myf.write('PORTDIR_OVERLAY="%s"\n' % self.settings["local_overlay"])
218
219 - # Set default locale for system responses. #478382
220 - myf.write(
221 - '\n'
222 - '# This sets the language of build output to English.\n'
223 - '# Please keep this setting intact when reporting bugs.\n'
224 - 'LC_MESSAGES=C\n')
225 -
226 - myf.close()
227 - self.resume.enable("chroot_setup")
228 + # Set default locale for system responses. #478382
229 + myf.write(
230 + '\n'
231 + '# This sets the language of build output to English.\n'
232 + '# Please keep this setting intact when reporting bugs.\n'
233 + 'LC_MESSAGES=C\n')
234 + myf.close()
235
236 def fsscript(self):
237 if "autoresume" in self.settings["options"] \
238 @@ -1183,12 +1198,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
239
240 make_conf = self.settings['chroot_path'] + self.settings['make_conf']
241 try:
242 - with open(make_conf) as f:
243 - data = f.readlines()
244 - data = ''.join(x for x in data
245 - if not x.startswith('PORTDIR_OVERLAY'))
246 - with open(make_conf, 'w') as f:
247 - f.write(data)
248 + self.write_make_conf(setup=False)
249 except OSError as e:
250 raise CatalystError('Could not update %s: %s' % (make_conf, e))
251
252
253 diff --git a/catalyst/defaults.py b/catalyst/defaults.py
254 index 0bba6f4d..84ed2822 100644
255 --- a/catalyst/defaults.py
256 +++ b/catalyst/defaults.py
257 @@ -59,6 +59,8 @@ confdefaults={
258 "snapshot_name": "portage-",
259 "source_matching": "strict",
260 "storedir": "/var/tmp/catalyst",
261 + "target_distdir": "/var/portage/distfiles",
262 + "target_pkgdir":"/var/portage/packages",
263 }
264
265 DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf'
266
267 diff --git a/etc/catalyst.conf b/etc/catalyst.conf
268 index 2e61ea4f..b4db063c 100644
269 --- a/etc/catalyst.conf
270 +++ b/etc/catalyst.conf
271 @@ -85,6 +85,8 @@ portdir="/usr/portage"
272 #
273 repo_basedir="/usr"
274 repo_name="portage"
275 +target_distdir="/usr/portage/distfiles"
276 +target_pkgdir="/usr/portage/packages"
277
278 # sharedir specifies where all of the catalyst runtime executables
279 # and other shared lib objects are.