mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 10:55:37 -04:00
[localecfg] Move all path-setting to one spot
- Make the way the paths are constructed consistent - Name the paths more consistently
This commit is contained in:
parent
863d00f40c
commit
7498629b5f
1 changed files with 11 additions and 9 deletions
|
@ -48,23 +48,27 @@ def run():
|
||||||
}
|
}
|
||||||
|
|
||||||
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
|
target_locale_gen = "{!s}/etc/locale.gen".format(install_path)
|
||||||
|
target_locale_gen_bak = target_locale_gen + ".bak"
|
||||||
|
target_locale_conf_path = "{!s}/etc/locale.conf".format(install_path)
|
||||||
|
target_etc_default_path = "{!s}/etc/default".format(install_path)
|
||||||
|
|
||||||
# restore backup if available
|
# restore backup if available
|
||||||
if os.path.exists('/etc/locale.gen.bak'):
|
if os.path.exists('/etc/locale.gen.bak'):
|
||||||
shutil.copy2("{!s}/etc/locale.gen.bak".format(install_path),
|
shutil.copy2(target_locale_gen_bak,
|
||||||
"{!s}/etc/locale.gen".format(install_path))
|
target_locale_gen)
|
||||||
|
|
||||||
# run locale-gen if detected
|
# run locale-gen if detected
|
||||||
if os.path.exists('/etc/locale.gen'):
|
if os.path.exists('/etc/locale.gen'):
|
||||||
text = []
|
text = []
|
||||||
|
|
||||||
with open("{!s}/etc/locale.gen".format(install_path), "r") as gen:
|
with open(target_locale_gen, "r") as gen:
|
||||||
text = gen.readlines()
|
text = gen.readlines()
|
||||||
|
|
||||||
# we want unique values, so locale_values should have 1 or 2 items
|
# we want unique values, so locale_values should have 1 or 2 items
|
||||||
locale_values = set(locale_conf.values())
|
locale_values = set(locale_conf.values())
|
||||||
|
|
||||||
with open("{!s}/etc/locale.gen".format(install_path), "w") as gen:
|
with open(target_locale_gen, "w") as gen:
|
||||||
for line in text:
|
for line in text:
|
||||||
# always enable en_US
|
# always enable en_US
|
||||||
if line.startswith("#" + en_us_locale):
|
if line.startswith("#" + en_us_locale):
|
||||||
|
@ -82,15 +86,13 @@ def run():
|
||||||
print('locale.gen done')
|
print('locale.gen done')
|
||||||
|
|
||||||
# write /etc/locale.conf
|
# write /etc/locale.conf
|
||||||
locale_conf_path = os.path.join(install_path, "etc/locale.conf")
|
with open(target_locale_conf_path, "w") as lcf:
|
||||||
with open(locale_conf_path, "w") as lcf:
|
|
||||||
for k, v in locale_conf.items():
|
for k, v in locale_conf.items():
|
||||||
lcf.write("{!s}={!s}\n".format(k, v))
|
lcf.write("{!s}={!s}\n".format(k, v))
|
||||||
|
|
||||||
# write /etc/default/locale if /etc/default exists and is a dir
|
# write /etc/default/locale if /etc/default exists and is a dir
|
||||||
etc_default_path = os.path.join(install_path, "etc/default")
|
if os.path.isdir(target_etc_default_path):
|
||||||
if os.path.isdir(etc_default_path):
|
with open(os.path.join(target_etc_default_path, "locale"), "w") as edl:
|
||||||
with open(os.path.join(etc_default_path, "locale"), "w") as edl:
|
|
||||||
for k, v in locale_conf.items():
|
for k, v in locale_conf.items():
|
||||||
edl.write("{!s}={!s}\n".format(k, v))
|
edl.write("{!s}={!s}\n".format(k, v))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue