commit:     1b2dd33da134cb8f6fbaa1b000e15b0b2836ef93
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 03:18:21 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Tue May 19 22:54:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1b2dd33d

catalyst: Convert catalyst.conf to TOML

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 catalyst/main.py  | 27 +++++------------
 etc/catalyst.conf | 88 ++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 59 insertions(+), 56 deletions(-)

diff --git a/catalyst/main.py b/catalyst/main.py
index be06ccd7..a2444eeb 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -5,6 +5,8 @@ import os
 import sys
 import textwrap
 
+import toml
+
 from snakeoil.process import namespaces
 
 from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
@@ -30,31 +32,16 @@ def version():
 
 
 def parse_config(config_files):
-    # search a couple of different areas for the main config file
-    myconf = {}
+    config = confdefaults
 
-    # try and parse the config file "config_file"
     for config_file in config_files:
         log.notice('Loading configuration file: %s', config_file)
         try:
-            config = catalyst.config.ConfigParser(config_file)
-            myconf.update(config.get_values())
+            config.update(toml.load(config_file))
         except Exception as e:
             log.critical('Could not find parse configuration file: %s: %s',
                          config_file, e)
 
-    # now, load up the values into conf_values so that we can use them
-    for x in list(confdefaults):
-        if x in myconf:
-            if x == 'options':
-                conf_values[x] = set(myconf[x].split())
-            elif x in ["decompressor_search_order"]:
-                conf_values[x] = myconf[x].split()
-            else:
-                conf_values[x] = myconf[x]
-        else:
-            conf_values[x] = confdefaults[x]
-
     # print out any options messages
     for opt in conf_values['options']:
         if opt in option_messages:
@@ -62,10 +49,10 @@ def parse_config(config_files):
 
     for key in ["digests", "envscript", "var_tmpfs_portage", "port_logdir",
                 "local_overlay", "repos"]:
-        if key in myconf:
-            conf_values[key] = myconf[key]
+        if key in config:
+            conf_values[key] = config[key]
 
-    if "envscript" in myconf:
+    if "envscript" in config:
         log.info('Envscript support enabled.')
 
     # take care of any variable substitutions that may be left

diff --git a/etc/catalyst.conf b/etc/catalyst.conf
index d33be15f..2272cb86 100644
--- a/etc/catalyst.conf
+++ b/etc/catalyst.conf
@@ -10,53 +10,69 @@
 #
 #     $ python3 -c 'import hashlib; print(hashlib.algorithms_available)'
 #
-digests="blake2b sha512"
+digests = ["blake2b", "sha512"]
 
 # envscript allows users to set options such as http proxies, MAKEOPTS,
 # GENTOO_MIRRORS, or any other environment variables needed for building.
 # The envscript file sets environment variables like so:
 # export FOO="bar"
-envscript="/etc/catalyst/catalystrc"
-
-# options set different build-time options for catalyst. Some examples are:
-# autoresume = Attempt to resume a failed build, clear the autoresume flags 
with
-#      the -a option to the catalyst cmdline.  -p will clear the autoresume 
flags
-#      as well as your pkgcache and kerncache
-#      ( This option is not fully tested, bug reports welcome )
-# bindist = enables the bindist USE flag, please see package specific 
definition,
-#      however, it is suggested to enable this if redistributing builds.
-#      This optional USE flag is normally cleaned from the make.conf file on
-#      completion of the stage.  For a non-cleaned version,
-#      use sticky-config also (see below)
-# ccache = enables build time ccache support
-# distcc = enable distcc support for building. You have to set distcc_hosts in
-#      your spec file.
-# icecream = enables icecream compiler cluster support for building
-# keepwork = Prevents the removal of the working chroot path and any autoresume
-#      files or points.
-# kerncache = keeps a tbz2 of your built kernel and modules (useful if your
-#      build stops in livecd-stage2)
-# pkgcache = keeps a tbz2 of every built package (useful if your build stops
-#      prematurely)
-# seedcache = use the build output of a previous target if it exists to speed 
up
-#      the copy
-# sticky-config = enables the code that will keep any internal 'catalyst_use' 
flags
-#      added to the USE= for building the stage.  These are usually added for 
legal
-#      or specific needs in building the the early stage.  Mostly it is the
-#      'bindist' USE flag option that is used for legal reasons, please see its
-#      specific definition.  It will also keep any /etc/portage/package.*
-#      files or directories.
-#
-# (These options can be used together)
-options="autoresume bindist kerncache pkgcache seedcache"
+envscript = "/etc/catalyst/catalystrc"
+
+# options set different build-time options for catalyst.
+options = [
+       # Attempt to resume a failed build, clear the autoresume flags with the
+       # -a option to the catalyst cmdline.  -p will clear the autoresume
+       # flags as well as your pkgcache and kerncache
+       "autoresume",
+
+       # Enables the bindist USE flag, please see package specific definition,
+       # however, it is suggested to enable this if redistributing builds.
+       # This optional USE flag is normally cleaned from the make.conf file on
+       # completion of the stage.  For a non-cleaned version, use
+       # sticky-config also (see below)
+       "bindist",
+
+       # Enable FEATURES=ccache
+       # "ccache",
+
+       # Enable FEATURES=distcc. You have to set distcc_hosts in your spec
+       # file.
+       # "distcc",
+
+       # Enable FEATURES=icecream
+       # "icecream",
+
+       # Prevents the removal of the working chroot path and any autoresume
+       # files or points.
+       # "keepwork",
+
+       # keeps a tbz2 of your built kernel and modules (useful if your
+       # build stops in livecd-stage2)
+       "kerncache",
+
+       # Build and use binary packages
+       "pkgcache",
+
+       # Use the build output of a previous target if it exists rather than
+       # the tarball
+       "seedcache",
+
+       # enables the code that will keep any internal 'catalyst_use' flags
+       # added to the USE= for building the stage.  These are usually added
+       # for legal or specific needs in building the the early stage.  Mostly
+       # it is the 'bindist' USE flag option that is used for legal reasons,
+       # please see its specific definition.  It will also keep any
+       # /etc/portage/package.* files or directories.
+       # "sticky-config",
+]
 
 # port_logdir is where all build logs will be kept. This dir will be 
automatically cleaned
 # of all logs over 30 days old. If left undefined the logs will remain in the 
build directory
 # as usual and get cleaned every time a stage build is restarted.
-# port_logdir="/var/tmp/catalyst/tmp"
+# port_logdir = "/var/tmp/catalyst/tmp"
 
 # var_tmpfs_portage will mount a tmpfs for /var/tmp/portage so building takes 
place in RAM
 # this feature requires a pretty large tmpfs ({open,libre}office needs ~8GB to 
build)
 # WARNING: If you use too much RAM everything will fail horribly and it is not 
our fault.
 # set size of /var/tmp/portage tmpfs in gigabytes
-# var_tmpfs_portage=16
+# var_tmpfs_portage = 16

Reply via email to