From: Yu Watanabe Date: Sat, 29 Dec 2018 13:00:07 +0000 (+0900) Subject: meson: check whether C.UTF-8 exists or not and use it if exists X-Git-Tag: v241-rc1~136^2 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=03475e2232d655e9a1c584080ca4ed592b1bd623 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. --- diff --git a/meson.build b/meson.build index 9ca3b72e4d5..f74a0bf3b2d 100644 --- a/meson.build +++ b/meson.build @@ -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()) diff --git a/meson_options.txt b/meson_options.txt index 7a75f380f9d..3474265bd35 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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 index 00000000000..43087980a94 --- /dev/null +++ b/tools/choose-default-locale.sh @@ -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