Oliver Smith | 0fa204e | 2021-08-12 15:16:11 +0200 | [diff] [blame] | 1 | #!/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. |
| 7 | DIR_OSMODEV="$(readlink -f "$(dirname $0)/../..")" |
| 8 | DIR_MAKE="$DIR_OSMODEV/ttcn3/make" |
| 9 | DIR_USR_LOCAL="$DIR_OSMODEV/ttcn3/usr_local" |
| 10 | RUN_SCRIPT="$DIR_OSMODEV/ttcn3/.run.sh" |
| 11 | DOCKER_IMG="$1" |
| 12 | UID="$(id -u)" |
| 13 | shift |
| 14 | |
| 15 | mkdir -p "$DIR_MAKE" |
| 16 | |
| 17 | # Script running as user inside docker |
| 18 | echo "#!/bin/sh -ex" > "$RUN_SCRIPT" |
| 19 | echo "cd \"$PWD\"" >> "$RUN_SCRIPT" |
| 20 | for i in "$@"; do |
| 21 | echo -n "'$i' " >> "$RUN_SCRIPT" |
| 22 | done |
| 23 | echo >> "$RUN_SCRIPT" |
| 24 | chmod +x "$RUN_SCRIPT" |
| 25 | |
| 26 | docker 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 | " |