mirror of
https://git.launchpad.net/livecd-rootfs
synced 2026-02-20 17:03:47 +00:00
simplify scratch directory handling a bit
This commit is contained in:
parent
a2a166d93d
commit
081981e650
@ -17,6 +17,7 @@ def make_boot_configurator_for_arch(
|
||||
arch: str,
|
||||
logger: "Logger",
|
||||
apt_state: "AptStateManager",
|
||||
workdir: pathlib.Path,
|
||||
iso_root: pathlib.Path,
|
||||
) -> "BaseBootConfigurator":
|
||||
"""Factory function to create boot configurator for a specific architecture."""
|
||||
@ -24,23 +25,23 @@ def make_boot_configurator_for_arch(
|
||||
case "amd64":
|
||||
from .amd64 import AMD64BootConfigurator
|
||||
|
||||
return AMD64BootConfigurator(logger, apt_state, iso_root)
|
||||
return AMD64BootConfigurator(logger, apt_state, workdir, iso_root)
|
||||
case "arm64":
|
||||
from .arm64 import ARM64BootConfigurator
|
||||
|
||||
return ARM64BootConfigurator(logger, apt_state, iso_root)
|
||||
return ARM64BootConfigurator(logger, apt_state, workdir, iso_root)
|
||||
case "ppc64el":
|
||||
from .ppc64el import PPC64ELBootConfigurator
|
||||
|
||||
return PPC64ELBootConfigurator(logger, apt_state, iso_root)
|
||||
return PPC64ELBootConfigurator(logger, apt_state, workdir, iso_root)
|
||||
case "riscv64":
|
||||
from .riscv64 import RISCV64BootConfigurator
|
||||
|
||||
return RISCV64BootConfigurator(logger, apt_state, iso_root)
|
||||
return RISCV64BootConfigurator(logger, apt_state, workdir, iso_root)
|
||||
case "s390x":
|
||||
from .s390x import S390XBootConfigurator
|
||||
|
||||
return S390XBootConfigurator(logger, apt_state, iso_root)
|
||||
return S390XBootConfigurator(logger, apt_state, workdir, iso_root)
|
||||
case _:
|
||||
raise ValueError(f"Unsupported architecture: {arch}")
|
||||
|
||||
|
||||
@ -202,14 +202,13 @@ fi
|
||||
|
||||
def make_bootable(
|
||||
self,
|
||||
workdir: pathlib.Path,
|
||||
project: str,
|
||||
capproject: str,
|
||||
subarch: str,
|
||||
hwe: bool,
|
||||
) -> None:
|
||||
"""Make the ISO bootable, including generating loopback.cfg."""
|
||||
super().make_bootable(workdir, project, capproject, subarch, hwe)
|
||||
super().make_bootable(project, capproject, subarch, hwe)
|
||||
grub_cfg = self.iso_root.joinpath("boot", "grub", "grub.cfg")
|
||||
grub_content = grub_cfg.read_text()
|
||||
self.iso_root.joinpath("boot", "grub", "loopback.cfg").write_text(
|
||||
|
||||
@ -33,15 +33,13 @@ class BaseBootConfigurator(ABC):
|
||||
self,
|
||||
logger: Logger,
|
||||
apt_state: AptStateManager,
|
||||
workdir: pathlib.Path,
|
||||
iso_root: pathlib.Path,
|
||||
) -> None:
|
||||
self.logger = logger
|
||||
self.apt_state = apt_state
|
||||
self.iso_root = iso_root
|
||||
|
||||
def create_dirs(self, workdir):
|
||||
self.scratch = workdir.joinpath("boot-stuff")
|
||||
self.scratch.mkdir(exist_ok=True)
|
||||
self.iso_root = iso_root
|
||||
|
||||
def download_and_extract_package(
|
||||
self, pkg_name: str, target_dir: pathlib.Path
|
||||
@ -85,7 +83,6 @@ class BaseBootConfigurator(ABC):
|
||||
|
||||
def make_bootable(
|
||||
self,
|
||||
workdir: pathlib.Path,
|
||||
project: str,
|
||||
capproject: str,
|
||||
subarch: str,
|
||||
@ -96,6 +93,6 @@ class BaseBootConfigurator(ABC):
|
||||
self.humanproject = capproject.replace("-", " ")
|
||||
self.subarch = subarch
|
||||
self.hwe = hwe
|
||||
self.create_dirs(workdir)
|
||||
self.scratch.mkdir(exist_ok=True)
|
||||
with self.logger.logged("configuring boot"):
|
||||
self.extract_files()
|
||||
|
||||
@ -90,14 +90,13 @@ menuentry "{self.humanproject} with the HWE kernel" {{
|
||||
|
||||
def make_bootable(
|
||||
self,
|
||||
workdir: pathlib.Path,
|
||||
project: str,
|
||||
capproject: str,
|
||||
subarch: str,
|
||||
hwe: bool,
|
||||
) -> None:
|
||||
"""Make the ISO bootable by extracting files and generating GRUB config."""
|
||||
super().make_bootable(workdir, project, capproject, subarch, hwe)
|
||||
super().make_bootable(project, capproject, subarch, hwe)
|
||||
with self.logger.logged("generating grub config"):
|
||||
content = self.generate_grub_config()
|
||||
grub_dir = self.iso_root.joinpath("boot", "grub")
|
||||
|
||||
@ -298,10 +298,10 @@ class ISOBuilder:
|
||||
self.arch,
|
||||
self.logger,
|
||||
self.apt_state,
|
||||
self.workdir,
|
||||
self.iso_root,
|
||||
)
|
||||
configurator.make_bootable(
|
||||
self.workdir,
|
||||
project,
|
||||
capproject,
|
||||
subarch,
|
||||
@ -341,9 +341,9 @@ class ISOBuilder:
|
||||
self.arch,
|
||||
self.logger,
|
||||
self.apt_state,
|
||||
self.workdir,
|
||||
self.iso_root,
|
||||
)
|
||||
configurator.create_dirs(self.workdir)
|
||||
mkisofs_opts = configurator.mkisofs_opts()
|
||||
cmd: list[str | pathlib.Path] = ["xorriso"]
|
||||
if self.arch == "riscv64":
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user