1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-05 08:47:56 +01:00
git/ci/run-linux32-build.sh
SZEDER Gábor 6b995760dc travis-ci: don't fail if user already exists on 32 bit Linux build job
The 32 bit Linux build job runs in a Docker container, which lends
itself to running and debugging locally, too.  Especially during
debugging one usually doesn't want to start with a fresh container
every time, to save time spent on installing a bunch of dependencies.
However, that doesn't work quite smootly, because the script running
in the container always creates a new user, which then must be removed
every time before subsequent executions, or the build script fails.

Make this process more convenient and don't try to create that user if
it already exists and has the right user ID in the container, so
developers don't have to bother with running a 'userdel' each time
before they run the build script.

The build job on Travis CI always starts with a fresh Docker
container, so this change doesn't make a difference there.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-01-30 13:27:19 -08:00

60 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
#
# Build and test Git in a 32-bit environment
#
# Usage:
# run-linux32-build.sh <host-user-id>
#
set -ex
if test $# -ne 1 || test -z "$1"
then
echo >&2 "usage: run-linux32-build.sh <host-user-id>"
exit 1
fi
# Update packages to the latest available versions
linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev libssl-dev \
libexpat-dev gettext python >/dev/null
'
# 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.
# 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.
HOST_UID=$1
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
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
# 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
# Build and test
linux32 --32bit i386 su -m -l $CI_USER -c '
set -ex
cd /usr/src/git
test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove
make --jobs=2
make --quiet test
'