Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/base/, etc/, catalyst/
Date: Thu, 21 May 2020 20:25:42
Message-Id: 1589939377.66e78a8d55d0ab99b48c7fe7a327aab9b05b2586.mattst88@gentoo
1 commit: 66e78a8d55d0ab99b48c7fe7a327aab9b05b2586
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 16 03:18:21 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Wed May 20 01:49:37 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=66e78a8d
7
8 catalyst: Convert catalyst.conf to TOML
9
10 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
11
12 catalyst/base/stagebase.py | 4 +--
13 catalyst/main.py | 47 +++++++------------------
14 etc/catalyst.conf | 88 +++++++++++++++++++++++++++-------------------
15 3 files changed, 67 insertions(+), 72 deletions(-)
16
17 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
18 index febaf969..9410f151 100644
19 --- a/catalyst/base/stagebase.py
20 +++ b/catalyst/base/stagebase.py
21 @@ -857,8 +857,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
22 if 'var_tmpfs_portage' not in self.settings:
23 continue
24
25 - mount += ['-t', 'tmpfs', '-o', 'size=' +
26 - self.settings['var_tmpfs_portage'] + 'G']
27 + mount += ['-t', 'tmpfs', '-o',
28 + f"size={self.settings['var_tmpfs_portage']}G"]
29 elif source == 'tmpfs':
30 mount += ['-t', 'tmpfs']
31 elif source == 'shm':
32
33 diff --git a/catalyst/main.py b/catalyst/main.py
34 index be06ccd7..159fe454 100644
35 --- a/catalyst/main.py
36 +++ b/catalyst/main.py
37 @@ -5,6 +5,8 @@ import os
38 import sys
39 import textwrap
40
41 +import toml
42 +
43 from snakeoil.process import namespaces
44
45 from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
46 @@ -17,8 +19,7 @@ from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE
47 from catalyst.support import CatalystError
48 from catalyst.version import get_version
49
50 -
51 -conf_values = {}
52 +conf_values = confdefaults
53
54
55 def version():
56 @@ -30,42 +31,20 @@ def version():
57
58
59 def parse_config(config_files):
60 - # search a couple of different areas for the main config file
61 - myconf = {}
62 -
63 - # try and parse the config file "config_file"
64 for config_file in config_files:
65 log.notice('Loading configuration file: %s', config_file)
66 try:
67 - config = catalyst.config.ConfigParser(config_file)
68 - myconf.update(config.get_values())
69 + conf_values.update(toml.load(config_file))
70 except Exception as e:
71 log.critical('Could not find parse configuration file: %s: %s',
72 config_file, e)
73
74 - # now, load up the values into conf_values so that we can use them
75 - for x in list(confdefaults):
76 - if x in myconf:
77 - if x == 'options':
78 - conf_values[x] = set(myconf[x].split())
79 - elif x in ["decompressor_search_order"]:
80 - conf_values[x] = myconf[x].split()
81 - else:
82 - conf_values[x] = myconf[x]
83 - else:
84 - conf_values[x] = confdefaults[x]
85 -
86 # print out any options messages
87 for opt in conf_values['options']:
88 if opt in option_messages:
89 log.info(option_messages[opt])
90
91 - for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
92 - "local_overlay", "repos"]:
93 - if key in myconf:
94 - conf_values[key] = myconf[key]
95 -
96 - if "envscript" in myconf:
97 + if "envscript" in conf_values:
98 log.info('Envscript support enabled.')
99
100 # take care of any variable substitutions that may be left
101 @@ -297,17 +276,17 @@ def _main(parser, opts):
102 conf_values['DEBUG'] = opts.debug
103 conf_values['VERBOSE'] = opts.debug or opts.verbose
104
105 - options = set()
106 + options = []
107 if opts.fetchonly:
108 - options.add('fetch')
109 + options.append('fetch')
110 if opts.purge:
111 - options.add('purge')
112 + options.append('purge')
113 if opts.purgeonly:
114 - options.add('purgeonly')
115 + options.append('purgeonly')
116 if opts.purgetmponly:
117 - options.add('purgetmponly')
118 + options.append('purgetmponly')
119 if opts.clear_autoresume:
120 - options.add('clear-autoresume')
121 + options.append('clear-autoresume')
122
123 # Make sure we have some work before moving further.
124 if not myspecfile and not mycmdline:
125 @@ -318,7 +297,7 @@ def _main(parser, opts):
126 # import configuration file and import our main module using those settings
127 parse_config(myconfigs)
128
129 - conf_values["options"].update(options)
130 + conf_values["options"].extend(options)
131 log.notice('conf_values[options] = %s', conf_values['options'])
132
133 # initialize our contents generator
134 @@ -335,7 +314,7 @@ def _main(parser, opts):
135
136 if "digests" in conf_values:
137 valid_digests = hashlib.algorithms_available
138 - digests = set(conf_values['digests'].split())
139 + digests = set(conf_values['digests'])
140 conf_values['digests'] = digests
141
142 # First validate all the requested digests are valid keys.
143
144 diff --git a/etc/catalyst.conf b/etc/catalyst.conf
145 index d33be15f..2272cb86 100644
146 --- a/etc/catalyst.conf
147 +++ b/etc/catalyst.conf
148 @@ -10,53 +10,69 @@
149 #
150 # $ python3 -c 'import hashlib; print(hashlib.algorithms_available)'
151 #
152 -digests="blake2b sha512"
153 +digests = ["blake2b", "sha512"]
154
155 # envscript allows users to set options such as http proxies, MAKEOPTS,
156 # GENTOO_MIRRORS, or any other environment variables needed for building.
157 # The envscript file sets environment variables like so:
158 # export FOO="bar"
159 -envscript="/etc/catalyst/catalystrc"
160 -
161 -# options set different build-time options for catalyst. Some examples are:
162 -# autoresume = Attempt to resume a failed build, clear the autoresume flags with
163 -# the -a option to the catalyst cmdline. -p will clear the autoresume flags
164 -# as well as your pkgcache and kerncache
165 -# ( This option is not fully tested, bug reports welcome )
166 -# bindist = enables the bindist USE flag, please see package specific definition,
167 -# however, it is suggested to enable this if redistributing builds.
168 -# This optional USE flag is normally cleaned from the make.conf file on
169 -# completion of the stage. For a non-cleaned version,
170 -# use sticky-config also (see below)
171 -# ccache = enables build time ccache support
172 -# distcc = enable distcc support for building. You have to set distcc_hosts in
173 -# your spec file.
174 -# icecream = enables icecream compiler cluster support for building
175 -# keepwork = Prevents the removal of the working chroot path and any autoresume
176 -# files or points.
177 -# kerncache = keeps a tbz2 of your built kernel and modules (useful if your
178 -# build stops in livecd-stage2)
179 -# pkgcache = keeps a tbz2 of every built package (useful if your build stops
180 -# prematurely)
181 -# seedcache = use the build output of a previous target if it exists to speed up
182 -# the copy
183 -# sticky-config = enables the code that will keep any internal 'catalyst_use' flags
184 -# added to the USE= for building the stage. These are usually added for legal
185 -# or specific needs in building the the early stage. Mostly it is the
186 -# 'bindist' USE flag option that is used for legal reasons, please see its
187 -# specific definition. It will also keep any /etc/portage/package.*
188 -# files or directories.
189 -#
190 -# (These options can be used together)
191 -options="autoresume bindist kerncache pkgcache seedcache"
192 +envscript = "/etc/catalyst/catalystrc"
193 +
194 +# options set different build-time options for catalyst.
195 +options = [
196 + # Attempt to resume a failed build, clear the autoresume flags with the
197 + # -a option to the catalyst cmdline. -p will clear the autoresume
198 + # flags as well as your pkgcache and kerncache
199 + "autoresume",
200 +
201 + # Enables the bindist USE flag, please see package specific definition,
202 + # however, it is suggested to enable this if redistributing builds.
203 + # This optional USE flag is normally cleaned from the make.conf file on
204 + # completion of the stage. For a non-cleaned version, use
205 + # sticky-config also (see below)
206 + "bindist",
207 +
208 + # Enable FEATURES=ccache
209 + # "ccache",
210 +
211 + # Enable FEATURES=distcc. You have to set distcc_hosts in your spec
212 + # file.
213 + # "distcc",
214 +
215 + # Enable FEATURES=icecream
216 + # "icecream",
217 +
218 + # Prevents the removal of the working chroot path and any autoresume
219 + # files or points.
220 + # "keepwork",
221 +
222 + # keeps a tbz2 of your built kernel and modules (useful if your
223 + # build stops in livecd-stage2)
224 + "kerncache",
225 +
226 + # Build and use binary packages
227 + "pkgcache",
228 +
229 + # Use the build output of a previous target if it exists rather than
230 + # the tarball
231 + "seedcache",
232 +
233 + # enables the code that will keep any internal 'catalyst_use' flags
234 + # added to the USE= for building the stage. These are usually added
235 + # for legal or specific needs in building the the early stage. Mostly
236 + # it is the 'bindist' USE flag option that is used for legal reasons,
237 + # please see its specific definition. It will also keep any
238 + # /etc/portage/package.* files or directories.
239 + # "sticky-config",
240 +]
241
242 # port_logdir is where all build logs will be kept. This dir will be automatically cleaned
243 # of all logs over 30 days old. If left undefined the logs will remain in the build directory
244 # as usual and get cleaned every time a stage build is restarted.
245 -# port_logdir="/var/tmp/catalyst/tmp"
246 +# port_logdir = "/var/tmp/catalyst/tmp"
247
248 # var_tmpfs_portage will mount a tmpfs for /var/tmp/portage so building takes place in RAM
249 # this feature requires a pretty large tmpfs ({open,libre}office needs ~8GB to build)
250 # WARNING: If you use too much RAM everything will fail horribly and it is not our fault.
251 # set size of /var/tmp/portage tmpfs in gigabytes
252 -# var_tmpfs_portage=16
253 +# var_tmpfs_portage = 16