mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] ptxd_make_world_common.sh: fix meson build for non-Debian distros
@ 2018-01-16 15:54 Clemens Gruber
  2018-01-17  9:40 ` Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Clemens Gruber @ 2018-01-16 15:54 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 use C.UTF-8/C.utf8 locale if available or
fall back to the first matching UTF-8 locale.

Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
---
 scripts/lib/ptxd_make_world_common.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/ptxd_make_world_common.sh b/scripts/lib/ptxd_make_world_common.sh
index 90f1c70b3..6b7045237 100644
--- a/scripts/lib/ptxd_make_world_common.sh
+++ b/scripts/lib/ptxd_make_world_common.sh
@@ -315,7 +315,16 @@ 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'"
+
+	    # Use Debian C.UTF-8 locale if available or fall back to first one found
+	    local c_locale=$(locale -a | grep -i "^C\.utf[-]\?8$")
+	    if [ ! -z "${c_locale}" ]; then
+		pkg_env="${pkg_env} LC_ALL='${c_locale}'"
+	    else
+		pkg_env="${pkg_env} LC_ALL='$(locale -a | grep -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] 2+ messages in thread

* Re: [ptxdist] [PATCH] ptxd_make_world_common.sh: fix meson build for non-Debian distros
  2018-01-16 15:54 [ptxdist] [PATCH] ptxd_make_world_common.sh: fix meson build for non-Debian distros Clemens Gruber
@ 2018-01-17  9:40 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2018-01-17  9:40 UTC (permalink / raw)
  To: ptxdist

On Tue, Jan 16, 2018 at 04:54:32PM +0100, Clemens Gruber wrote:
> Debian patches glibc to add a special C.UTF-8 locale, which is not
> available on most other distros.

Right, I knew about that, but forgot to implement this.

> For the meson build to work on other distros like ArchLinux, let's grep
> the output of locale -a and use C.UTF-8/C.utf8 locale if available or
> fall back to the first matching UTF-8 locale.
> 
> Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
> ---
>  scripts/lib/ptxd_make_world_common.sh | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/ptxd_make_world_common.sh b/scripts/lib/ptxd_make_world_common.sh
> index 90f1c70b3..6b7045237 100644
> --- a/scripts/lib/ptxd_make_world_common.sh
> +++ b/scripts/lib/ptxd_make_world_common.sh
> @@ -315,7 +315,16 @@ 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'"
> +
> +	    # Use Debian C.UTF-8 locale if available or fall back to first one found
> +	    local c_locale=$(locale -a | grep -i "^C\.utf[-]\?8$")
> +	    if [ ! -z "${c_locale}" ]; then
> +		pkg_env="${pkg_env} LC_ALL='${c_locale}'"
> +	    else
> +		pkg_env="${pkg_env} LC_ALL='$(locale -a | grep -m 1 "\.utf[-]\?8")'"

This will likly result in something linke 'aa_DJ.utf8'. That's not a good
idea. Maybe like this:

local c_locale
if c_locale=$(locale -a | grep -i "^C\.utf[-]\?8$") || \
   c_locale=$(locale -a | grep -i "^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 -m 1 "\.utf[-]\?8")'"
fi

This way we get english if at all possible.

Michael

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

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-17  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 15:54 [ptxdist] [PATCH] ptxd_make_world_common.sh: fix meson build for non-Debian distros Clemens Gruber
2018-01-17  9:40 ` Michael Olbrich

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