]> git.ipfire.org Git - thirdparty/git.git/blame - ci/run-linux32-build.sh
ci/linux32: parameterise command to switch arch
[thirdparty/git.git] / ci / run-linux32-build.sh
CommitLineData
88dedd5e
JS
1#!/bin/sh
2#
3# Build and test Git in a 32-bit environment
4#
5# Usage:
53303302 6# run-linux32-build.sh <host-user-id>
88dedd5e
JS
7#
8
04d47e96 9set -ex
a8b8b6b8 10
53303302
SG
11if test $# -ne 1 || test -z "$1"
12then
13 echo >&2 "usage: run-linux32-build.sh <host-user-id>"
14 exit 1
15fi
16
2bd1e2d2
ĐTCD
17case "$jobname" in
18Linux32)
19 switch_cmd="linux32 --32bit i386"
20 ;;
21*)
22 exit 1
23 ;;
24esac
25
88dedd5e 26# Update packages to the latest available versions
2bd1e2d2 27command $switch_cmd sh -c '
88dedd5e
JS
28 apt update >/dev/null &&
29 apt install -y build-essential libcurl4-openssl-dev libssl-dev \
30 libexpat-dev gettext python >/dev/null
04d47e96 31'
88dedd5e
JS
32
33# If this script runs inside a docker container, then all commands are
34# usually executed as root. Consequently, the host user might not be
35# able to access the test output files.
53303302
SG
36# If a non 0 host user id is given, then create a user "ci" with that
37# user id to make everything accessible to the host user.
04d47e96 38HOST_UID=$1
53303302
SG
39if test $HOST_UID -eq 0
40then
41 # Just in case someone does want to run the test suite as root.
42 CI_USER=root
43else
44 CI_USER=ci
6b995760
SG
45 if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
46 then
47 echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
48 else
49 useradd -u $HOST_UID $CI_USER
50 fi
51
53303302
SG
52 # Due to a bug the test suite was run as root in the past, so
53 # a prove state file created back then is only accessible by
54 # root. Now that bug is fixed, the test suite is run as a
55 # regular user, but the prove state file coming from Travis
56 # CI's cache might still be owned by root.
57 # Make sure that this user has rights to any cached files,
58 # including an existing prove state file.
59 test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
60fi
88dedd5e
JS
61
62# Build and test
2bd1e2d2 63command $switch_cmd su -m -l $CI_USER -c "
04d47e96 64 set -ex
ffce2ebd
ĐTCD
65 export DEVELOPER='$DEVELOPER'
66 export DEFAULT_TEST_TARGET='$DEFAULT_TEST_TARGET'
67 export GIT_PROVE_OPTS='$GIT_PROVE_OPTS'
68 export GIT_TEST_OPTS='$GIT_TEST_OPTS'
69 export GIT_TEST_CLONE_2GB='$GIT_TEST_CLONE_2GB'
70 export MAKEFLAGS='$MAKEFLAGS'
71 export cache_dir='$cache_dir'
04d47e96 72 cd /usr/src/git
ffce2ebd 73 test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove
eaa62291 74 make
bbf24adb 75 make test
ffce2ebd 76"