From e72022f0a10c2e59314a1f5271b2a7275df30326 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 Oct 2021 18:18:52 +1300 Subject: [PATCH] install from squashfs with langpack preinstalled if present --- subiquity/models/source.py | 9 +++++++++ subiquity/server/controllers/source.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/subiquity/models/source.py b/subiquity/models/source.py index f7219d00..de537503 100644 --- a/subiquity/models/source.py +++ b/subiquity/models/source.py @@ -34,6 +34,7 @@ class CatalogEntry: type: str default: bool = False locale_support: str = attr.ib(default="locale-only") + preinstalled_langs: typing.List[str] = attr.ib(default=attr.Factory(list)) fake_entries = { @@ -66,6 +67,7 @@ class SourceModel: self._dir = '/cdrom/casper' self.current = fake_entries['server'] self.sources = [self.current] + self.lang = None def load_from_file(self, fp): self._dir = os.path.dirname(fp.name) @@ -87,6 +89,13 @@ class SourceModel: def render(self): path = os.path.join(self._dir, self.current.path) + if self.current.preinstalled_langs: + base, ext = os.path.splitext(path) + if self.lang in self.current.preinstalled_langs: + suffix = self.lang + else: + suffix = 'no-languages' + path = base + '.' + suffix + ext scheme = self.current.type return { 'sources': { diff --git a/subiquity/server/controllers/source.py b/subiquity/server/controllers/source.py index 4b15764a..fe9d211b 100644 --- a/subiquity/server/controllers/source.py +++ b/subiquity/server/controllers/source.py @@ -21,6 +21,7 @@ from subiquity.common.types import ( SourceSelectionAndSetting, ) from subiquity.server.controller import SubiquityController +from subiquity.server.types import InstallerChannels def _translate(d, lang): @@ -55,6 +56,12 @@ class SourceController(SubiquityController): return with open(path) as fp: self.model.load_from_file(fp) + self.app.hub.subscribe( + (InstallerChannels.CONFIGURED, 'locale'), self._set_locale) + + def _set_locale(self): + current = self.app.base_model.locale.selected_language + self.model.lang = current.split('_')[0] def interactive(self): if len(self.model.sources) <= 1: