From e59e4e7c7af68458036a30b4327a1a53e97e2172 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 7 Jun 2023 16:06:37 +1200 Subject: [PATCH] copy /cdrom to the reset partition, if configured --- subiquity/server/controllers/install.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index 88c91596..a2cea751 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -51,6 +51,9 @@ from subiquity.server.curtin import ( run_curtin_command, start_curtin_command, ) +from subiquity.server.mounter import ( + Mounter, + ) from subiquity.server.types import ( InstallerChannels, ) @@ -147,6 +150,16 @@ class InstallController(SubiquityController): config.update(kw) return config + def rp_config(self, logs_dir: Path, target: str) -> Dict[str, Any]: + """Return configuration to be used as part of populating a recovery + partition.""" + return { + "install": { + "target": target, + "resume_data": None, + } + } + @with_context(description="umounting /target dir") async def unmount_target(self, *, context, target): await run_curtin_command(self.app, context, 'unmount', '-t', target, @@ -224,7 +237,7 @@ class InstallController(SubiquityController): fs_controller = self.app.controllers.Filesystem - async def run_curtin_step(name, stages, step_config): + async def run_curtin_step(name, stages, step_config, source=source): config = copy.deepcopy(base_config) merge_config(config, copy.deepcopy(step_config)) await self.run_curtin_step( @@ -291,6 +304,15 @@ class InstallController(SubiquityController): # really write recovery_system={snapd_system_label} to # {target}/var/lib/snapd/modeenv to get snapd to pick it up on # first boot. But not needed for now. + rp = fs_controller.reset_partition + if rp is not None: + mounter = Mounter(self.app) + async with mounter.mounted(rp.path) as mp: + await run_curtin_step( + name="populate recovery", stages=["extract"], + step_config=self.rp_config(logs_dir, mp.p()), + source='cp:///cdrom', + ) @with_context(description="creating fstab") async def create_core_boot_classic_fstab(self, *, context):