Fix l-s-c behavior under SNAP environment.

- By passing the datadir command line option.
This commit is contained in:
Carlos Nihelton 2022-01-17 10:49:47 -03:00
parent 957d56a52f
commit a14a143d55
1 changed files with 12 additions and 1 deletions

View File

@ -139,7 +139,18 @@ class ConfigureController(SubiquityController):
clsLang = langCodes[0]
packages = []
# Running that command doesn't require root.
cp = await arun_command([clsCommand, "-l", clsLang], env=env)
snap_dir = os.getenv("SNAP")
if snap_dir is None:
snap_dir = "/"
data_dir = os.path.join(snap_dir, "usr/share/language-selector")
if not os.path.exists(data_dir):
log.error("Misconfigured snap environment pointed L-S-C data dir"
" to %s", data_dir)
return None
cp = await arun_command([clsCommand, "-d", data_dir, "-l", clsLang],
env=env)
if cp.returncode != 0:
log.error('Command "%s" failed with return code %d',
cp.args, cp.returncode)