Browse code

Build containerd, runc, and proxy statically

These were originally static binaries in the first place, this changes
them back to that.

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>

Eli Uriegas authored on 2018/03/08 06:29:10
Showing 3 changed files
... ...
@@ -14,10 +14,15 @@ install_containerd() {
14 14
 
15 15
 	(
16 16
 
17
-		if [ "$1" == "static" ]; then
18
-			export BUILDTAGS='static_build netgo'
19
-			export EXTRA_FLAGS='-buildmod pie'
20
-			export EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'
17
+		export BUILDTAGS='static_build netgo'
18
+		export EXTRA_FLAGS='-buildmod pie'
19
+		export EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'
20
+
21
+		# Reset build flags to nothing if we want a dynbinary
22
+		if [ "$1" == "dynamic" ]; then
23
+			export BUILDTAGS=''
24
+			export EXTRA_FLAGS=''
25
+			export EXTRA_LDFLAGS=''
21 26
 		fi
22 27
 
23 28
 		make
... ...
@@ -23,6 +23,7 @@ install_proxy() {
23 23
 
24 24
 install_proxy_dynamic() {
25 25
 	export PROXY_LDFLAGS="-linkmode=external" install_proxy
26
+	export BUILD_MODE="-buildmode=pie"
26 27
 	_install_proxy
27 28
 }
28 29
 
... ...
@@ -31,7 +32,7 @@ _install_proxy() {
31 31
 	git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
32 32
 	cd "$GOPATH/src/github.com/docker/libnetwork"
33 33
 	git checkout -q "$LIBNETWORK_COMMIT"
34
-	go build -buildmode=pie -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
34
+	go build $BUILD_MODE -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
35 35
 }
36 36
 
37 37
 
... ...
@@ -11,7 +11,12 @@ install_runc() {
11 11
 	git clone https://github.com/opencontainers/runc.git "$GOPATH/src/github.com/opencontainers/runc"
12 12
 	cd "$GOPATH/src/github.com/opencontainers/runc"
13 13
 	git checkout -q "$RUNC_COMMIT"
14
-	make BUILDTAGS="$RUNC_BUILDTAGS" $1
14
+	if [ -z "$1" ]; then
15
+		target=static
16
+	else
17
+		target="$1"
18
+	fi
19
+	make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
15 20
 	mkdir -p ${PREFIX}
16 21
 	cp runc ${PREFIX}/docker-runc
17 22
 }