Merge pull request #1481 from mwhudson/tpm-v2

force storage version to 2 for a core boot classic install
This commit is contained in:
Michael Hudson-Doyle 2022-11-15 09:31:34 +13:00 committed by GitHub
commit 22b1958e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 14 deletions

View File

@ -145,6 +145,9 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
self._role_to_device: Dict[snapdapi.Role: _Device] = {}
self.use_tpm: bool = False
def is_core_boot_classic(self):
return self._system is not None
def load_autoinstall_data(self, data):
log.debug("load_autoinstall_data %s", data)
if data is None:
@ -180,24 +183,29 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
async def _get_system(self):
await self._unmount_system()
await self._mount_system()
self._system = None
label = self.app.base_model.source.current.snapd_system_label
if label is None:
if label is not None:
self._system = await self.app.snapdapi.v2.systems[label].GET()
log.debug("got system %s", self._system)
if len(self._system.volumes) == 0:
# This means the system does not define a gadget or kernel and
# so isn't a core boot classic system.
self._system = None
if self._system is None:
await self._unmount_system()
self.model.storage_version = self.opts.storage_version
self._system = None
return
system = await self.app.snapdapi.v2.systems[label].GET()
log.debug("got system %s", system)
if len(system.volumes) == 0:
# This means the system does not define a gadget or kernel
# so isn't a core boot classic system.
await self._unmount_system()
return
self._system = system
if len(system.volumes) > 1:
# Formatting for a core boot classic system relies on some curtin
# features that are only available with v2 partitioning.
self.model.storage_version = 2
if len(self._system.volumes) > 1:
self._core_boot_classic_error = system_multiple_volumes_text
[volume] = system.volumes.values()
[volume] = self._system.volumes.values()
if volume.schema != 'gpt':
self._core_boot_classic_error = system_non_gpt_text
if system.storage_encryption.support == \
if self._system.storage_encryption.support == \
StorageEncryptionSupport.DEFECTIVE:
self._core_boot_classic_error = system_defective_encryption_text

View File

@ -257,8 +257,8 @@ class InstallController(SubiquityController):
acquire_config=self.acquire_initial_config
).run,
]
if self.model.source.current.snapd_system_label:
fs_controller = self.app.controllers.Filesystem
fs_controller = self.app.controllers.Filesystem
if fs_controller.is_core_boot_classic():
steps.append(
make_curtin_step(
name="partitioning", stages=["partitioning"],
@ -305,6 +305,10 @@ class InstallController(SubiquityController):
acquire_config=self.acquire_generic_config,
).run,
])
# If the current source has a snapd_system_label here we should
# really write recovery_system={snapd_system_label} to
# {target}/var/lib/snapd/modeenv to get snapd to pick it up on
# first boot. But not needed for now.
for step in steps:
await step(context=context)

View File

@ -525,6 +525,9 @@ class TestCoreBootInstallMethods(IsolatedAsyncioTestCase):
self.app.controllers.Source.source_path = ''
await self.fsc._get_system_task.start()
await self.fsc._get_system_task.wait()
self.assertEqual(model.storage_version, 2)
self.fsc.apply_system(disk.id)
partition_count = len([
structure