Browse code

Add a script to install a bundle into Docker for Mac

After building docker from the git repo, you can run
```
./contrib/mac-install-bundle.sh install
```
and this will tell Docker for Mac to look for a bundle at the current
path to run instead of the built in version of Docker. This will persist
until you do a factory reset or run
```
./contrib/mac-install-bundle.sh undo
```

A factory reset is advised to reset as a development Docker may break your
install.

The path must be a path that is shared with Docker for Mac so that the VM
can find it - nothing is installed into the image.

This is in `contrib/` as it is a best effort attempt to make it easier for
Docker for Mac users to test master or pull requests. If it breaks anything
a factory reset is your friend.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>

Justin Cormack authored on 2016/09/14 21:36:29
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,45 @@
0
+#!/bin/sh
1
+
2
+set -e
3
+
4
+errexit() {
5
+	echo "$1"
6
+	exit 1
7
+}
8
+
9
+[ "$(uname -s)" == "Darwin" ] || errexit "This script can only be used on a Mac"
10
+
11
+[ $# -eq 1 ] || errexit "Usage: $0 install|undo"
12
+
13
+BUNDLE="bundles/$(cat VERSION)"
14
+BUNDLE_PATH="$PWD/$BUNDLE"
15
+CLIENT_PATH="$BUNDLE_PATH/cross/darwin/amd64/docker"
16
+DATABASE="$HOME/Library/Containers/com.docker.docker/Data/database"
17
+DATABASE_KEY="$DATABASE/com.docker.driver.amd64-linux/bundle"
18
+
19
+[ -d "$DATABASE" ] || errexit "Docker for Mac must be installed for this script"
20
+
21
+case "$1" in
22
+"install")
23
+	[ -d "$BUNDLE" ] || errexit "cannot find bundle $BUNDLE"
24
+	[ -e "$CLIENT_PATH" ] || errexit "you need to run make cross first"
25
+	[ -e "$BUNDLE/binary-daemon/dockerd" ] || errexit "you need to build binaries first"
26
+	[ -f "$BUNDLE/binary-client/docker" ] || errexit "you need to build binaries first"
27
+	git -C "$DATABASE" reset --hard >/dev/null
28
+	echo "$BUNDLE_PATH" > "$DATABASE_KEY"
29
+	git -C "$DATABASE" add "$DATABASE_KEY"
30
+	git -C "$DATABASE" commit -m "update bundle to $BUNDLE_PATH"
31
+	rm -f /usr/local/bin/docker
32
+	cp "$CLIENT_PATH" /usr/local/bin
33
+	echo "Bundle installed. Restart Docker to use. To uninstall, reset Docker to factory defaults."
34
+	;;
35
+"undo")
36
+	git -C "$DATABASE" reset --hard >/dev/null
37
+	[ -f "$DATABASE_KEY" ] || errexit "bundle not set"
38
+	git -C "$DATABASE" rm "$DATABASE_KEY"
39
+	git -C "$DATABASE" commit -m "remove bundle"
40
+	rm -f /usr/local/bin/docker
41
+	ln -s "$HOME/Library/Group Containers/group.com.docker/bin/docker" /usr/local/bin
42
+	echo "Bundle removed. Using dev versions may cause issues, a reset to factory defaults is recommended."
43
+	;;
44
+esac