From d2f3db6463f33f9b41bbfff468df06cd1acbdea3 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 2 Aug 2023 15:55:39 +1200 Subject: [PATCH 1/4] move oem configuration stuff to a separate method and do not call it when installing core --- subiquity/server/controllers/install.py | 89 +++++++++++++------------ 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index d0fdb5a3..30e6915f 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -224,6 +224,51 @@ class InstallController(SubiquityController): device_map = json.load(fp) self.app.controllers.Filesystem.update_devices(device_map) + @with_context(description="configuring OEM packages") + async def pre_curthooks_oem_configuration(self, context): + # For OEM, we basically mimic what ubuntu-drivers does: + # 1. Install each package with apt-get install + # 2. For each package, run apt-get update using only the source + # installed by said package. + # 3. Run apt-get install again for each package. This will upgrade + # them to the version found in the OEM archive. + + # NOTE In ubuntu-drivers, this is done in a single call to apt-get + # install. + for pkg in self.model.oem.metapkgs: + await self.install_package(package=pkg.name) + + if self.model.network.has_network: + for pkg in self.model.oem.metapkgs: + source_list = f"/etc/apt/sources.list.d/{pkg.name}.list" + await run_curtin_command( + self.app, + context, + "in-target", + "-t", + self.tpath(), + "--", + "apt-get", + "update", + "-o", + f"Dir::Etc::SourceList={source_list}", + "-o", + "Dir::Etc::SourceParts=/dev/null", + "--no-list-cleanup", + private_mounts=False, + ) + + # NOTE In ubuntu-drivers, this is done in a single call to + # apt-get install. + for pkg in self.model.oem.metapkgs: + await self.install_package(package=pkg.name) + + # If we already have a kernel installed, don't bother requesting + # curthooks to install it again or we might end up with two + # kernels. + if await list_installed_kernels(Path(self.tpath())): + self.model.kernel.curthooks_no_install = True + @with_context(description="installing system", level="INFO", childlevel="DEBUG") async def curtin_install(self, *, context, source): if self.app.opts.dry_run: @@ -343,48 +388,8 @@ class InstallController(SubiquityController): ) await self.setup_target(context=context) - # For OEM, we basically mimic what ubuntu-drivers does: - # 1. Install each package with apt-get install - # 2. For each package, run apt-get update using only the source - # installed by said package. - # 3. Run apt-get install again for each package. This will upgrade - # them to the version found in the OEM archive. - - # NOTE In ubuntu-drivers, this is done in a single call to apt-get - # install. - for pkg in self.model.oem.metapkgs: - await self.install_package(package=pkg.name) - - if self.model.network.has_network: - for pkg in self.model.oem.metapkgs: - source_list = f"/etc/apt/sources.list.d/{pkg.name}.list" - await run_curtin_command( - self.app, - context, - "in-target", - "-t", - self.tpath(), - "--", - "apt-get", - "update", - "-o", - f"Dir::Etc::SourceList={source_list}", - "-o", - "Dir::Etc::SourceParts=/dev/null", - "--no-list-cleanup", - private_mounts=False, - ) - - # NOTE In ubuntu-drivers, this is done in a single call to - # apt-get install. - for pkg in self.model.oem.metapkgs: - await self.install_package(package=pkg.name) - - # If we already have a kernel installed, don't bother requesting - # curthooks to install it again or we might end up with two - # kernels. - if await list_installed_kernels(Path(self.tpath())): - self.model.kernel.curthooks_no_install = True + if self.supports_apt(): + await self.pre_curthooks_oem_configuration(context=context) await run_curtin_step( name="curthooks", From 81bad123d0479a15aaa3f18f482e982fd8e3139f Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 3 Aug 2023 08:36:19 +1200 Subject: [PATCH 2/4] do not display a message about OEM configuration if no metapackages --- subiquity/server/controllers/install.py | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index 30e6915f..066a9fe2 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -224,21 +224,23 @@ class InstallController(SubiquityController): device_map = json.load(fp) self.app.controllers.Filesystem.update_devices(device_map) - @with_context(description="configuring OEM packages") async def pre_curthooks_oem_configuration(self, context): - # For OEM, we basically mimic what ubuntu-drivers does: - # 1. Install each package with apt-get install - # 2. For each package, run apt-get update using only the source - # installed by said package. - # 3. Run apt-get install again for each package. This will upgrade - # them to the version found in the OEM archive. + async def install_oem_metapackages(ctx): + # For OEM, we basically mimic what ubuntu-drivers does: + # 1. Install each package with apt-get install + # 2. For each package, run apt-get update using only the source + # installed by said package. + # 3. Run apt-get install again for each package. This will upgrade + # them to the version found in the OEM archive. - # NOTE In ubuntu-drivers, this is done in a single call to apt-get - # install. - for pkg in self.model.oem.metapkgs: - await self.install_package(package=pkg.name) + # NOTE In ubuntu-drivers, this is done in a single call to apt-get + # install. + for pkg in self.model.oem.metapkgs: + await self.install_package(package=pkg.name, context=ctx) + + if not self.model.network.has_network: + return - if self.model.network.has_network: for pkg in self.model.oem.metapkgs: source_list = f"/etc/apt/sources.list.d/{pkg.name}.list" await run_curtin_command( @@ -263,6 +265,14 @@ class InstallController(SubiquityController): for pkg in self.model.oem.metapkgs: await self.install_package(package=pkg.name) + if not self.model.oem.metapkgs: + return + + with context.child( + "install_oem_metapackages", "installing applicable OEM metapackages" + ) as child: + await install_oem_metapackages(child) + # If we already have a kernel installed, don't bother requesting # curthooks to install it again or we might end up with two # kernels. From ac4d39baf84e26f4f253fa0162b3451c487d27c5 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Thu, 3 Aug 2023 11:06:12 +1200 Subject: [PATCH 3/4] add integration that installs desktop and as a result, tests OEM metapackage code path --- examples/answers/desktop.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/answers/desktop.yaml diff --git a/examples/answers/desktop.yaml b/examples/answers/desktop.yaml new file mode 100644 index 00000000..6a0706cc --- /dev/null +++ b/examples/answers/desktop.yaml @@ -0,0 +1,32 @@ +#source-catalog: examples/sources/desktop.yaml +Source: + source: ubuntu-desktop +Welcome: + lang: en_US +Refresh: + update: no +Keyboard: + layout: us +Zdev: + accept-default: yes +Network: + accept-default: yes +Proxy: + proxy: "" +Mirror: + country-code: us +Filesystem: + guided: yes + guided-index: 0 +Identity: + realname: Ubuntu + username: ubuntu + hostname: ubuntu-server + # ubuntu + password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1' +UbuntuPro: + token: "" +InstallProgress: + reboot: yes +Drivers: + install: no From 7afd0e57bab75aedfe269a5ec2f1ee8a21ff6556 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Fri, 4 Aug 2023 15:39:22 +1200 Subject: [PATCH 4/4] move kernel check out of oem specific code --- subiquity/server/controllers/install.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/subiquity/server/controllers/install.py b/subiquity/server/controllers/install.py index 066a9fe2..8eee0e29 100644 --- a/subiquity/server/controllers/install.py +++ b/subiquity/server/controllers/install.py @@ -273,12 +273,6 @@ class InstallController(SubiquityController): ) as child: await install_oem_metapackages(child) - # If we already have a kernel installed, don't bother requesting - # curthooks to install it again or we might end up with two - # kernels. - if await list_installed_kernels(Path(self.tpath())): - self.model.kernel.curthooks_no_install = True - @with_context(description="installing system", level="INFO", childlevel="DEBUG") async def curtin_install(self, *, context, source): if self.app.opts.dry_run: @@ -401,6 +395,12 @@ class InstallController(SubiquityController): if self.supports_apt(): await self.pre_curthooks_oem_configuration(context=context) + # If we already have a kernel installed, don't bother requesting + # curthooks to install it again or we might end up with two + # kernels. + if await list_installed_kernels(Path(self.tpath())): + self.model.kernel.curthooks_no_install = True + await run_curtin_step( name="curthooks", stages=["curthooks"],