install from squashfs with langpack preinstalled if present

This commit is contained in:
Michael Hudson-Doyle 2021-10-05 18:18:52 +13:00 committed by Dan Bungert
parent f72d581692
commit e72022f0a1
2 changed files with 16 additions and 0 deletions

View File

@ -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': {

View File

@ -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: