diff --git a/examples/answers/desktop.yaml b/examples/answers/desktop.yaml index 6a0706cc9..1754cd4c1 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 000000000..ee54bf7d4 --- /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 ee54bf7d4..626c1b1e8 100644 --- a/examples/sources/desktop.yaml +++ b/examples/sources/desktop.yaml @@ -1,11 +1,39 @@ - default: true description: + en: A minimal but usable Ubuntu Desktop. + id: ubuntu-desktop-minimal + locale_support: langpack + name: + en: Ubuntu Desktop (minimized) + path: minimal.squashfs + preinstalled_langs: + - de + - en + - es + - fr + - it + - pt + - ru + - zh + - '' + 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: standard.squashfs + path: minimal.standard.squashfs preinstalled_langs: - de - en @@ -16,14 +44,14 @@ - ru - zh - '' - size: 4033826816 + 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 diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index b792426c0..9995e4e99 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -404,6 +404,7 @@ def disallowed_encryption(msg): 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 d3888bb51..4321601df 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -369,6 +369,36 @@ async def fake_run(cmd, **kwargs): 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 = [