dockcross: Add support for Windows

Tested on Git Bash and Bash on Ubuntu for Windows.

There are some issue with building the Docker image itself, but using the
images works great.
This commit is contained in:
Matt McCormick
2016-11-16 19:02:55 -08:00
parent 46e4b18ebf
commit d9d65ffcc9
2 changed files with 22 additions and 5 deletions

View File

@ -171,18 +171,35 @@ fi
# Set the docker run extra args (if any)
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
# If we are not running via boot2docker
if [ -z $DOCKER_HOST ]; then
# Bash on Ubuntu on Windows
UBUNTU_ON_WINDOWS=$(grep -l Microsoft /proc/version)
# MSYS, Git Bash, etc.
MSYS=$(grep -l MINGW /proc/version)
if [ -z "$UBUNTU_ON_WINDOWS" -a -z "$MSYS" ]; then
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
fi
# Change the PWD when working in Docker on Windows
if [ -n "$UBUNTU_ON_WINDOWS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\/mnt\//}
HOST_PWD=${HOST_PWD/\//:\/}
elif [ -n "$MSYS" ]; then
HOST_PWD=$PWD
HOST_PWD=${HOST_PWD/\//}
HOST_PWD=${HOST_PWD/\//:\/}
else
HOST_PWD=$PWD
fi
#------------------------------------------------------------------------------
# Now, finally, run the command in a container
#
tty -s && TTY_ARGS=-ti || TTY_ARGS=
CONTAINER_NAME=dockcross_$RANDOM
docker run $TTY_ARGS --name $CONTAINER_NAME \
-v $PWD:/work \
-v $HOST_PWD:/work \
$USER_IDS \
$FINAL_ARGS \
$FINAL_IMAGE "$@"