From 382c193afa623fee4746132a05a7e5fbe39f2fb6 Mon Sep 17 00:00:00 2001 From: AlmAck Date: Sat, 3 Mar 2018 12:56:03 +0100 Subject: [PATCH 1/2] Enable the correct language in the locale.gen list the original code does not distinguish the document comments inside the locale.gen file from the real locale list. The language was then enabled from the header comments of the file instead of the correct value in the list. The new code verify tha the complete locale string is just after the first character of the string, enablig only the correct value of the locale list. An example: # en_US.UTF-8 UTF-8 --> document header, should not be enabled #en_US.UTF-8 UTF-8 --> correct section to enable Related to this request: https://code.chakralinux.org/tools/calamares-chakra/issues/2 --- src/modules/localecfg/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/localecfg/main.py b/src/modules/localecfg/main.py index 7df2fe31e..155382aab 100644 --- a/src/modules/localecfg/main.py +++ b/src/modules/localecfg/main.py @@ -65,12 +65,15 @@ def run(): with open("{!s}/etc/locale.gen".format(install_path), "w") as gen: for line in text: # always enable en_US - if en_us_locale in line and line[0] == "#": + if line.startswith(en_us_locale, 1): # uncomment line line = line[1:].lstrip() for locale_value in locale_values: - if locale_value in line and line[0] == "#": + # check the locale value starting from + # the second index because we expect that + # the first one is a '#' + if line.startswith(locale_value, 1): # uncomment line line = line[1:].lstrip() From 58952b685ca81ee6e3090deb0ae85add96f6ef6a Mon Sep 17 00:00:00 2001 From: AlmAck Date: Sat, 3 Mar 2018 14:30:08 +0100 Subject: [PATCH 2/2] the first character must be a comment to original code would match both lines: zen_US.UTF-8 UTF-8 #en_US.UTF-8 UTF-8 introducing "#" should check only the commented lines --- src/modules/localecfg/main.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/modules/localecfg/main.py b/src/modules/localecfg/main.py index 155382aab..e6c37133b 100644 --- a/src/modules/localecfg/main.py +++ b/src/modules/localecfg/main.py @@ -65,15 +65,12 @@ def run(): with open("{!s}/etc/locale.gen".format(install_path), "w") as gen: for line in text: # always enable en_US - if line.startswith(en_us_locale, 1): + if line.startswith("#" + en_us_locale): # uncomment line line = line[1:].lstrip() for locale_value in locale_values: - # check the locale value starting from - # the second index because we expect that - # the first one is a '#' - if line.startswith(locale_value, 1): + if line.startswith("#" + locale_value): # uncomment line line = line[1:].lstrip()