Browse code

Add `make install` task

This installs docker and dockerd to `$DOCKER_MAKE_INSTALL_PREFIX/bin`, which
defaults to `/usr/local/bin`

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Brian Goff authored on 2016/05/24 10:44:43
Showing 11 changed files
... ...
@@ -91,6 +91,9 @@ docs: ## build the docs
91 91
 gccgo: build-gccgo ## build the gcc-go linux binaries
92 92
 	$(DOCKER_FLAGS) "$(DOCKER_IMAGE)-gccgo" hack/make.sh gccgo
93 93
 
94
+install: ## install the linux binaries
95
+	KEEPBUNDLE=1 hack/make.sh install-binary
96
+
94 97
 rpm: build ## build the rpm packages
95 98
 	$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build-rpm
96 99
 
... ...
@@ -333,6 +333,19 @@ copy_containerd() {
333 333
 	fi
334 334
 }
335 335
 
336
+install_binary() {
337
+	file="$1"
338
+	target="${DOCKER_MAKE_INSTALL_PREFIX:=/usr/local}/bin/"
339
+	if [ "$(go env GOOS)" == "linux" ]; then
340
+		echo "Installing $(basename $file) to ${target}"
341
+		cp -L "$file" "$target"
342
+	else
343
+		echo "Install is only supported on linux"
344
+		return 1
345
+	fi
346
+}
347
+
348
+
336 349
 main() {
337 350
 	# We want this to fail if the bundles already exist and cannot be removed.
338 351
 	# This is to avoid mixing bundles from different versions of the code.
339 352
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+#!/bin/bash
1
+
2
+DOCKER_CLIENT_BINARY_NAME='docker'
3
+DOCKER_DAEMON_BINARY_NAME='dockerd'
... ...
@@ -1,5 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3
+rm -rf "$DEST"
3 4
 
4 5
 # This script exists as backwards compatibility for CI
5 6
 (
... ...
@@ -1,8 +1,12 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
+[ -z "$KEEPDEST" ] && \
5
+	rm -rf "$DEST"
6
+
4 7
 (
5
-	export BINARY_SHORT_NAME='docker'
8
+	source "${MAKEDIR}/.binary-setup"
9
+	export BINARY_SHORT_NAME="$DOCKER_CLIENT_BINARY_NAME"
6 10
 	export SOURCE_PATH='./cmd/docker'
7 11
 	source "${MAKEDIR}/.binary"
8 12
 )
... ...
@@ -1,9 +1,13 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
+[ -z "$KEEPDEST" ] && \
5
+	rm -rf "$DEST"
6
+
4 7
 (
5
-	export BINARY_SHORT_NAME='dockerd'
8
+	source "${MAKEDIR}/.binary-setup"
9
+	export BINARY_SHORT_NAME="$DOCKER_DAEMON_BINARY_NAME"
6 10
 	export SOURCE_PATH='./cmd/dockerd'
7 11
 	source "${MAKEDIR}/.binary"
8 12
 	copy_containerd "$DEST" 'hash'
9
-)
10 13
\ No newline at end of file
14
+)
... ...
@@ -21,6 +21,7 @@ fi
21 21
 
22 22
 for platform in $DOCKER_CROSSPLATFORMS; do
23 23
 	(
24
+		export KEEPDEST=1
24 25
 		export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
25 26
 		mkdir -p "$DEST"
26 27
 		ABS_DEST="$(cd "$DEST" && pwd -P)"
... ...
@@ -28,14 +29,14 @@ for platform in $DOCKER_CROSSPLATFORMS; do
28 28
 		export GOARCH=${platform##*/}
29 29
 
30 30
 		if [ -z "${daemonSupporting[$platform]}" ]; then
31
-            # we just need a simple client for these platforms
31
+			# we just need a simple client for these platforms
32 32
 			export LDFLAGS_STATIC_DOCKER=""
33
-            # remove the "daemon" build tag from platforms that aren't supported
34
-            export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" )
35
-		    source "${MAKEDIR}/binary-client"
36
-        else
37
-		    source "${MAKEDIR}/binary-client"
38
-		    source "${MAKEDIR}/binary-daemon"
33
+			# remove the "daemon" build tag from platforms that aren't supported
34
+			export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" )
35
+			source "${MAKEDIR}/binary-client"
36
+		else
37
+			source "${MAKEDIR}/binary-client"
38
+			source "${MAKEDIR}/binary-daemon"
39 39
 		fi
40 40
 	)
41 41
 done
42 42
new file mode 100644
... ...
@@ -0,0 +1,12 @@
0
+#!/bin/bash
1
+
2
+set -e
3
+rm -rf "$DEST"
4
+
5
+(
6
+	source "${MAKEDIR}/install-binary-client"
7
+)
8
+
9
+(
10
+	source "${MAKEDIR}/install-binary-daemon"
11
+)
0 12
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+#!/bin/bash
1
+
2
+set -e
3
+rm -rf "$DEST"
4
+
5
+(
6
+	DEST="$(dirname $DEST)/binary-client"
7
+	source "${MAKEDIR}/.binary-setup"
8
+	install_binary "${DEST}/${DOCKER_CLIENT_BINARY_NAME}"
9
+)
0 10
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+#!/bin/bash
1
+
2
+set -e
3
+rm -rf "$DEST"
4
+
5
+(
6
+	DEST="$(dirname $DEST)/binary-daemon"
7
+	source "${MAKEDIR}/.binary-setup"
8
+	install_binary "${DEST}/${DOCKER_DAEMON_BINARY_NAME}"
9
+)
... ...
@@ -13,8 +13,11 @@ fi
13 13
 for d in "$CROSS/"*/*; do
14 14
 	export GOARCH="$(basename "$d")"
15 15
 	export GOOS="$(basename "$(dirname "$d")")"
16
-	BINARY_NAME="docker-$VERSION"
17
-	DAEMON_BINARY_NAME="dockerd-$VERSION"
16
+
17
+	source "${MAKEDIR}/.binary-setup"
18
+
19
+	BINARY_NAME="${DOCKER_CLIENT_BINARY_NAME}-$VERSION"
20
+	DAEMON_BINARY_NAME="${DOCKER_DAEMON_BINARY_NAME}-$VERSION"
18 21
 	BINARY_EXTENSION="$(export GOOS && binary_extension)"
19 22
 	if [ "$GOOS" = 'windows' ]; then
20 23
 		# if windows use a zip, not tgz
... ...
@@ -40,9 +43,9 @@ for d in "$CROSS/"*/*; do
40 40
 
41 41
 	# Copy the correct docker binary
42 42
 	mkdir -p $TAR_PATH
43
-	cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/docker$BINARY_EXTENSION"
43
+	cp -L "$d/$BINARY_FULLNAME" "$TAR_PATH/${DOCKER_CLIENT_BINARY_NAME}${BINARY_EXTENSION}"
44 44
 	if [ -f "$d/$DAEMON_BINARY_FULLNAME" ]; then
45
-		cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/dockerd$BINARY_EXTENSION"
45
+		cp -L "$d/$DAEMON_BINARY_FULLNAME" "$TAR_PATH/${DOCKER_DAEMON_BINARY_NAME}${BINARY_EXTENSION}"
46 46
 	fi
47 47
 
48 48
 	# copy over all the containerd binaries