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