Browse code

Add new "DOCKER_CLIENTONLY" build variable to allow skipping of the dockerinit compilation, especially for Homebrew / Mac OS X client-only compilation

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/03/07 13:22:25
Showing 2 changed files
... ...
@@ -181,6 +181,12 @@ the file "./VERSION". This binary is usually installed somewhere like
181 181
 
182 182
 ### Dynamic Daemon / Client-only Binary
183 183
 
184
+If you are only interested in a Docker client binary, set `DOCKER_CLIENTONLY` to a non-empty value using something similar to the following: (which will prevent the extra step of compiling dockerinit)
185
+
186
+```bash
187
+export DOCKER_CLIENTONLY=1
188
+```
189
+
184 190
 If you need to (due to distro policy, distro library availability, or for other
185 191
 reasons) create a dynamically compiled daemon binary, or if you are only
186 192
 interested in creating a client binary for Docker, use something similar to the
... ...
@@ -2,32 +2,37 @@
2 2
 
3 3
 DEST=$1
4 4
 
5
-# dockerinit still needs to be a static binary, even if docker is dynamic
6
-go build \
7
-	-o $DEST/dockerinit-$VERSION \
8
-	"${BUILDFLAGS[@]}" \
9
-	-ldflags "
10
-		$LDFLAGS
11
-		$LDFLAGS_STATIC
12
-		-extldflags \"$EXTLDFLAGS_STATIC\"
13
-	" \
14
-	./dockerinit
15
-echo "Created binary: $DEST/dockerinit-$VERSION"
16
-ln -sf dockerinit-$VERSION $DEST/dockerinit
17
-
18
-sha1sum=
19
-if command -v sha1sum &> /dev/null; then
20
-	sha1sum=sha1sum
21
-elif command -v shasum &> /dev/null; then
22
-	# Mac OS X - why couldn't they just use the same command name and be happy?
23
-	sha1sum=shasum
5
+if [ -z "$DOCKER_CLIENTONLY" ]; then
6
+	# dockerinit still needs to be a static binary, even if docker is dynamic
7
+	go build \
8
+		-o $DEST/dockerinit-$VERSION \
9
+		"${BUILDFLAGS[@]}" \
10
+		-ldflags "
11
+			$LDFLAGS
12
+			$LDFLAGS_STATIC
13
+			-extldflags \"$EXTLDFLAGS_STATIC\"
14
+		" \
15
+		./dockerinit
16
+	echo "Created binary: $DEST/dockerinit-$VERSION"
17
+	ln -sf dockerinit-$VERSION $DEST/dockerinit
18
+	
19
+	sha1sum=
20
+	if command -v sha1sum &> /dev/null; then
21
+		sha1sum=sha1sum
22
+	elif command -v shasum &> /dev/null; then
23
+		# Mac OS X - why couldn't they just use the same command name and be happy?
24
+		sha1sum=shasum
25
+	else
26
+		echo >&2 'error: cannot find sha1sum command or equivalent'
27
+		exit 1
28
+	fi
29
+	
30
+	# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
31
+	export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
24 32
 else
25
-	echo >&2 'error: cannot find sha1sum command or equivalent'
26
-	exit 1
33
+	# DOCKER_CLIENTONLY must be truthy, so we don't need to bother with dockerinit :)
34
+	export DOCKER_INITSHA1=""
27 35
 fi
28
-
29
-# sha1 our new dockerinit to ensure separate docker and dockerinit always run in a perfect pair compiled for one another
30
-export DOCKER_INITSHA1="$($sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
31 36
 # exported so that "dyntest" can easily access it later without recalculating it
32 37
 
33 38
 (