Make consistent calls to lsb_release

We now always call lsb_release() with the application-wide dry-run
boolean. All calls should now be consistent (i.e. without a mix of
examples and files coming from the host)

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2021-12-17 16:13:43 +01:00
parent 475d71e166
commit 47ed7dbb9b
6 changed files with 9 additions and 11 deletions

View File

@ -217,7 +217,7 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
if self.model.bootloader == Bootloader.PREP:
self.supports_resilient_boot = False
else:
release = lsb_release()['release']
release = lsb_release(dry_run=self.app.opts.dry_run)['release']
self.supports_resilient_boot = release >= '20.04'
self.ui.set_body(FilesystemView(self.model, self))

View File

@ -16,7 +16,6 @@
"""
import logging
from typing import Optional
from subiquity.client.controller import SubiquityTuiController
from subiquity.common.types import UbuntuAdvantageInfo
@ -40,11 +39,8 @@ class UbuntuAdvantageController(SubiquityTuiController):
await self.endpoint.skip.POST()
raise Skip("Hiding the screen until we can validate the token.")
path_lsb_release: Optional[str] = None
if self.app.opts.dry_run:
# In dry-run mode, always pretend to be on LTS
path_lsb_release = "examples/lsb-release-focal"
if "LTS" not in lsb_release(path_lsb_release)["description"]:
dry_run: bool = self.app.opts.dry_run
if "LTS" not in lsb_release(dry_run=dry_run)["description"]:
await self.endpoint.skip.POST()
raise Skip("Not running LTS version")

View File

@ -207,7 +207,7 @@ class AptConfigurer:
if os.path.exists(proxy_path):
os.unlink(proxy_path)
codename = lsb_release()['codename']
codename = lsb_release(dry_run=self.app.opts.dry_run)['codename']
write_file(
self.install_tree.p('etc/apt/sources.list'),

View File

@ -448,7 +448,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
if self.model.bootloader == Bootloader.PREP:
self.supports_resilient_boot = False
else:
release = lsb_release()['release']
release = lsb_release(dry_run=self.app.opts.dry_run)['release']
self.supports_resilient_boot = release >= '20.04'
self._start_task = schedule_task(self._start())

View File

@ -70,8 +70,10 @@ class KernelController(NonInteractiveController):
# Should check this package exists really but
# that's a bit tricky until we get cleverer about
# the apt config in general.
dry_run: bool = self.app.opts.dry_run
package = 'linux-{flavor}-{release}'.format(
flavor=flavor, release=lsb_release()['release'])
flavor=flavor,
release=lsb_release(dry_run=dry_run)['release'])
self.model.metapkg_name = package
def make_autoinstall(self):

View File

@ -441,7 +441,7 @@ class HelpMenu(PopUpLauncher):
self.app.add_global_overlay(stretchy)
def about(self, sender=None):
info = lsb_release()
info = lsb_release(dry_run=self.app.opts.dry_run)
if 'LTS' in info['description']:
template = _(ABOUT_INSTALLER_LTS)
else: