summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@yahoo-inc.com>2016-09-15 15:03:43 +0200
committerArnstein Ressem <aressem@yahoo-inc.com>2016-09-15 15:03:43 +0200
commit84b3929a0faaf7f8d713dadf1b1832b24832869f (patch)
tree7798a12881ce81c9dd094e848f12bd27df158850 /docker
parent0c2d67ab5e59b1b01e93325d4c86f249f0700344 (diff)
Make it possible to use native docker on OSX.
Diffstat (limited to 'docker')
-rwxr-xr-xdocker/enter-build-container-internal.sh25
1 files changed, 16 insertions, 9 deletions
diff --git a/docker/enter-build-container-internal.sh b/docker/enter-build-container-internal.sh
index 7da96fde376..c28837583e0 100755
--- a/docker/enter-build-container-internal.sh
+++ b/docker/enter-build-container-internal.sh
@@ -12,18 +12,25 @@ DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
cd $DIR
CALLER_UID=$(stat -c "%u" $DIR)
-CALLER_GID=$(stat -c "%g" $DIR)
-groupadd -f -g $CALLER_GID $USERNAME
-useradd -u $CALLER_UID -g $CALLER_GID $USERNAME
-echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+if [ $CALLER_UID -ne 0 ]; then
+ # We are in a system that maps the uids and this dir is not owned by root
+ # Create a user with same uid and gid to avoid mixing
+ CALLER_GID=$(stat -c "%g" $DIR)
-su -c "mkdir -p $DIR/../.ccache" $USERNAME
-su -c "ln -sf $DIR/../.ccache /home/$USERNAME/.ccache" $USERNAME
+ groupadd -f -g $CALLER_GID $USERNAME
+ useradd -u $CALLER_UID -g $CALLER_GID $USERNAME
+ echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+else
+ USERNAME=root
+fi
+
+su -c "mkdir -p $DIR/../.ccache" - $USERNAME
+su -c "ln -sf $DIR/../.ccache \$HOME/.ccache" - $USERNAME
-su -c "mkdir -p $DIR/../.m2" $USERNAME
-su -c "ln -sf $DIR/../.m2 /home/$USERNAME/.m2" $USERNAME
+su -c "mkdir -p $DIR/../.m2" - $USERNAME
+su -c "ln -sf $DIR/../.m2 $HOME/.m2" - $USERNAME
cd $DIR/..
-su $USERNAME
+su -c "cd $DIR/.. && /bin/bash" - $USERNAME