Gentoo Archives: gentoo-catalyst

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