Skip to content

Commit d6beee7

Browse files
committed
make toml define variable processing order
Signed-off-by: Zen <[email protected]>
1 parent 763b67b commit d6beee7

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

src/ugrd/base/core.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@ minor = 1
4646
"ugrd.base.core" = [ "configure_library_paths" ]
4747

4848
[custom_parameters]
49-
binaries = "NoDupFlatList" # Binaries which should be included in the intiramfs, dependencies resolved with lddtree
49+
hostonly = "bool" # If true, the initramfs will be built specifically for the host building it
50+
validate = "bool" # If true, the configuration of the initramfs will be validated against the host
51+
_file_owner_uid = "int" # Add the _file_owner_uid property, used to store the uid of the file owner
52+
_custom_init_file = "str" # Add the _custom_init_file propety, used to set where the custom init file is located
53+
build_dir = "Path" # The directory where the initramfs is built
54+
build_logging = "bool" # If true, additional build information will be logged to the console
55+
_build_log_level = "int" # The level of logging to use for the build log, set to 10 by default and incremeted by if build_log is true (min 20)
56+
symlinks = "dict" # Symlinks dict, defines the symlinks to be made in the initramfs
5057
dependencies = "NoDupFlatList" # Dependencies, used to define the dependencies of the initramfs
5158
opt_dependencies = "NoDupFlatList" # Optional dependencies, which will be included if they are found
5259
gz_dependencies = "NoDupFlatList" # GZipped dependencies property, used to define the gzipped dependencies (will be extracted)
5360
library_paths = "NoDupFlatList" # library_paths property, used to define the library paths to add to LD_LIBRARY_PATH
54-
symlinks = "dict" # Symlinks dict, defines the symlinks to be made in the initramfs
61+
binaries = "NoDupFlatList" # Binaries which should be included in the intiramfs, dependencies resolved with lddtree
5562
copies = "dict" # Copies dict, defines the files to be copied to the initramfs
5663
nodes = "dict" # Nodes dict, defines the device nodes to be created
5764
paths = "NoDupFlatList" # Paths to be created in the initramfs
5865
masks = "dict" # Imports to be masked in the initramfs
59-
build_dir = "Path" # The directory where the initramfs is built
60-
build_logging = "bool" # If true, additional build information will be logged to the console
61-
_build_log_level = "int" # The level of logging to use for the build log, set to 10 by default and incremeted by if build_log is true (min 20)
6266
out_dir = "Path" # The directory where the initramfs is packed/output. If no packer is used, this is the final output directory.
6367
old_count = "int" # The number of times to cycle old files before deleting
6468
clean = "bool" # Add the clean property, used to define if the mounts should be cleaned up after boot
65-
hostonly = "bool" # If true, the initramfs will be built specifically for the host building it
66-
validate = "bool" # If true, the configuration of the initramfs will be validated against the host
6769
file_owner = "str" # Add the file_owner property, used to define who should own the copied initramfs files
68-
_file_owner_uid = "int" # Add the _file_owner_uid property, used to store the uid of the file owner
69-
_custom_init_file = "str" # Add the _custom_init_file propety, used to set where the custom init file is located
7070

src/ugrd/fs/btrfs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ def autodetect_root_subvol(self):
8080

8181

8282
@check_dict('subvol_selector', value=True, message="subvol_selector not enabled, skipping")
83+
@check_dict('root_subvol', unset=True, message="root_subvol is set, skipping.")
8384
def select_subvol(self) -> str:
8485
""" Returns a bash script to list subvolumes on the root volume. """
85-
if self['root_subvol']:
86-
self.logger.warning("root_subvol is set, skipping subvolume selection.")
87-
return
8886
return [f'mount -t btrfs -o subvolid=5,ro $(cat /run/MOUNTS_ROOT_SOURCE) {self["_base_mount_path"]}',
8987
f'''if [ -z "$(btrfs subvolume list -o {self['_base_mount_path']})" ]; then''',
9088
f''' echo "Failed to list btrfs subvolumes for root volume: {self['_base_mount_path']}"''',

src/ugrd/fs/btrfs.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ autodetect_root_subvol = true
1717
# Custom parameters
1818
[custom_parameters]
1919
_base_mount_path = "Path" # Set the mount point for the root filesystem when used to check for subvols
20-
subvol_selector = "bool" # Select a btrfs subvolume for the root partition at runtime
2120
root_subvol = "str" # Set the default btrfs subvolume for the root filesystem
21+
subvol_selector = "bool" # Select a btrfs subvolume for the root partition at runtime
2222
autodetect_root_subvol = "bool" # Automatically detect the root subvolume

src/ugrd/initramfs_dict.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
__author__ = "desultory"
3-
__version__ = "1.0.2"
3+
__version__ = "1.1.0"
44

55
from tomllib import load, TOMLDecodeError
66
from pathlib import Path
@@ -75,7 +75,7 @@ def __setitem__(self, key: str, value) -> None:
7575
self.logger.debug("[%s] Custom types: %s" % (key, self['custom_parameters'].keys()))
7676
# for anything but the logger, add to the processing queue
7777
if key != 'logger':
78-
self.logger.warning("Adding unknown internal parameter to processing queue: %s" % key)
78+
self.logger.debug("Adding unknown internal parameter to processing queue: %s" % key)
7979
if key not in self['_processing']:
8080
self['_processing'][key] = Queue()
8181
self['_processing'][key].put(value)
@@ -105,10 +105,10 @@ def _process_custom_parameters(self, parameter_name: str, parameter_type: type)
105105
self.logger.debug("Leaving '%s' as None" % parameter_name)
106106

107107
if parameter_name in self['_processing']:
108-
self.logger.info("Processing queued values for '%s'" % parameter_name)
108+
self.logger.debug("Processing queued values for '%s'" % parameter_name)
109109
while not self['_processing'][parameter_name].empty():
110110
value = self['_processing'][parameter_name].get()
111-
self.logger.info("Processing queued value for '%s': %s" % (parameter_name, value))
111+
self.logger.debug("Processing queued value for '%s': %s" % (parameter_name, value))
112112
self[parameter_name] = value
113113
self['_processing'].pop(parameter_name)
114114

@@ -206,20 +206,20 @@ def _process_modules(self, module: str) -> None:
206206
except TOMLDecodeError as e:
207207
raise TOMLDecodeError("Unable to load module config: %s" % module) from e
208208

209-
# Import these first, as they affect how the rest of the config is processed
210-
early_imports = ['imports', 'custom_parameters']
211-
for import_type in early_imports:
212-
if import_type in module_config:
213-
self[import_type] = module_config[import_type]
214-
self.logger.debug("[%s] Registered %s: %s" % (module, import_type, self[import_type]))
215-
209+
# First import all variabled, then import processing functions/imports in order
210+
processing_imports = ['imports', 'custom_parameters']
216211
for name, value in module_config.items():
217-
if name in early_imports:
212+
if name in processing_imports:
218213
self.logger.log(5, "[%s] Skipping '%s'" % (module, name))
219214
continue
220215
self.logger.debug("[%s] Setting '%s' to: %s" % (module, name, value))
221216
self[name] = value
222217

218+
for import_type in processing_imports:
219+
if import_type in module_config:
220+
self[import_type] = module_config[import_type]
221+
self.logger.debug("[%s] Registered %s: %s" % (module, import_type, self[import_type]))
222+
223223
# Append the module to the list of loaded modules, avoid recursion
224224
self['modules'].append(module)
225225

0 commit comments

Comments
 (0)