From aa27b338201406b2a731d2f19f53153289f8a457 Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Fri, 25 Aug 2023 16:16:52 -0600 Subject: [PATCH] generalize live system package install Add live_packages model method where install models may specify packages needed in the live system. Move efibootmgr there. --- subiquity/models/filesystem.py | 6 ++++++ subiquity/models/subiquity.py | 8 ++++++++ subiquity/server/controllers/install.py | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 57440049..93a6ccbc 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -2038,3 +2038,9 @@ class FilesystemModel(object): ) self._actions.append(zpool) return zpool + + async def live_packages(self): + r = [] + if self.reset_partition is not None: + r.append("efibootmgr") + return r diff --git a/subiquity/models/subiquity.py b/subiquity/models/subiquity.py index d97dba61..a3077439 100644 --- a/subiquity/models/subiquity.py +++ b/subiquity/models/subiquity.py @@ -390,6 +390,14 @@ class SubiquityModel: packages.extend(await meth()) return packages + async def live_packages(self): + packages = [] + for model_name in self._install_model_names.all(): + meth = getattr(getattr(self, model_name), "live_packages", None) + if meth is not None: + packages.extend(await meth()) + return packages + def _cloud_init_files(self): # TODO, this should be moved to the in-target cloud-config seed so on # first boot of the target, it reconfigures datasource_list to none diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index aeee3ff9..d5e62c68 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -597,6 +597,11 @@ class InstallController(SubiquityController): with open(self.tpath("etc/fstab"), "w") as fp: fp.write("/run/mnt/ubuntu-boot/EFI/ubuntu /boot/grub none bind\n") + @with_context(description="installing packages to live system") + async def install_live_packages(self, *, context): + for package in await self.model.live_packages(): + await self.app.package_installer.install_pkg(package) + @with_context() async def install(self, *, context): context.set("is-install-context", True) @@ -627,8 +632,7 @@ class InstallController(SubiquityController): fsc = self.app.controllers.Filesystem for_install_path = self.model.source.get_source(fsc._info.name) - if self.app.base_model.filesystem.reset_partition: - self.app.package_installer.start_installing_pkg("efibootmgr") + await self.install_live_packages() if self.model.target is not None: if os.path.exists(self.model.target):