summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-08-24 17:39:20 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-05 14:51:27 -0400
commitbe2cc0ad2109894d2f576c73e3f037b6b79a6bdc (patch)
tree4419c2dbbf22ae48c826c36abcad0ac39611d8a3
parent67059893a232e682aa5eca7a3d13042b1c884d55 (diff)
downloadhaskell-be2cc0ad2109894d2f576c73e3f037b6b79a6bdc.tar.gz
gitlab-ci: More intelligent detection of locale availability
Previously ci.sh would unconditionally use C.UTF-8. However, this fails on Centos 7, which appears not to provide this locale. Now we first try C.UTF-8, then try en_US.UTF-8, then fail. Works around #18607.
-rwxr-xr-x.gitlab/ci.sh29
1 files changed, 26 insertions, 3 deletions
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index dcaa41b089..f031c5f03f 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -26,9 +26,6 @@ LT_CYAN="1;36"
WHITE="1;37"
LT_GRAY="0;37"
-export LANG=C.UTF-8
-export LC_ALL=C.UTF-8
-
# GitLab Pipelines log section delimiters
# https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
start_section() {
@@ -60,6 +57,30 @@ function run() {
TOP="$(pwd)"
+function setup_locale() {
+ # BSD grep terminates early with -q, consequently locale -a will get a
+ # SIGPIPE and the pipeline will fail with pipefail.
+ shopt -o -u pipefail
+ if locale -a | grep -q C.UTF-8; then
+ # Debian
+ export LANG=C.UTF-8
+ elif locale -a | grep -q C.utf8; then
+ # Fedora calls it this
+ export LANG=C.utf8
+ elif locale -a | grep -q en_US.UTF-8; then
+ # Centos doesn't have C.UTF-8
+ export LANG=en_US.UTF-8
+ else
+ error "Failed to find usable locale"
+ info "Available locales:"
+ locale -a
+ fail "No usable locale, aborting..."
+ fi
+ info "Using locale $LANG..."
+ export LC_ALL=$LANG
+ shopt -o -s pipefail
+}
+
function mingw_init() {
case "$MSYSTEM" in
MINGW32)
@@ -423,6 +444,8 @@ function shell() {
run $cmd
}
+setup_locale
+
# Determine Cabal data directory
case "$(uname)" in
MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;;