generalize live system package install

Add live_packages model method where install models may specify
packages needed in the live system.  Move efibootmgr there.
This commit is contained in:
Dan Bungert 2023-08-25 16:16:52 -06:00
parent ff990df628
commit aa27b33820
3 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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):