mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH v2] ptxd_make_world_common.sh: fix meson build for non-Debian distros
@ 2018-01-17 17:34 Clemens Gruber
  0 siblings, 0 replies; only message in thread
From: Clemens Gruber @ 2018-01-17 17:34 UTC (permalink / raw)
  To: ptxdist; +Cc: Clemens Gruber

Debian patches glibc to add a special C.UTF-8 locale, which is not
available on most other distros.
For the meson build to work on other distros like ArchLinux, let's grep
the output of locale -a and try to find C.UTF-8, en_US.UTF-8 or an en_*
UTF-8 locale. If none can be found, fall back to any UTF-8 locale and
print a warning.

Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
---

Changes since v1:
- Followed Michaels recommendations to prefer en_US and en_* locales
  and only fall back to any UTF-8 locale as a last resort
- Added "-m 1" to all grep invocations to limit the number of matches

 scripts/lib/ptxd_make_world_common.sh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/ptxd_make_world_common.sh b/scripts/lib/ptxd_make_world_common.sh
index 90f1c70b3..85471ce22 100644
--- a/scripts/lib/ptxd_make_world_common.sh
+++ b/scripts/lib/ptxd_make_world_common.sh
@@ -315,7 +315,19 @@ ptxd_make_world_init() {
 
 	    pkg_conf_opt="${pkg_conf_opt:-${!conf_opt_ptr}}"
 	    pkg_conf_env="PTXDIST_ICECC= ${pkg_conf_env}"
-	    pkg_env="${pkg_env} LC_ALL='C.UTF-8'"
+
+	    # Try to find a suitable UTF-8 locale on all distros
+	    local c_locale
+	    if c_locale=$(locale -a | grep -i -m 1 "^C\.utf[-]\?8$") || \
+	       c_locale=$(locale -a | grep -i -m 1 "^en_US\.utf[-]\?8$") || \
+	       c_locale=$(locale -a | grep -i -m 1 "^en_.*\.utf[-]\?8$"); then
+		pkg_env="${pkg_env} LC_ALL='${c_locale}'"
+	    else
+		ptxd_warning "Failed to find a good UTF-8 locale for meson."
+		pkg_env="${pkg_env} LC_ALL='$(locale -a | grep -i -m 1 "\.utf[-]\?8")'"
+	    fi
+	    unset c_locale
+
 	    if [ "${PTXDIST_VERBOSE}" = "1" ]; then
 		pkg_make_opt="-v ${pkg_make_opt}"
 		pkg_install_opt="-v ${pkg_install_opt}"
-- 
2.15.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-17 17:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-17 17:34 [ptxdist] [PATCH v2] ptxd_make_world_common.sh: fix meson build for non-Debian distros Clemens Gruber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox