From 957d56a52ff5f7bfaa8742998a1aa73d4aa6812d Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Mon, 17 Jan 2022 10:48:58 -0300 Subject: [PATCH 1/3] FIx unbound variable in live run --- system_setup/server/controllers/configure.py | 1 + 1 file changed, 1 insertion(+) diff --git a/system_setup/server/controllers/configure.py b/system_setup/server/controllers/configure.py index dfeab9e5..de632e14 100644 --- a/system_setup/server/controllers/configure.py +++ b/system_setup/server/controllers/configure.py @@ -289,6 +289,7 @@ class ConfigureController(SubiquityController): create_user_base = [] assign_grp_base = [] usergroups_list = get_users_and_groups() + etc_dir = "/etc" # default if not dryrun. if self.app.opts.dry_run: log.debug("creating a mock-up env for user %s", username) # creating folders and files for dryrun From a14a143d55ef5cf1de38e5f0762896b0151a0148 Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Mon, 17 Jan 2022 10:49:47 -0300 Subject: [PATCH 2/3] Fix l-s-c behavior under SNAP environment. - By passing the datadir command line option. --- system_setup/server/controllers/configure.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/system_setup/server/controllers/configure.py b/system_setup/server/controllers/configure.py index de632e14..ea437a55 100644 --- a/system_setup/server/controllers/configure.py +++ b/system_setup/server/controllers/configure.py @@ -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) From 0d30deac7fc4ac8378f8586c61d897809433019e Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Tue, 18 Jan 2022 10:18:45 -0300 Subject: [PATCH 3/3] Promotes the "--no-checks" to outside of dry-run Tests in real WSL2 environment revealed that update-locale checks fails but with the "--no-checks" option it updates the locale files accordingly and when the image restarts the locale is correctly set. --- system_setup/server/controllers/configure.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system_setup/server/controllers/configure.py b/system_setup/server/controllers/configure.py index ea437a55..1cf00b16 100644 --- a/system_setup/server/controllers/configure.py +++ b/system_setup/server/controllers/configure.py @@ -85,7 +85,8 @@ class ConfigureController(SubiquityController): def __update_locale_cmd(self, lang) -> List[str]: """ Add mocking cli to update-locale if in dry-run.""" - updateLocCmd = ["update-locale", "LANG={}".format(lang)] + updateLocCmd = ["update-locale", "LANG={}".format(lang), + "--no-checks"] if not self.app.opts.dry_run: return updateLocCmd @@ -93,8 +94,7 @@ class ConfigureController(SubiquityController): "etc/default/") os.makedirs(defaultLocDir, exist_ok=True) updateLocCmd += ["--locale-file", - os.path.join(defaultLocDir, "locale"), - "--no-checks"] + os.path.join(defaultLocDir, "locale")] return updateLocCmd async def _activate_locale(self, lang, env) -> bool: