install packages listed by check-language-support when locale_support == "langpack"
This commit is contained in:
parent
13d541654b
commit
b144f234ac
|
@ -15,6 +15,8 @@
|
|||
|
||||
import logging
|
||||
|
||||
from subiquitycore.utils import split_cmd_output
|
||||
|
||||
log = logging.getLogger('subiquity.models.locale')
|
||||
|
||||
|
||||
|
@ -27,6 +29,9 @@ class LocaleModel:
|
|||
selected_language = None
|
||||
locale_support = "locale-only"
|
||||
|
||||
def __init__(self, chroot_prefix):
|
||||
self.chroot_prefix = chroot_prefix
|
||||
|
||||
def switch_language(self, code):
|
||||
self.selected_language = code
|
||||
|
||||
|
@ -42,3 +47,15 @@ class LocaleModel:
|
|||
if '.' not in locale and '_' in locale:
|
||||
locale += '.UTF-8'
|
||||
return {'locale': locale}
|
||||
|
||||
async def target_packages(self):
|
||||
if self.selected_language is None:
|
||||
return []
|
||||
if self.locale_support != "langpack":
|
||||
return []
|
||||
lang = self.selected_language.split('.')[0]
|
||||
if lang == "C":
|
||||
return []
|
||||
|
||||
return await split_cmd_output(
|
||||
self.chroot_prefix + ['check-language-support', '-l', lang], None)
|
||||
|
|
|
@ -116,7 +116,7 @@ class SubiquityModel:
|
|||
self.identity = IdentityModel()
|
||||
self.kernel = KernelModel()
|
||||
self.keyboard = KeyboardModel(self.root)
|
||||
self.locale = LocaleModel()
|
||||
self.locale = LocaleModel(self.chroot_prefix)
|
||||
self.mirror = MirrorModel()
|
||||
self.network = NetworkModel()
|
||||
self.packages = []
|
||||
|
|
|
@ -60,4 +60,4 @@ class LocaleController(SubiquityController):
|
|||
|
||||
async def POST(self, data: str):
|
||||
self.model.switch_language(data)
|
||||
self.configured()
|
||||
await self.configured()
|
||||
|
|
|
@ -97,6 +97,11 @@ async def astart_command(cmd, *, stdout=subprocess.PIPE,
|
|||
env=_clean_env(env), **kw)
|
||||
|
||||
|
||||
async def split_cmd_output(cmd, split_on):
|
||||
cp = await arun_command(cmd, check=True)
|
||||
return cp.stdout.split(split_on)
|
||||
|
||||
|
||||
def start_command(cmd, *, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, encoding='utf-8', errors='replace',
|
||||
env=None, **kw):
|
||||
|
|
|
@ -52,10 +52,11 @@ class SystemSetupModel(SubiquityModel):
|
|||
self.root = root
|
||||
if root != '/':
|
||||
self.target = root
|
||||
self.chroot_prefix = []
|
||||
|
||||
self.packages = []
|
||||
self.userdata = {}
|
||||
self.locale = LocaleModel()
|
||||
self.locale = LocaleModel(self.chroot_prefix)
|
||||
self.identity = IdentityModel()
|
||||
self.wslconfbase = WSLConfigurationBaseModel()
|
||||
self.wslconfadvanced = WSLConfigurationAdvancedModel()
|
||||
|
|
Loading…
Reference in New Issue