1 |
commit: b30dd97d672d61bb40340799330ef7863b173b0c |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 19 22:04:49 2017 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Nov 22 01:16:22 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b30dd97d |
7 |
|
8 |
Unify all make.conf settings and writing |
9 |
|
10 |
This excludes stage1 builds which needs to modify the seed stage's make.conf for |
11 |
initial stage building. |
12 |
|
13 |
catalyst/base/stagebase.py | 221 ++++++++++++++++++------------------ |
14 |
etc/catalyst.conf | 9 ++ |
15 |
targets/stage2/stage2-controller.sh | 2 - |
16 |
targets/stage3/stage3-controller.sh | 2 - |
17 |
targets/stage4/stage4-controller.sh | 2 - |
18 |
targets/support/chroot-functions.sh | 16 +-- |
19 |
targets/support/functions.sh | 12 -- |
20 |
7 files changed, 130 insertions(+), 134 deletions(-) |
21 |
|
22 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
23 |
index d44db985..a7aa7f41 100644 |
24 |
--- a/catalyst/base/stagebase.py |
25 |
+++ b/catalyst/base/stagebase.py |
26 |
@@ -548,27 +548,29 @@ class StageBase(TargetBase, ClearBase, GenBase): |
27 |
return |
28 |
|
29 |
def set_use(self): |
30 |
- if self.settings["spec_prefix"] + "/use" in self.settings: |
31 |
- self.settings["use"] = \ |
32 |
- self.settings[self.settings["spec_prefix"] + "/use"] |
33 |
- del self.settings[self.settings["spec_prefix"] + "/use"] |
34 |
- if "use" not in self.settings: |
35 |
- self.settings["use"] = "" |
36 |
- if isinstance(self.settings['use'], str): |
37 |
- self.settings["use"] = self.settings["use"].split() |
38 |
+ use = self.settings["spec_prefix"] + "/use" |
39 |
+ if use in self.settings: |
40 |
+ if isinstance(self.settings[use], str): |
41 |
+ self.settings["use"] = self.settings[use].split() |
42 |
+ self.settings["use"] = self.settings[use] |
43 |
+ del self.settings[use] |
44 |
+ else: |
45 |
+ self.settings["use"] = [] |
46 |
|
47 |
def set_catalyst_use(self): |
48 |
- if self.settings["spec_prefix"] + "/catalyst_use" in self.settings: |
49 |
- self.settings["catalyst_use"] = \ |
50 |
- self.settings[self.settings["spec_prefix"]+"/catalyst_use"] |
51 |
- del self.settings[self.settings["spec_prefix"]+"/catalyst_use"] |
52 |
- if "catalyst_use" not in self.settings: |
53 |
- self.settings["catalyst_use"] = "" |
54 |
- if isinstance(self.settings['catalyst_use'], str): |
55 |
- self.settings["catalyst_use"] = self.settings["catalyst_use"].split() |
56 |
+ catalyst_use = self.settings["spec_prefix"] + "/catalyst_use" |
57 |
+ if catalyst_use in self.settings: |
58 |
+ if isinstance(self.settings[catalyst_use], str): |
59 |
+ self.settings["catalyst_use"] = self.settings[catalyst_use].split() |
60 |
+ else: |
61 |
+ self.settings["catalyst_use"] = self.settings[catalyst_use] |
62 |
+ del self.settings[catalyst_use] |
63 |
+ else: |
64 |
+ self.settings["catalyst_use"] = [] |
65 |
|
66 |
# Force bindist when options ask for it |
67 |
- if "BINDIST" in self.settings: |
68 |
+ if "bindist" in self.settings["options"]: |
69 |
+ log.debug("Enabling bindist USE flag") |
70 |
self.settings["catalyst_use"].append("bindist") |
71 |
|
72 |
def set_stage_path(self): |
73 |
@@ -1071,92 +1073,98 @@ class StageBase(TargetBase, ClearBase, GenBase): |
74 |
makepath = normpath(self.settings["chroot_path"] + |
75 |
self.settings["make_conf"]) |
76 |
clear_path(makepath) |
77 |
- myf = open(makepath, "w") |
78 |
- myf.write("# These settings were set by the catalyst build script " |
79 |
- "that automatically\n# built this stage.\n") |
80 |
- myf.write("# Please consult " |
81 |
- "/usr/share/portage/config/make.conf.example " |
82 |
- "for a more\n# detailed example.\n") |
83 |
- |
84 |
- for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS", |
85 |
- "ASFLAGS"]: |
86 |
- if not flags in self.settings: |
87 |
- continue |
88 |
- if flags in ["LDFLAGS", "ASFLAGS"]: |
89 |
- myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n" |
90 |
- % flags) |
91 |
- if (flags is not "CFLAGS" and |
92 |
- self.settings[flags] == self.settings["CFLAGS"]): |
93 |
- myf.write('%s="${CFLAGS}"\n' % flags) |
94 |
- elif isinstance(self.settings[flags], list): |
95 |
- myf.write('%s="%s"\n' |
96 |
- % (flags, ' '.join(self.settings[flags]))) |
97 |
- else: |
98 |
- myf.write('%s="%s"\n' |
99 |
- % (flags, self.settings[flags])) |
100 |
- |
101 |
- if "CBUILD" in self.settings: |
102 |
- myf.write("# This should not be changed unless you know exactly" |
103 |
- " what you are doing. You\n# should probably be " |
104 |
- "using a different stage, instead.\n") |
105 |
- myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n') |
106 |
- |
107 |
- if "CHOST" in self.settings: |
108 |
- myf.write("# WARNING: Changing your CHOST is not something " |
109 |
- "that should be done lightly.\n# Please consult " |
110 |
- "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable " |
111 |
- "before changing.\n") |
112 |
- myf.write('CHOST="' + self.settings["CHOST"] + '"\n') |
113 |
- |
114 |
- # Figure out what our USE vars are for building |
115 |
- myusevars = [] |
116 |
- if "HOSTUSE" in self.settings: |
117 |
- myusevars.extend(self.settings["HOSTUSE"]) |
118 |
- |
119 |
- if "use" in self.settings: |
120 |
- myusevars.extend(self.settings["use"]) |
121 |
- |
122 |
- if myusevars: |
123 |
- myf.write("# These are the USE and USE_EXPAND flags that were " |
124 |
- "used for\n# building in addition to what is provided " |
125 |
- "by the profile.\n") |
126 |
- myusevars = sorted(set(myusevars)) |
127 |
- myf.write('USE="' + ' '.join(myusevars) + '"\n') |
128 |
- if '-*' in myusevars: |
129 |
- log.warning( |
130 |
- 'The use of -* in %s/use will cause portage to ignore\n' |
131 |
- 'package.use in the profile and portage_confdir.\n' |
132 |
- "You've been warned!", self.settings['spec_prefix']) |
133 |
- |
134 |
- myuseexpandvars = {} |
135 |
- if "HOSTUSEEXPAND" in self.settings: |
136 |
- for hostuseexpand in self.settings["HOSTUSEEXPAND"]: |
137 |
- myuseexpandvars.update( |
138 |
- {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]}) |
139 |
- |
140 |
- if myuseexpandvars: |
141 |
- for hostuseexpand in myuseexpandvars: |
142 |
- myf.write(hostuseexpand + '="' + |
143 |
- ' '.join(myuseexpandvars[hostuseexpand]) + '"\n') |
144 |
- # write out a shipable version |
145 |
- target_portdir = normpath(self.settings["repo_basedir"] + "/" + |
146 |
- self.settings["repo_name"]) |
147 |
- |
148 |
- myf.write('PORTDIR="%s"\n' % target_portdir) |
149 |
- myf.write('DISTDIR="%s"\n' % self.settings['target_distdir']) |
150 |
- myf.write('PKGDIR="%s"\n' % self.settings['target_pkgdir']) |
151 |
- if setup: |
152 |
- # Setup the portage overlay |
153 |
- if "portage_overlay" in self.settings: |
154 |
- myf.write('PORTDIR_OVERLAY="%s"\n' % self.settings["local_overlay"]) |
155 |
- |
156 |
- # Set default locale for system responses. #478382 |
157 |
- myf.write( |
158 |
- '\n' |
159 |
- '# This sets the language of build output to English.\n' |
160 |
- '# Please keep this setting intact when reporting bugs.\n' |
161 |
- 'LC_MESSAGES=C\n') |
162 |
- myf.close() |
163 |
+ with open(makepath, "w") as myf: |
164 |
+ log.notice("Writing the stage make.conf to: %s" % makepath) |
165 |
+ myf.write("# These settings were set by the catalyst build script " |
166 |
+ "that automatically\n# built this stage.\n") |
167 |
+ myf.write("# Please consult " |
168 |
+ "/usr/share/portage/config/make.conf.example " |
169 |
+ "for a more\n# detailed example.\n") |
170 |
+ |
171 |
+ for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS", |
172 |
+ "ASFLAGS"]: |
173 |
+ if not flags in self.settings: |
174 |
+ continue |
175 |
+ if flags in ["LDFLAGS", "ASFLAGS"]: |
176 |
+ myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n" |
177 |
+ % flags) |
178 |
+ if (flags is not "CFLAGS" and |
179 |
+ self.settings[flags] == self.settings["CFLAGS"]): |
180 |
+ myf.write('%s="${CFLAGS}"\n' % flags) |
181 |
+ elif isinstance(self.settings[flags], list): |
182 |
+ myf.write('%s="%s"\n' |
183 |
+ % (flags, ' '.join(self.settings[flags]))) |
184 |
+ else: |
185 |
+ myf.write('%s="%s"\n' |
186 |
+ % (flags, self.settings[flags])) |
187 |
+ |
188 |
+ if "CBUILD" in self.settings: |
189 |
+ myf.write("# This should not be changed unless you know exactly" |
190 |
+ " what you are doing. You\n# should probably be " |
191 |
+ "using a different stage, instead.\n") |
192 |
+ myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n') |
193 |
+ |
194 |
+ if "CHOST" in self.settings: |
195 |
+ myf.write("# WARNING: Changing your CHOST is not something " |
196 |
+ "that should be done lightly.\n# Please consult " |
197 |
+ "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable " |
198 |
+ "before changing.\n") |
199 |
+ myf.write('CHOST="' + self.settings["CHOST"] + '"\n') |
200 |
+ |
201 |
+ # Figure out what our USE vars are for building |
202 |
+ myusevars = [] |
203 |
+ if "bindist" in self.settings["options"]: |
204 |
+ myf.write("\n# NOTE: This stage was built with the bindist Use flag enabled\n") |
205 |
+ if setup or "sticky-config" in self.settings["options"]: |
206 |
+ myusevars.extend(self.settings["catalyst_use"]) |
207 |
+ log.notice("STICKY-CONFIG is enabled") |
208 |
+ if "HOSTUSE" in self.settings: |
209 |
+ myusevars.extend(self.settings["HOSTUSE"]) |
210 |
+ |
211 |
+ if "use" in self.settings: |
212 |
+ myusevars.extend(self.settings["use"]) |
213 |
+ |
214 |
+ if myusevars: |
215 |
+ myf.write("# These are the USE and USE_EXPAND flags that were " |
216 |
+ "used for\n# building in addition to what is provided " |
217 |
+ "by the profile.\n") |
218 |
+ myusevars = sorted(set(myusevars)) |
219 |
+ myf.write('USE="' + ' '.join(myusevars) + '"\n') |
220 |
+ if '-*' in myusevars: |
221 |
+ log.warning( |
222 |
+ 'The use of -* in %s/use will cause portage to ignore\n' |
223 |
+ 'package.use in the profile and portage_confdir.\n' |
224 |
+ "You've been warned!", self.settings['spec_prefix']) |
225 |
+ |
226 |
+ myuseexpandvars = {} |
227 |
+ if "HOSTUSEEXPAND" in self.settings: |
228 |
+ for hostuseexpand in self.settings["HOSTUSEEXPAND"]: |
229 |
+ myuseexpandvars.update( |
230 |
+ {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]}) |
231 |
+ |
232 |
+ if myuseexpandvars: |
233 |
+ for hostuseexpand in myuseexpandvars: |
234 |
+ myf.write(hostuseexpand + '="' + |
235 |
+ ' '.join(myuseexpandvars[hostuseexpand]) + '"\n') |
236 |
+ # write out a shipable version |
237 |
+ target_portdir = normpath(self.settings["repo_basedir"] + "/" + |
238 |
+ self.settings["repo_name"]) |
239 |
+ |
240 |
+ myf.write('PORTDIR="%s"\n' % target_portdir) |
241 |
+ myf.write('DISTDIR="%s"\n' % self.settings['target_distdir']) |
242 |
+ myf.write('PKGDIR="%s"\n' % self.settings['target_pkgdir']) |
243 |
+ if setup: |
244 |
+ # Setup the portage overlay |
245 |
+ if "portage_overlay" in self.settings: |
246 |
+ myf.write('PORTDIR_OVERLAY="%s"\n' % self.settings["local_overlay"]) |
247 |
+ |
248 |
+ # Set default locale for system responses. #478382 |
249 |
+ myf.write( |
250 |
+ '\n' |
251 |
+ '# This sets the language of build output to English.\n' |
252 |
+ '# Please keep this setting intact when reporting bugs.\n' |
253 |
+ 'LC_MESSAGES=C\n') |
254 |
+ |
255 |
|
256 |
def fsscript(self): |
257 |
if "autoresume" in self.settings["options"] \ |
258 |
@@ -1197,11 +1205,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
259 |
if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]): |
260 |
clear_path(self.settings["chroot_path"] + self.settings["local_overlay"]) |
261 |
|
262 |
- make_conf = self.settings['chroot_path'] + self.settings['make_conf'] |
263 |
- try: |
264 |
- self.write_make_conf(setup=False) |
265 |
- except OSError as e: |
266 |
- raise CatalystError('Could not update %s: %s' % (make_conf, e)) |
267 |
+ # re-write the make.conf to be sure it is clean |
268 |
+ self.write_make_conf(setup=False) |
269 |
|
270 |
# Clean up old and obsoleted files in /etc |
271 |
if os.path.exists(self.settings["stage_path"]+"/etc"): |
272 |
|
273 |
diff --git a/etc/catalyst.conf b/etc/catalyst.conf |
274 |
index b4db063c..c22cd439 100644 |
275 |
--- a/etc/catalyst.conf |
276 |
+++ b/etc/catalyst.conf |
277 |
@@ -53,6 +53,9 @@ hash_function="crc32" |
278 |
# ( This option is not fully tested, bug reports welcome ) |
279 |
# bindist = enables the bindist USE flag, please see package specific definition, |
280 |
# however, it is suggested to enable this if redistributing builds. |
281 |
+# This optional USE flag is normally cleaned from the make.conf file on |
282 |
+# completion of the stage. For a non-cleaned version, |
283 |
+# use sticky-config also (see below) |
284 |
# ccache = enables build time ccache support |
285 |
# distcc = enable distcc support for building. You have to set distcc_hosts in |
286 |
# your spec file. |
287 |
@@ -70,6 +73,12 @@ hash_function="crc32" |
288 |
# snapcache = cache the snapshot so that it can be bind-mounted into the chroot. |
289 |
# WARNING: moving parts of the portage tree from within fsscript *will* break |
290 |
# your cache. The cache is unlinked before any empty or rm processing, though. |
291 |
+# sticky-config = enables the code that will keep any internal 'catalyst_use' flags |
292 |
+# added to the USE= for building the stage. These ae usually added for legal |
293 |
+# or specific needs in building the the early stage. Mostly it is the |
294 |
+# 'bindist' USE flag option that is used for legal reasons, please see its |
295 |
+# specific definition. It will also keep any /etc/portage/package.* |
296 |
+# files or directories. |
297 |
# |
298 |
# (These options can be used together) |
299 |
options="autoresume bindist kerncache pkgcache seedcache snapcache" |
300 |
|
301 |
diff --git a/targets/stage2/stage2-controller.sh b/targets/stage2/stage2-controller.sh |
302 |
index 41bd43bb..2eee79f3 100755 |
303 |
--- a/targets/stage2/stage2-controller.sh |
304 |
+++ b/targets/stage2/stage2-controller.sh |
305 |
@@ -10,8 +10,6 @@ case $1 in |
306 |
;; |
307 |
|
308 |
run) |
309 |
- prepare_portage |
310 |
- |
311 |
shift |
312 |
export clst_packages="$*" |
313 |
exec_in_chroot \ |
314 |
|
315 |
diff --git a/targets/stage3/stage3-controller.sh b/targets/stage3/stage3-controller.sh |
316 |
index eaa40b3d..2d415e40 100755 |
317 |
--- a/targets/stage3/stage3-controller.sh |
318 |
+++ b/targets/stage3/stage3-controller.sh |
319 |
@@ -10,8 +10,6 @@ case $1 in |
320 |
;; |
321 |
|
322 |
run) |
323 |
- prepare_portage |
324 |
- |
325 |
shift |
326 |
export clst_packages="$*" |
327 |
exec_in_chroot ${clst_shdir}/${clst_target}/${clst_target}-chroot.sh |
328 |
|
329 |
diff --git a/targets/stage4/stage4-controller.sh b/targets/stage4/stage4-controller.sh |
330 |
index 4c5d5a06..6a876c82 100755 |
331 |
--- a/targets/stage4/stage4-controller.sh |
332 |
+++ b/targets/stage4/stage4-controller.sh |
333 |
@@ -10,8 +10,6 @@ case $1 in |
334 |
;; |
335 |
|
336 |
pre-kmerge) |
337 |
- prepare_portage |
338 |
- |
339 |
# Sets up the build environment before any kernels are compiled |
340 |
exec_in_chroot ${clst_shdir}/support/pre-kmerge.sh |
341 |
;; |
342 |
|
343 |
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh |
344 |
index b01bbbbd..e44de61b 100755 |
345 |
--- a/targets/support/chroot-functions.sh |
346 |
+++ b/targets/support/chroot-functions.sh |
347 |
@@ -183,14 +183,14 @@ setup_gcc(){ |
348 |
setup_pkgmgr(){ |
349 |
# Set bindist USE flag if clst_BINDIST is set |
350 |
# this is handled independantly in stage2, changes here should be mirrored there |
351 |
- if [ "${clst_target}" != "stage1" ] && [ -e "${clst_make_conf}" ] \ |
352 |
- && [ -n "${clst_BINDIST}" ]; then |
353 |
- if grep -q ^USE "${clst_make_conf}"; then |
354 |
- echo "USE=\"\${USE} bindist\"" >> "${clst_make_conf}" |
355 |
- else |
356 |
- echo "USE=\"bindist\"" >> "${clst_make_conf}" |
357 |
- fi |
358 |
- fi |
359 |
+ #if [ "${clst_target}" != "stage1" ] && [ -e "${clst_make_conf}" ] \ |
360 |
+ # && [ -n "${clst_BINDIST}" ]; then |
361 |
+ # if grep -q ^USE "${clst_make_conf}"; then |
362 |
+ # echo "USE=\"\${USE} bindist\"" >> "${clst_make_conf}" |
363 |
+ # else |
364 |
+ # echo "USE=\"bindist\"" >> "${clst_make_conf}" |
365 |
+ # fi |
366 |
+ #fi |
367 |
|
368 |
# We need to merge our package manager with USE="build" set in case it is |
369 |
# portage to avoid frying our /etc/portage/make.conf file. Otherwise, we could |
370 |
|
371 |
diff --git a/targets/support/functions.sh b/targets/support/functions.sh |
372 |
index f743d419..ac4ec6c7 100755 |
373 |
--- a/targets/support/functions.sh |
374 |
+++ b/targets/support/functions.sh |
375 |
@@ -16,19 +16,7 @@ delete_from_chroot(){ |
376 |
fi |
377 |
} |
378 |
|
379 |
-prepare_portage() { |
380 |
- |
381 |
- echo "CATALYST_USE=\"${clst_CATALYST_USE}\"" >> ${clst_chroot_path}${clst_make_conf} |
382 |
- sed -i -e "/^USE=\"/s//\${CATALYST_USE} ${USE} /" ${clst_chroot_path}${clst_make_conf} |
383 |
-} |
384 |
- |
385 |
clear_portage() { |
386 |
- # Clean-up USE again |
387 |
- [ -e ${clst_chroot_path}${clst_make_conf} ] && echo "Drop \$CATALYST_USE from USE on ${clst_chroot_path}${clst_make_conf}" |
388 |
- [ -e ${clst_chroot_path}${clst_make_conf} ] && sed -i -e "/^USE=\"/s/\${CATALYST_USE} //" ${clst_chroot_path}${clst_make_conf} |
389 |
- [ -e ${clst_chroot_path}${clst_make_conf} ] && echo "Remove \$CATALYST_USE on ${clst_chroot_path}${clst_make_conf}" |
390 |
- [ -e ${clst_chroot_path}${clst_make_conf} ] && sed -i -e "/^CATALYST_USE/d" ${clst_chroot_path}${clist_make_conf} |
391 |
- |
392 |
if [ -n "${clst_portage_prefix}" ]; then |
393 |
for dir in "keywords", "mask", "unmask", "use"; do |
394 |
[ -d ${clst_chroot_path}/etc/portage/package.${dir}/${clst_portage_prefix} ] && |