summaryrefslogtreecommitdiff
path: root/.gitlab/ci.sh
diff options
context:
space:
mode:
Diffstat (limited to '.gitlab/ci.sh')
-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" ;;