Skip to content

Commit 4233780

Browse files
authored
Merge pull request #92 from desultory/dev
add build_enum phase for enumeration
2 parents 5287e57 + 9a00520 commit 4233780

File tree

11 files changed

+29
-18
lines changed

11 files changed

+29
-18
lines changed

docs/dev_manual.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ For example, the `generate_fstab` function is added to the `build_tasks` book fr
4545

4646
Build imports are used to mutate config and build the base structure of the initramfs.
4747

48+
### build_enum
49+
50+
`build_enum` is used for system enumeration, such as finding the root device, loaded kernel mods, etc.
51+
4852
### build_pre
4953

50-
`build_pre` contains build tasks which are run at the very start of the build, such as build directory cleaning and additional config processing.
54+
`build_pre` contains build tasks which are run at the very start of the build, such as build directory cleaning and additional config processing based on enumerated info.
5155

5256
### build_tasks
5357

src/ugrd/base/base.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ autodetect_init = true
1717
[imports.config_processing]
1818
"ugrd.base.base" = [ "_process_loglevel", "_process_init_target", "_process_autodetect_init" ]
1919

20-
[imports.build_pre]
20+
[imports.build_enum]
2121
"ugrd.base.base" = [ "autodetect_init" ]
2222

2323
[imports.init_early]

src/ugrd/base/core.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ minor = 1
3333
"_process_validate",
3434
]
3535

36+
[imports.build_enum]
37+
"ugrd.base.core" = [ "detect_tmpdir", "find_libgcc" ]
38+
3639
[imports.build_pre]
37-
"ugrd.base.core" = [ "detect_tmpdir", "clean_build_dir", "find_libgcc" ]
40+
"ugrd.base.core" = [ "clean_build_dir" ]
3841

3942
[imports.build_deploy]
4043
"ugrd.base.core" = [ "generate_structure",

src/ugrd/base/plymouth.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ options = ['noauto', 'nosuid', 'noexec', 'rw', 'mode=620', 'gid=5']
1414
no_validate_options = true
1515
path = "devpts"
1616

17-
[imports.build_pre]
17+
[imports.build_enum]
1818
"ugrd.base.plymouth" = [ "find_plymouth_config" ]
1919

2020
[imports.build_tasks]

src/ugrd/crypto/smartcard.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
__author__ = "desultory"
2-
__version__ = "1.1.2"
2+
__version__ = "1.2.0"
33

44
from zenlib.util import contains
5+
from pathlib import Path
56

67

7-
@contains("sc_public_key", "Smartcard public key file not specified (sc_public_key)", raise_exception=True)
8-
def fetch_keys(self) -> None:
9-
"""Adds the GGP public key file to the list of dependencies."""
10-
self.logger.info("Adding GPG public key file to dependencies: %s", self["sc_public_key"])
11-
self["dependencies"] = self["sc_public_key"]
8+
def _process_sc_public_key(self, key: str) -> None:
9+
"""Processes the smartcard public key file."""
10+
key_path = Path(key)
11+
if not key_path.exists():
12+
raise FileNotFoundError(f"Smartcard public key file not found: {key}")
13+
self.data["sc_public_key"] = key_path
14+
self.logger.info("Using smartcard public key file: %s", key_path)
15+
self["dependencies"] = key_path
1216

1317

1418
@contains("sc_public_key", "Smartcard public key file not specified (sc_public_key)", raise_exception=True)

src/ugrd/crypto/smartcard.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ cryptsetup_autoretry = false
1010
reset_command = "gpgconf --reload && gpg --card-status"
1111

1212
[custom_parameters]
13-
sc_public_key = "str" # The path to the public key to import
13+
sc_public_key = "Path" # The path to the public key to import
1414

15-
[imports.build_pre]
16-
"ugrd.crypto.smartcard" = [ "fetch_keys" ]
15+
[imports.config_processing]
16+
"ugrd.crypto.smartcard" = [ "_process_sc_public_key" ]
1717

1818
[imports.init_early]
1919
"ugrd.crypto.smartcard" = [ "import_keys" ]

src/ugrd/fs/cpio.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cpio_compression = "xz"
33
cpio_rotate = true
44
check_cpio = true
55

6-
[imports.build_final]
6+
[imports.build_pre]
77
"ugrd.fs.cpio" = [ "get_archive_name" ]
88

99
[imports.pack]

src/ugrd/fs/mounts.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ late_fstab = "/etc/fstab.late"
2525
[imports.config_processing]
2626
"ugrd.fs.mounts" = [ "_process_mounts_multi", "_process_late_mounts_multi", "_process_mount_timeout" ]
2727

28-
[imports.build_pre]
28+
[imports.build_enum]
2929
"ugrd.fs.mounts" = [ "get_mounts_info", "get_virtual_block_info", "get_blkid_info",
3030
"autodetect_root", "autodetect_mounts", "autodetect_root_dm", "autodetect_init_mount" ]
3131

src/ugrd/initramfs_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, config="/etc/ugrd/config.toml", *args, **kwargs):
1717
self.included_functions = {}
1818

1919
# Used for functions that are run as part of the build process
20-
self.build_tasks = ["build_pre", "build_tasks", "build_late", "build_deploy", "build_final"]
20+
self.build_tasks = ["build_enum", "build_pre", "build_tasks", "build_late", "build_deploy", "build_final"]
2121

2222
# init_pre and init_final are run as part of generate_initramfs_main
2323
self.init_types = [

src/ugrd/kmod/kconfig.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[custom_parameters]
22
kernel_config_file = "Path" # Path to the kernel configuration file
33

4-
[imports.build_pre]
4+
[imports.build_enum]
55
"ugrd.kmod.kmod" = [ "find_kernel_config" ]

0 commit comments

Comments
 (0)