From 65612edc0b96985e4b209bdb7481760b336e01ed Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 10 Oct 2023 12:07:48 +0200 Subject: [PATCH 1/2] examples: add desktop source with different variations Signed-off-by: Olivier Gayot --- examples/answers/desktop.yaml | 2 +- examples/sources/desktop-standard.yaml | 29 ++++++++++++++++ examples/sources/desktop.yaml | 46 +++++++++++++++++++++----- 3 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 examples/sources/desktop-standard.yaml diff --git a/examples/answers/desktop.yaml b/examples/answers/desktop.yaml index 6a0706cc..1754cd4c 100644 --- a/examples/answers/desktop.yaml +++ b/examples/answers/desktop.yaml @@ -1,4 +1,4 @@ -#source-catalog: examples/sources/desktop.yaml +#source-catalog: examples/sources/desktop-standard.yaml Source: source: ubuntu-desktop Welcome: diff --git a/examples/sources/desktop-standard.yaml b/examples/sources/desktop-standard.yaml new file mode 100644 index 00000000..ee54bf7d --- /dev/null +++ b/examples/sources/desktop-standard.yaml @@ -0,0 +1,29 @@ +- default: true + description: + en: A full featured Ubuntu Desktop. + id: ubuntu-desktop + locale_support: langpack + name: + en: Ubuntu Desktop + path: standard.squashfs + preinstalled_langs: + - de + - en + - es + - fr + - it + - pt + - ru + - zh + - '' + size: 4033826816 + type: fsimage-layered + variant: desktop + variations: + enhanced-secureboot: + path: standard.enhanced-secureboot.squashfs + size: 4336062464 + snapd_system_label: enhanced-secureboot-desktop + standard: + path: standard.squashfs + size: 4033826816 diff --git a/examples/sources/desktop.yaml b/examples/sources/desktop.yaml index ee54bf7d..626c1b1e 100644 --- a/examples/sources/desktop.yaml +++ b/examples/sources/desktop.yaml @@ -1,11 +1,11 @@ - default: true description: - en: A full featured Ubuntu Desktop. - id: ubuntu-desktop + en: A minimal but usable Ubuntu Desktop. + id: ubuntu-desktop-minimal locale_support: langpack name: - en: Ubuntu Desktop - path: standard.squashfs + en: Ubuntu Desktop (minimized) + path: minimal.squashfs preinstalled_langs: - de - en @@ -16,14 +16,42 @@ - ru - zh - '' - size: 4033826816 + size: 4015337472 + type: fsimage-layered + variant: desktop + variations: + minimal: + path: minimal.squashfs + size: 4015337472 + minimal-enhanced-secureboot: + path: minimal.enhanced-secureboot.squashfs + size: 4319010816 + snapd_system_label: enhanced-secureboot-desktop +- description: + en: A full featured Ubuntu Desktop. + id: ubuntu-desktop + locale_support: langpack + name: + en: Ubuntu Desktop + path: minimal.standard.squashfs + preinstalled_langs: + - de + - en + - es + - fr + - it + - pt + - ru + - zh + - '' + size: 5735194624 type: fsimage-layered variant: desktop variations: enhanced-secureboot: - path: standard.enhanced-secureboot.squashfs - size: 4336062464 + path: minimal.standard.enhanced-secureboot.squashfs + size: 6006235136 snapd_system_label: enhanced-secureboot-desktop standard: - path: standard.squashfs - size: 4033826816 + path: minimal.standard.squashfs + size: 5735194624 From d4820497e7f2c613a328509d0f5f0f049a9dcf3f Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 10 Oct 2023 16:29:53 +0200 Subject: [PATCH 2/2] filesystem: do not keep the variation info when the source changes When the source changes, the available variations should change as well. If we keep the old variations in the FilesystemController._variations_info dictionary, we end up with a crash later in the install. Signed-off-by: Olivier Gayot --- subiquity/server/controllers/filesystem.py | 1 + .../controllers/tests/test_filesystem.py | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index b792426c..9995e4e9 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -404,6 +404,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator): return info async def _examine_systems(self): + self._variation_info.clear() catalog_entry = self.app.base_model.source.current for name, variation in catalog_entry.variations.items(): system = None diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index d3888bb5..4321601d 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -369,6 +369,36 @@ class TestSubiquityControllerFilesystem(IsolatedAsyncioTestCase): await self.fsc._pre_shutdown() mock_run.assert_called_once_with(["mountpoint", "/target"]) + async def test_examine_systems(self): + # In LP: #2037723 and other similar reports, the user selects the + # source 'ubuntu-desktop-minimal' first and then switches to + # 'ubuntu-desktop'. The variations of those two sources are different. + # Upon switching to the new source, we forgot to discard the old + # variations. This lead to a crash further in the install. + self.fsc.model = model = make_model(Bootloader.UEFI) + make_disk(model) + self.app.base_model.source.current.type = "fsimage" + self.app.base_model.source.current.variations = { + "minimal": CatalogEntryVariation(path="", size=1), + } + + self.app.dr_cfg = DRConfig() + self.app.dr_cfg.systems_dir_exists = True + + await self.fsc._examine_systems() + + self.assertEqual(len(self.fsc._variation_info), 1) + self.assertEqual(self.fsc._variation_info["minimal"].name, "minimal") + + self.app.base_model.source.current.variations = { + "default": CatalogEntryVariation(path="", size=1), + } + + await self.fsc._examine_systems() + + self.assertEqual(len(self.fsc._variation_info), 1) + self.assertEqual(self.fsc._variation_info["default"].name, "default") + class TestGuided(IsolatedAsyncioTestCase): boot_expectations = [