Allow skipping locale-gen command.
lang-packs post-install hook executes locale-gen. For certain languages a matrix of locales is generated. Re-running locale-gen regenerates not only the locale we wanted, but the whole matrix, causing further delays. We can save up to 40s (tested on my laptop) by skipping locale-gen if apt succeeded. Still useful to run it unconditionally i dry-run since apt won't execute any post-install hook.
This commit is contained in:
parent
d6cbbda685
commit
5a8e2f2835
|
@ -101,7 +101,7 @@ class ConfigureController(SubiquityController):
|
||||||
os.path.join(defaultLocDir, "locale")]
|
os.path.join(defaultLocDir, "locale")]
|
||||||
return updateLocCmd
|
return updateLocCmd
|
||||||
|
|
||||||
async def _activate_locale(self, lang, env) -> bool:
|
async def _activate_locale(self, lang, env, skipLocGen=False) -> bool:
|
||||||
""" Return true if succeed in running the last commands
|
""" Return true if succeed in running the last commands
|
||||||
to set the locale.
|
to set the locale.
|
||||||
"""
|
"""
|
||||||
|
@ -111,7 +111,7 @@ class ConfigureController(SubiquityController):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
updateCmd = self.__update_locale_cmd(lang)
|
updateCmd = self.__update_locale_cmd(lang)
|
||||||
cmds = [[locGenCmd], updateCmd]
|
cmds = [updateCmd] if skipLocGen else [[locGenCmd], updateCmd]
|
||||||
for cmd in cmds:
|
for cmd in cmds:
|
||||||
cp = await arun_command(cmd, env=env)
|
cp = await arun_command(cmd, env=env)
|
||||||
if cp.returncode != 0:
|
if cp.returncode != 0:
|
||||||
|
@ -283,7 +283,9 @@ class ConfigureController(SubiquityController):
|
||||||
log.error("Failed to install recommended language packs.")
|
log.error("Failed to install recommended language packs.")
|
||||||
return
|
return
|
||||||
|
|
||||||
ok = await self._activate_locale(lang, env)
|
# We want to run locale-gen if apt fails to install language packs,
|
||||||
|
# so the other locale definitions match the user expectation.
|
||||||
|
ok = await self._activate_locale(lang, env, skipLocGen=ok)
|
||||||
if not ok:
|
if not ok:
|
||||||
log.error("Failed to run locale activation commands.")
|
log.error("Failed to run locale activation commands.")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue