refactor(history): commit development branch
All checks were successful
/ job (push) Successful in 1m12s
All checks were successful
/ job (push) Successful in 1m12s
new development branch from root commit
This commit is contained in:
parent
3e562930f6
commit
020aaa0b9a
94 changed files with 4804 additions and 0 deletions
54
rwx/grub/__init__.py
Normal file
54
rwx/grub/__init__.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
"""Wrap GRUB commands."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from rwx import cmd, ps
|
||||
|
||||
cmd.need("grub-mkimage")
|
||||
|
||||
COMPRESSION = "xz"
|
||||
ENV_BYTES = 1024
|
||||
ENV_COMMENT = "#"
|
||||
ENV_HEADER = f"""{ENV_COMMENT} GRUB Environment Block
|
||||
"""
|
||||
MODULES = {
|
||||
"i386-pc": [
|
||||
("biosdisk",),
|
||||
("ntldr",),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def make_image(
|
||||
image_format: str,
|
||||
image_path: str,
|
||||
modules: list[str],
|
||||
memdisk_path: str,
|
||||
pubkey_path: str | None = None,
|
||||
) -> None:
|
||||
"""Make a binary bootable image.
|
||||
|
||||
:param image_format: output format (x86_64-efi, i386-pc, arm64-efi)
|
||||
:type image_format: str
|
||||
:param image_path: output file
|
||||
:type image_path: str
|
||||
:param modules: modules to embed
|
||||
:type modules: list[str]
|
||||
:param memdisk_path: archive to include
|
||||
:type memdisk_path: str
|
||||
:param pubkey_path: extra public key to add
|
||||
:type pubkey_path: str | None
|
||||
"""
|
||||
args: list[str | tuple[str, ...]] = [
|
||||
"grub-mkimage",
|
||||
("--compress", COMPRESSION),
|
||||
("--format", image_format),
|
||||
("--output", image_path),
|
||||
("--memdisk", memdisk_path),
|
||||
]
|
||||
if pubkey_path:
|
||||
args.append(("--pubkey", pubkey_path))
|
||||
args.extend(modules)
|
||||
if extra_modules := MODULES.get(image_format):
|
||||
args.extend(extra_modules)
|
||||
ps.run(*args)
|
Loading…
Add table
Add a link
Reference in a new issue