Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/dev_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ For example, the `generate_fstab` function is added to the `build_tasks` book fr

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

### build_enum

`build_enum` is used for system enumeration, such as finding the root device, loaded kernel mods, etc.

### build_pre

`build_pre` contains build tasks which are run at the very start of the build, such as build directory cleaning and additional config processing.
`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.

### build_tasks

Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/base/base.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ autodetect_init = true
[imports.config_processing]
"ugrd.base.base" = [ "_process_loglevel", "_process_init_target", "_process_autodetect_init" ]

[imports.build_pre]
[imports.build_enum]
"ugrd.base.base" = [ "autodetect_init" ]

[imports.init_early]
Expand Down
5 changes: 4 additions & 1 deletion src/ugrd/base/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ minor = 1
"_process_validate",
]

[imports.build_enum]
"ugrd.base.core" = [ "detect_tmpdir", "find_libgcc" ]

[imports.build_pre]
"ugrd.base.core" = [ "detect_tmpdir", "clean_build_dir", "find_libgcc" ]
"ugrd.base.core" = [ "clean_build_dir" ]

[imports.build_deploy]
"ugrd.base.core" = [ "generate_structure",
Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/base/plymouth.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ options = ['noauto', 'nosuid', 'noexec', 'rw', 'mode=620', 'gid=5']
no_validate_options = true
path = "devpts"

[imports.build_pre]
[imports.build_enum]
"ugrd.base.plymouth" = [ "find_plymouth_config" ]

[imports.build_tasks]
Expand Down
16 changes: 10 additions & 6 deletions src/ugrd/crypto/smartcard.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
__author__ = "desultory"
__version__ = "1.1.2"
__version__ = "1.2.0"

from zenlib.util import contains
from pathlib import Path


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


@contains("sc_public_key", "Smartcard public key file not specified (sc_public_key)", raise_exception=True)
Expand Down
6 changes: 3 additions & 3 deletions src/ugrd/crypto/smartcard.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ cryptsetup_autoretry = false
reset_command = "gpgconf --reload && gpg --card-status"

[custom_parameters]
sc_public_key = "str" # The path to the public key to import
sc_public_key = "Path" # The path to the public key to import

[imports.build_pre]
"ugrd.crypto.smartcard" = [ "fetch_keys" ]
[imports.config_processing]
"ugrd.crypto.smartcard" = [ "_process_sc_public_key" ]

[imports.init_early]
"ugrd.crypto.smartcard" = [ "import_keys" ]
Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/fs/cpio.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cpio_compression = "xz"
cpio_rotate = true
check_cpio = true

[imports.build_final]
[imports.build_pre]
"ugrd.fs.cpio" = [ "get_archive_name" ]

[imports.pack]
Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/fs/mounts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ late_fstab = "/etc/fstab.late"
[imports.config_processing]
"ugrd.fs.mounts" = [ "_process_mounts_multi", "_process_late_mounts_multi", "_process_mount_timeout" ]

[imports.build_pre]
[imports.build_enum]
"ugrd.fs.mounts" = [ "get_mounts_info", "get_virtual_block_info", "get_blkid_info",
"autodetect_root", "autodetect_mounts", "autodetect_root_dm", "autodetect_init_mount" ]

Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/initramfs_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, config="/etc/ugrd/config.toml", *args, **kwargs):
self.included_functions = {}

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

# init_pre and init_final are run as part of generate_initramfs_main
self.init_types = [
Expand Down
2 changes: 1 addition & 1 deletion src/ugrd/kmod/kconfig.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[custom_parameters]
kernel_config_file = "Path" # Path to the kernel configuration file

[imports.build_pre]
[imports.build_enum]
"ugrd.kmod.kmod" = [ "find_kernel_config" ]
2 changes: 1 addition & 1 deletion src/ugrd/kmod/kmod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ no_kmod = "bool" # Disables kernel modules entirely
[imports.config_processing]
"ugrd.kmod.kmod" = [ "_process_kmod_init_multi", "_process_kernel_modules_multi", "_process__kmod_auto_multi" ]

[imports.build_pre]
[imports.build_enum]
"ugrd.kmod.kmod" = [ "get_kernel_metadata", "autodetect_modules" ]

[imports.build_late]
Expand Down