1 |
commit: 3269cfc50ec2eeccbb1c5aebc89fd4b38ce1b3e8 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 14 02:37:11 2020 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Oct 21 01:07:29 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3269cfc5 |
7 |
|
8 |
catalyst: Set jobs/load-average via catalyst.conf |
9 |
|
10 |
We currently have two mechanisms of setting MAKEOPTS: in spec files and |
11 |
in catalystrc. |
12 |
|
13 |
Setting makeopts in spec files doesn't make sense. The spec should |
14 |
describe the thing that's being built and not contain options that are |
15 |
specific to the build system. |
16 |
|
17 |
Setting makeopts via catalystrc is better, but it only applies to the |
18 |
actual build system invocations, leaving emerge to run jobs serially or |
19 |
again requiring configuration specific to the build machine to be put |
20 |
into the spec file. For example: |
21 |
|
22 |
update_seed_command: ... --jobs 5 --load-average 5 |
23 |
|
24 |
With jobs and load-average specified in catalyst.conf, catalyst has the |
25 |
information required to configure both emerge and the build systems |
26 |
emerge executes. |
27 |
|
28 |
This removes the undocumented makeopts spec file option and replaces it |
29 |
with jobs and load-average settings in catalyst.conf. |
30 |
|
31 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
32 |
|
33 |
catalyst/base/stagebase.py | 12 +++++------- |
34 |
catalyst/defaults.py | 2 ++ |
35 |
doc/catalyst-config.5.txt | 15 ++++++++++++--- |
36 |
etc/catalyst.conf | 8 ++++++++ |
37 |
etc/catalystrc | 3 --- |
38 |
targets/support/chroot-functions.sh | 8 ++++++++ |
39 |
6 files changed, 35 insertions(+), 13 deletions(-) |
40 |
|
41 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
42 |
index 99d638d8..afea5776 100644 |
43 |
--- a/catalyst/base/stagebase.py |
44 |
+++ b/catalyst/base/stagebase.py |
45 |
@@ -59,7 +59,6 @@ class StageBase(TargetBase, ClearBase, GenBase): |
46 |
"interpreter", |
47 |
"kerncache_path", |
48 |
"ldflags", |
49 |
- "makeopts", |
50 |
"pkgcache_path", |
51 |
"portage_confdir", |
52 |
"portage_overlay", |
53 |
@@ -1336,12 +1335,11 @@ class StageBase(TargetBase, ClearBase, GenBase): |
54 |
continue |
55 |
log.warning("Not making envar for '%s', is a dict", x) |
56 |
|
57 |
- if "makeopts" in self.settings: |
58 |
- if isinstance(self.settings["makeopts"], str): |
59 |
- self.env["MAKEOPTS"] = self.settings["makeopts"] |
60 |
- else: |
61 |
- # ensure makeopts is a string |
62 |
- self.env["MAKEOPTS"] = ' '.join(self.settings["makeopts"]) |
63 |
+ makeopts = [] |
64 |
+ for flag, setting in {'j': 'jobs', 'l': 'load-average'}.items(): |
65 |
+ if setting in self.settings: |
66 |
+ makeopts.append(f'-{flag}{self.settings[setting]}') |
67 |
+ self.env['MAKEOPTS'] = ' '.join(makeopts) |
68 |
|
69 |
log.debug('setup_environment(); env = %r', self.env) |
70 |
|
71 |
|
72 |
diff --git a/catalyst/defaults.py b/catalyst/defaults.py |
73 |
index c153fcc4..7a2fe3f3 100644 |
74 |
--- a/catalyst/defaults.py |
75 |
+++ b/catalyst/defaults.py |
76 |
@@ -13,6 +13,8 @@ valid_config_file_values = frozenset([ |
77 |
"digests", |
78 |
"distdir", |
79 |
"envscript", |
80 |
+ "jobs", |
81 |
+ "load-average", |
82 |
"options", |
83 |
"port_logdir", |
84 |
"repo_basedir", |
85 |
|
86 |
diff --git a/doc/catalyst-config.5.txt b/doc/catalyst-config.5.txt |
87 |
index 7ac9a2a3..cbef6092 100644 |
88 |
--- a/doc/catalyst-config.5.txt |
89 |
+++ b/doc/catalyst-config.5.txt |
90 |
@@ -48,9 +48,9 @@ $ python3 -c 'import hashlib; print(hashlib.algorithms_available)' |
91 |
|
92 |
*envscript*:: |
93 |
Environment script location, which allows users to set options such as |
94 |
-HTTP proxies, `MAKEOPTS`, `GENTOO_MIRRORS`, or any other environment |
95 |
-variables needed for building. The envscript file sets environment |
96 |
-variables using POSIX shell notation: |
97 |
+HTTP proxies, `GENTOO_MIRRORS`, or any other environment variables |
98 |
+needed for building. The envscript file sets environment variables |
99 |
+using POSIX shell notation: |
100 |
+ |
101 |
--------------------------------- |
102 |
export FOO="bar" |
103 |
@@ -136,6 +136,15 @@ written to the target's make.conf if it is not the default value of |
104 |
Other settings |
105 |
~~~~~~~~~~~~~~ |
106 |
|
107 |
+*jobs*:: |
108 |
+Integral value passed to *emerge(1)* as the parameter to --jobs and is |
109 |
+used to define *MAKEOPTS* during the target build. |
110 |
+ |
111 |
+*load-average*:: |
112 |
+Floating-point value passed to *emerge(1)* as the parameter to |
113 |
+--load-average and is used to define *MAKEOPTS* during the target |
114 |
+build. |
115 |
+ |
116 |
*sharedir*:: |
117 |
Catalyst runtime script location. `/usr/share/catalyst` should work for |
118 |
most default installations. If you are running catalyst from a Git |
119 |
|
120 |
diff --git a/etc/catalyst.conf b/etc/catalyst.conf |
121 |
index 2272cb86..81693c25 100644 |
122 |
--- a/etc/catalyst.conf |
123 |
+++ b/etc/catalyst.conf |
124 |
@@ -76,3 +76,11 @@ options = [ |
125 |
# WARNING: If you use too much RAM everything will fail horribly and it is not our fault. |
126 |
# set size of /var/tmp/portage tmpfs in gigabytes |
127 |
# var_tmpfs_portage = 16 |
128 |
+ |
129 |
+# Integral value passed to emerge as the parameter to --jobs and is used to |
130 |
+# define MAKEOPTS during the target build. |
131 |
+# jobs = 4 |
132 |
+ |
133 |
+# Floating-point value passed to emerge as the parameter to --load-average and |
134 |
+# is used to define MAKEOPTS during the target build. |
135 |
+# load-average = 4.0 |
136 |
|
137 |
diff --git a/etc/catalystrc b/etc/catalystrc |
138 |
index bcd729af..e7904128 100755 |
139 |
--- a/etc/catalystrc |
140 |
+++ b/etc/catalystrc |
141 |
@@ -1,5 +1,2 @@ |
142 |
#!/bin/bash |
143 |
# This is an example catalystrc. As such, it doesn't actually *do* anything. |
144 |
- |
145 |
-# Uncomment the following to increase the number of threads used to compile. |
146 |
-# export MAKEOPTS="-j16" |
147 |
|
148 |
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh |
149 |
index 7222892e..89a313f7 100755 |
150 |
--- a/targets/support/chroot-functions.sh |
151 |
+++ b/targets/support/chroot-functions.sh |
152 |
@@ -130,6 +130,14 @@ setup_emerge_opts() { |
153 |
emerge_opts+=(--fetchonly) |
154 |
bootstrap_opts+=(-f) |
155 |
fi |
156 |
+ if [ -n "${clst_jobs}" ] |
157 |
+ then |
158 |
+ emerge_opts+=(--jobs "${clst_jobs}") |
159 |
+ fi |
160 |
+ if [ -n "${clst_load_average}" ] |
161 |
+ then |
162 |
+ emerge_opts+=(--load-average "${clst_load_average}") |
163 |
+ fi |
164 |
|
165 |
if [ -n "${clst_PKGCACHE}" ] && [ -z "${clst_update_seed}" -o "${clst_update_seed}" = "no" ] |
166 |
then |