]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: check whether C.UTF-8 exists or not and use it if exists 11291/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Dec 2018 13:00:07 +0000 (22:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Jan 2019 18:41:36 +0000 (03:41 +0900)
If C.UTF-8 does not exist, then fallback to en_US.UTF-8 or C.

meson.build
meson_options.txt
tools/choose-default-locale.sh [new file with mode: 0755]

index 9ca3b72e4d50003bf3377ed7b52687d57db4e7ba..f74a0bf3b2d82b4bafa3da8ccf3804537f52d539 100644 (file)
@@ -829,6 +829,10 @@ conf.set_quoted('NTP_SERVERS', ntp_servers)
 substs.set('NTP_SERVERS', ntp_servers)
 
 default_locale = get_option('default-locale')
+if default_locale == ''
+        choose_default_locale_sh = find_program('tools/choose-default-locale.sh')
+        default_locale = run_command(choose_default_locale_sh).stdout().strip()
+endif
 conf.set_quoted('SYSTEMD_DEFAULT_LOCALE', default_locale)
 
 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
index 7a75f380f9d6dc76d6c1ba7b8f5d96a7f135abe6..3474265bd35241a60a0972bcf53278a9a335c7f1 100644 (file)
@@ -195,7 +195,7 @@ option('default-kill-user-processes', type : 'boolean',
        description : 'the default value for KillUserProcesses= setting')
 option('gshadow', type : 'boolean',
        description : 'support for shadow group')
-option('default-locale', type : 'string', value : 'C',
+option('default-locale', type : 'string', value : '',
        description : 'default locale used when /etc/locale.conf does not exist')
 
 option('default-dnssec', type : 'combo',
diff --git a/tools/choose-default-locale.sh b/tools/choose-default-locale.sh
new file mode 100755 (executable)
index 0000000..4308798
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Fedora uses C.utf8 but Debian uses C.UTF-8
+if locale -a | grep -xq -E 'C\.(utf8|UTF-8)'; then
+        echo 'C.UTF-8'
+elif locale -a | grep -xqF 'en_US.utf8'; then
+        echo 'en_US.UTF-8'
+else
+        echo 'C'
+fi