summaryrefslogtreecommitdiff
path: root/cloudinit/distros
diff options
context:
space:
mode:
authorKristian Klausen <kristian@klausen.dk>2021-03-15 20:30:03 +0100
committerGitHub <noreply@github.com>2021-03-15 14:30:03 -0500
commit3aeb14cd46613b97afefc4632909f6e9b83d0230 (patch)
tree591f52bf5800f63b3e9db00ce711e812b4d5f3cf /cloudinit/distros
parentd95b448fe106146b7510f7b64f2e83c51943f04d (diff)
downloadvyos-cloud-init-3aeb14cd46613b97afefc4632909f6e9b83d0230.tar.gz
vyos-cloud-init-3aeb14cd46613b97afefc4632909f6e9b83d0230.zip
archlinux: Fix broken locale logic (#841)
The locale wasn't persisted correct nor set. LP: #1402406
Diffstat (limited to 'cloudinit/distros')
-rw-r--r--cloudinit/distros/arch.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/cloudinit/distros/arch.py b/cloudinit/distros/arch.py
index 5f42a24c..f8385f7f 100644
--- a/cloudinit/distros/arch.py
+++ b/cloudinit/distros/arch.py
@@ -23,7 +23,7 @@ LOG = logging.getLogger(__name__)
class Distro(distros.Distro):
- locale_conf_fn = "/etc/locale.gen"
+ locale_gen_fn = "/etc/locale.gen"
network_conf_dir = "/etc/netctl"
resolve_conf_fn = "/etc/resolv.conf"
init_cmd = ['systemctl'] # init scripts
@@ -43,16 +43,20 @@ class Distro(distros.Distro):
cfg['ssh_svcname'] = 'sshd'
def apply_locale(self, locale, out_fn=None):
- if not out_fn:
- out_fn = self.locale_conf_fn
- subp.subp(['locale-gen', '-G', locale], capture=False)
- # "" provides trailing newline during join
+ if out_fn is not None and out_fn != "/etc/locale.conf":
+ LOG.warning("Invalid locale_configfile %s, only supported "
+ "value is /etc/locale.conf", out_fn)
lines = [
util.make_header(),
- 'LANG="%s"' % (locale),
+ # Hard-coding the charset isn't ideal, but there is no other way.
+ '%s UTF-8' % (locale),
"",
]
- util.write_file(out_fn, "\n".join(lines))
+ util.write_file(self.locale_gen_fn, "\n".join(lines))
+ subp.subp(['locale-gen'], capture=False)
+ # In the future systemd can handle locale-gen stuff:
+ # https://github.com/systemd/systemd/pull/9864
+ subp.subp(['localectl', 'set-locale', locale], capture=False)
def install_packages(self, pkglist):
self.update_package_sources()