blob: 25cedb43d9bad04ece32ec19bf45960fbb5a274f [file] [log] [blame]
Oliver Smith0fa204e2021-08-12 15:16:11 +02001#!/bin/sh -ex
2# Passed by ttcn3.sh to gen_makefile.py to run './configure', 'make' and
3# 'make install' inside docker. The osmo-dev directory is mounted at the same
4# location inside the docker container. A usr_local dir is mounted to
5# /usr/local, so 'make install' can put all files there and following builds
6# have the files available.
7DIR_OSMODEV="$(readlink -f "$(dirname $0)/../..")"
8DIR_MAKE="$DIR_OSMODEV/ttcn3/make"
9DIR_USR_LOCAL="$DIR_OSMODEV/ttcn3/usr_local"
10RUN_SCRIPT="$DIR_OSMODEV/ttcn3/.run.sh"
11DOCKER_IMG="$1"
12UID="$(id -u)"
13shift
14
15mkdir -p "$DIR_MAKE"
16
17# Script running as user inside docker
18echo "#!/bin/sh -ex" > "$RUN_SCRIPT"
19echo "cd \"$PWD\"" >> "$RUN_SCRIPT"
20for i in "$@"; do
21 echo -n "'$i' " >> "$RUN_SCRIPT"
22done
23echo >> "$RUN_SCRIPT"
24chmod +x "$RUN_SCRIPT"
25
26docker run \
27 --rm \
28 -e "LD_LIBRARY_PATH=/usr/local/lib" \
29 -v "$DIR_OSMODEV:$DIR_OSMODEV" \
30 -v "$DIR_USR_LOCAL:/usr/local" \
31 -v "$RUN_SCRIPT:/tmp/run.sh:ro" \
32 "$DOCKER_IMG" \
33 sh -ex -c "
34 if ! id -u $UID 2>/dev/null; then
35 useradd -u $UID user
36 fi
37 su \$(id -un $UID) -c /tmp/run.sh
38 "