2016-05-28 00:24:50 +02:00
|
|
|
#!/bin/sh
|
|
|
|
set -e -u
|
|
|
|
|
2017-03-02 12:15:27 +01:00
|
|
|
HOME=/home/builder
|
2017-07-15 11:37:17 +02:00
|
|
|
if [ `uname` = Darwin ]; then
|
|
|
|
# Workaround for mac readlink not supporting -f.
|
|
|
|
REPOROOT=$PWD
|
|
|
|
else
|
|
|
|
REPOROOT="$(dirname $(readlink -f $0))/../"
|
|
|
|
fi
|
2017-07-14 00:27:46 +02:00
|
|
|
|
2016-05-28 00:24:50 +02:00
|
|
|
IMAGE_NAME=termux/package-builder
|
2016-06-04 00:41:30 +02:00
|
|
|
CONTAINER_NAME=termux-package-builder
|
2016-05-28 00:24:50 +02:00
|
|
|
|
2017-07-21 15:34:38 +02:00
|
|
|
USER=builder
|
2017-03-02 12:15:27 +01:00
|
|
|
|
2016-06-04 00:41:30 +02:00
|
|
|
echo "Running container '$CONTAINER_NAME' from image '$IMAGE_NAME'..."
|
|
|
|
|
|
|
|
docker start $CONTAINER_NAME > /dev/null 2> /dev/null || {
|
|
|
|
echo "Creating new container..."
|
|
|
|
docker run \
|
2017-02-04 23:22:56 +01:00
|
|
|
--detach \
|
2017-03-02 12:41:06 +01:00
|
|
|
--env HOME=$HOME \
|
2017-02-04 23:22:56 +01:00
|
|
|
--name $CONTAINER_NAME \
|
2017-07-14 00:27:46 +02:00
|
|
|
--volume $REPOROOT:$HOME/termux-packages \
|
2017-02-04 23:22:56 +01:00
|
|
|
--tty \
|
|
|
|
$IMAGE_NAME
|
2017-07-21 15:34:38 +02:00
|
|
|
if [ $(id -u) -ne 1000 -a $(id -u) -ne 0 ]
|
2017-07-14 00:27:46 +02:00
|
|
|
then
|
|
|
|
echo "Changed builder uid/gid... (this may take a while)"
|
|
|
|
docker exec --tty $CONTAINER_NAME chown -R $(id -u) $HOME
|
|
|
|
docker exec --tty $CONTAINER_NAME chown -R $(id -u) /data
|
|
|
|
docker exec --tty $CONTAINER_NAME usermod -u $(id -u) builder
|
|
|
|
docker exec --tty $CONTAINER_NAME groupmod -g $(id -g) builder
|
|
|
|
fi
|
2016-06-04 00:41:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" -eq "0" ]; then
|
2017-03-02 12:15:27 +01:00
|
|
|
docker exec --interactive --tty --user $USER $CONTAINER_NAME bash
|
2016-06-04 00:41:30 +02:00
|
|
|
else
|
2017-03-02 12:15:27 +01:00
|
|
|
docker exec --interactive --tty --user $USER $CONTAINER_NAME $@
|
2016-06-04 00:41:30 +02:00
|
|
|
fi
|
2016-05-28 00:24:50 +02:00
|
|
|
|
|
|
|
|