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:
Carlos Nihelton 2022-05-30 17:33:09 -03:00
parent d6cbbda685
commit 5a8e2f2835
No known key found for this signature in database
GPG Key ID: 6FE346D245197E9A
1 changed files with 5 additions and 3 deletions

View File

@ -101,7 +101,7 @@ class ConfigureController(SubiquityController):
os.path.join(defaultLocDir, "locale")]
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
to set the locale.
"""
@ -111,7 +111,7 @@ class ConfigureController(SubiquityController):
return False
updateCmd = self.__update_locale_cmd(lang)
cmds = [[locGenCmd], updateCmd]
cmds = [updateCmd] if skipLocGen else [[locGenCmd], updateCmd]
for cmd in cmds:
cp = await arun_command(cmd, env=env)
if cp.returncode != 0:
@ -283,7 +283,9 @@ class ConfigureController(SubiquityController):
log.error("Failed to install recommended language packs.")
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:
log.error("Failed to run locale activation commands.")
return