Skip to content

Commit fbe7dd6

Browse files
committed
add flag btrfs_userspace
squashed from 7 commits: add flag userspace_btrfs condition btrfs_scan and select_subvol on userspace_btrfs userspace_btrfs fixes after testing refactor add_btrfs_deps don't add default config to the procesing queue if populated ensures defaults don't override user config is modules are dynamically loaded Signed-off-by: Zen <[email protected]> refactor userspace_btrfs into btrfs_userspace refactor add_btrfs_deps into pull_btrfs_userspace raise log level of not including btrfs userspace
1 parent 4c90cd0 commit fbe7dd6

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ Importing this module will run `btrfs device scan` and pull btrfs modules.
314314
* `autodetect_root_subvol` (true) Autodetect the root subvolume, unless `root_subvol` or `subvol_selector` is set. Depends on `hostonly`.
315315
* `root_subvol` - Set the desired root subvolume.
316316
* `_base_mount_path` (/root_base) Sets where the subvolume selector mounts the base filesytem to scan for subvolumes.
317+
* `btrfs_userspace` (true) Add btrfs binary to be able to mount multi-device btrfs partitions.
317318

318319
#### ugrd.fs.resume
319320

src/ugrd/fs/btrfs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def _process_subvol_selector(self, subvol_selector: bool) -> None:
7575
self["paths"] = self["_base_mount_path"]
7676

7777

78+
@contains("btrfs_userspace", message="btrfs_userspace is disabled, will not add btrfs_scan to init.")
7879
def btrfs_scan(self) -> str:
7980
"""scan for new btrfs devices."""
8081
return 'einfo "$(btrfs device scan)"'
@@ -98,6 +99,7 @@ def autodetect_root_subvol(self):
9899

99100
@contains("subvol_selector", message="subvol_selector is not enabled, skipping.")
100101
@unset("root_subvol", message="root_subvol is set, skipping.")
102+
@contains("btrfs_userspace", message="btrfs_userspace is not enabled, skipping.")
101103
def select_subvol(self) -> str:
102104
"""Returns a POSIX shell script to list subvolumes on the root volume."""
103105
return f"""
@@ -134,3 +136,8 @@ def set_root_subvol(self) -> str:
134136
"""Adds the root_subvol to the root_mount options."""
135137
_validate_root_subvol(self)
136138
return f"""setvar root_extra_options ',subvol={self["root_subvol"]}'"""
139+
140+
@contains("btrfs_userspace", message="btrfs_userspace is disabled, skipping adding btrfs to binaries list.", log_level=30)
141+
def pull_btrfs_userspace(self):
142+
self.logger.debug("Adding btrfs to binaries list.")
143+
self["binaries"] = "btrfs"

src/ugrd/fs/btrfs.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
binaries = [ "btrfs" ]
21
kmod_init = [ "btrfs", "crc32c" ] # crc32c is a softdep but more or less required
32

43
_base_mount_path = "/root_base"
54
subvol_selector = false
65
autodetect_root_subvol = true
6+
btrfs_userspace = true
77

88
[imports.config_processing]
99
"ugrd.fs.btrfs" = [ "_process_root_subvol", "_process_subvol_selector" ]
1010

1111
[imports.build_pre]
1212
"ugrd.fs.btrfs" = [ "autodetect_root_subvol" ]
1313

14+
[imports.build_late]
15+
"ugrd.fs.btrfs" = [ "pull_btrfs_userspace" ]
16+
1417
[imports.init_mount]
1518
"ugrd.fs.btrfs" = [ "btrfs_scan", "set_root_subvol", "select_subvol" ]
1619

@@ -28,3 +31,4 @@ _base_mount_path = "Path" # Set the mount point for the root filesystem when us
2831
root_subvol = "str" # Set the default btrfs subvolume for the root filesystem
2932
subvol_selector = "bool" # Select a btrfs subvolume for the root partition at runtime
3033
autodetect_root_subvol = "bool" # Automatically detect the root subvolume
34+
btrfs_userspace = "bool" # Add btrfs binary to be able to mount multi-device btrfs partitions

src/ugrd/initramfs_dict.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = "desultory"
2-
__version__ = "2.4.1"
2+
__version__ = "2.4.2"
33

44
from collections import UserDict
55
from importlib import import_module
@@ -372,8 +372,13 @@ def _process_modules(self, module: str) -> None:
372372
if name in ["imports", "custom_parameters", "provides", "needs"]:
373373
self.logger.log(5, "[%s] Skipping '%s'" % (module, name))
374374
continue
375-
self.logger.debug("[%s] (%s) Setting value: %s" % (module, name, value))
376-
self[name] = value
375+
if name in self["_processing"]:
376+
self.logger.debug(
377+
f"Skipping setting defaults for parameter with queued values: {c_(name, 'yellow')}"
378+
)
379+
else:
380+
self.logger.debug("[%s] (%s) Setting value: %s" % (module, name, value))
381+
self[name] = value
377382

378383
# Add custom parameters after values are added, so they are processed in the correct order
379384
custom_parameters = module_config.get("custom_parameters", {})

0 commit comments

Comments
 (0)