3 # Build and test Git inside container
6 # run-docker-build.sh <host-user-id>
11 if test $# -ne 1 || test -z "$1"
13 echo >&2 "usage: run-docker-build.sh <host-user-id>"
19 switch_cmd="linux32 --32bit i386"
26 "${0%/*}/install-docker-dependencies.sh"
28 # If this script runs inside a docker container, then all commands are
29 # usually executed as root. Consequently, the host user might not be
30 # able to access the test output files.
31 # If a non 0 host user id is given, then create a user "ci" with that
32 # user id to make everything accessible to the host user.
34 if test $HOST_UID -eq 0
36 # Just in case someone does want to run the test suite as root.
40 if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
42 echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
44 useradd -u $HOST_UID $CI_USER
47 # Due to a bug the test suite was run as root in the past, so
48 # a prove state file created back then is only accessible by
49 # root. Now that bug is fixed, the test suite is run as a
50 # regular user, but the prove state file coming from Travis
51 # CI's cache might still be owned by root.
52 # Make sure that this user has rights to any cached files,
53 # including an existing prove state file.
54 test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
58 command $switch_cmd su -m -l $CI_USER -c "
60 export DEVELOPER='$DEVELOPER'
61 export DEFAULT_TEST_TARGET='$DEFAULT_TEST_TARGET'
62 export GIT_PROVE_OPTS='$GIT_PROVE_OPTS'
63 export GIT_TEST_OPTS='$GIT_TEST_OPTS'
64 export GIT_TEST_CLONE_2GB='$GIT_TEST_CLONE_2GB'
65 export MAKEFLAGS='$MAKEFLAGS'
66 export cache_dir='$cache_dir'
68 test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove