You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.0 KiB
77 lines
2.0 KiB
8 years ago
|
#!/bin/sh
|
||
|
#
|
||
5 years ago
|
# Build and test Git inside container
|
||
8 years ago
|
#
|
||
|
# Usage:
|
||
5 years ago
|
# run-docker-build.sh <host-user-id>
|
||
8 years ago
|
#
|
||
|
|
||
7 years ago
|
set -ex
|
||
7 years ago
|
|
||
7 years ago
|
if test $# -ne 1 || test -z "$1"
|
||
|
then
|
||
5 years ago
|
echo >&2 "usage: run-docker-build.sh <host-user-id>"
|
||
7 years ago
|
exit 1
|
||
|
fi
|
||
|
|
||
5 years ago
|
case "$jobname" in
|
||
|
Linux32)
|
||
|
switch_cmd="linux32 --32bit i386"
|
||
|
;;
|
||
|
*)
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
8 years ago
|
# Update packages to the latest available versions
|
||
5 years ago
|
command $switch_cmd sh -c '
|
||
8 years ago
|
apt update >/dev/null &&
|
||
|
apt install -y build-essential libcurl4-openssl-dev libssl-dev \
|
||
|
libexpat-dev gettext python >/dev/null
|
||
7 years ago
|
'
|
||
8 years ago
|
|
||
|
# If this script runs inside a docker container, then all commands are
|
||
|
# usually executed as root. Consequently, the host user might not be
|
||
|
# able to access the test output files.
|
||
7 years ago
|
# If a non 0 host user id is given, then create a user "ci" with that
|
||
|
# user id to make everything accessible to the host user.
|
||
7 years ago
|
HOST_UID=$1
|
||
7 years ago
|
if test $HOST_UID -eq 0
|
||
|
then
|
||
|
# Just in case someone does want to run the test suite as root.
|
||
|
CI_USER=root
|
||
|
else
|
||
|
CI_USER=ci
|
||
7 years ago
|
if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
|
||
|
then
|
||
|
echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
|
||
|
else
|
||
|
useradd -u $HOST_UID $CI_USER
|
||
|
fi
|
||
|
|
||
7 years ago
|
# Due to a bug the test suite was run as root in the past, so
|
||
|
# a prove state file created back then is only accessible by
|
||
|
# root. Now that bug is fixed, the test suite is run as a
|
||
|
# regular user, but the prove state file coming from Travis
|
||
|
# CI's cache might still be owned by root.
|
||
|
# Make sure that this user has rights to any cached files,
|
||
|
# including an existing prove state file.
|
||
|
test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
|
||
|
fi
|
||
8 years ago
|
|
||
|
# Build and test
|
||
5 years ago
|
command $switch_cmd su -m -l $CI_USER -c "
|
||
7 years ago
|
set -ex
|
||
5 years ago
|
export DEVELOPER='$DEVELOPER'
|
||
|
export DEFAULT_TEST_TARGET='$DEFAULT_TEST_TARGET'
|
||
|
export GIT_PROVE_OPTS='$GIT_PROVE_OPTS'
|
||
|
export GIT_TEST_OPTS='$GIT_TEST_OPTS'
|
||
|
export GIT_TEST_CLONE_2GB='$GIT_TEST_CLONE_2GB'
|
||
|
export MAKEFLAGS='$MAKEFLAGS'
|
||
|
export cache_dir='$cache_dir'
|
||
7 years ago
|
cd /usr/src/git
|
||
5 years ago
|
test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove
|
||
6 years ago
|
make
|
||
6 years ago
|
make test
|
||
5 years ago
|
"
|