meson: check whether C.UTF-8 exists or not and use it if exists

If C.UTF-8 does not exist, then fallback to en_US.UTF-8 or C.
This commit is contained in:
Yu Watanabe 2018-12-29 22:00:07 +09:00
parent 8ca9e92c74
commit 03475e2232
3 changed files with 17 additions and 1 deletions

View 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())

View 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',

12
tools/choose-default-locale.sh Executable file
View File

@ -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