|
3 | 3 | # Build and test Git in a 32-bit environment
|
4 | 4 | #
|
5 | 5 | # Usage:
|
6 |
| -# run-linux32-build.sh [host-user-id] |
| 6 | +# run-linux32-build.sh <host-user-id> |
7 | 7 | #
|
8 | 8 |
|
9 |
| -set -x |
| 9 | +set -ex |
| 10 | + |
| 11 | +if test $# -ne 1 || test -z "$1" |
| 12 | +then |
| 13 | + echo >&2 "usage: run-linux32-build.sh <host-user-id>" |
| 14 | + exit 1 |
| 15 | +fi |
10 | 16 |
|
11 | 17 | # Update packages to the latest available versions
|
12 | 18 | linux32 --32bit i386 sh -c '
|
13 | 19 | apt update >/dev/null &&
|
14 | 20 | apt install -y build-essential libcurl4-openssl-dev libssl-dev \
|
15 | 21 | libexpat-dev gettext python >/dev/null
|
16 |
| -' && |
| 22 | +' |
17 | 23 |
|
18 | 24 | # If this script runs inside a docker container, then all commands are
|
19 | 25 | # usually executed as root. Consequently, the host user might not be
|
20 | 26 | # able to access the test output files.
|
21 |
| -# If a host user id is given, then create a user "ci" with the host user |
22 |
| -# id to make everything accessible to the host user. |
23 |
| -HOST_UID=$1 && |
24 |
| -CI_USER=$USER && |
25 |
| -test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) && |
| 27 | +# If a non 0 host user id is given, then create a user "ci" with that |
| 28 | +# user id to make everything accessible to the host user. |
| 29 | +HOST_UID=$1 |
| 30 | +if test $HOST_UID -eq 0 |
| 31 | +then |
| 32 | + # Just in case someone does want to run the test suite as root. |
| 33 | + CI_USER=root |
| 34 | +else |
| 35 | + CI_USER=ci |
| 36 | + if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID |
| 37 | + then |
| 38 | + echo "user '$CI_USER' already exists with the requested ID $HOST_UID" |
| 39 | + else |
| 40 | + useradd -u $HOST_UID $CI_USER |
| 41 | + fi |
| 42 | + |
| 43 | + # Due to a bug the test suite was run as root in the past, so |
| 44 | + # a prove state file created back then is only accessible by |
| 45 | + # root. Now that bug is fixed, the test suite is run as a |
| 46 | + # regular user, but the prove state file coming from Travis |
| 47 | + # CI's cache might still be owned by root. |
| 48 | + # Make sure that this user has rights to any cached files, |
| 49 | + # including an existing prove state file. |
| 50 | + test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir" |
| 51 | +fi |
26 | 52 |
|
27 | 53 | # Build and test
|
28 | 54 | linux32 --32bit i386 su -m -l $CI_USER -c '
|
29 |
| - cd /usr/src/git && |
30 |
| - ln -s /tmp/travis-cache/.prove t/.prove && |
31 |
| - make --jobs=2 && |
32 |
| - make --quiet test |
| 55 | + set -ex |
| 56 | + cd /usr/src/git |
| 57 | + test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove |
| 58 | + make --jobs=2 |
| 59 | + make --quiet test |
33 | 60 | '
|
0 commit comments