Browse code

Add osusergo build tar for static binaries

Go 1.11 includes a fix to os/user to be working in a static binary
(fixing https://github.com/golang/go/issues/23265). The fix requires
`osusergo` build tag to be set for static binaries, which is what
this commit adds (also for containerd).

[v2: sort build tags alphabetically]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Kir Kolyshkin authored on 2018/07/19 17:01:27
Showing 3 changed files
... ...
@@ -14,7 +14,7 @@ install_containerd() {
14 14
 
15 15
 	(
16 16
 
17
-		export BUILDTAGS='static_build netgo'
17
+		export BUILDTAGS='netgo osusergo static_build'
18 18
 		export EXTRA_FLAGS='-buildmode=pie'
19 19
 		export EXTRA_LDFLAGS='-extldflags "-fno-PIC -static"'
20 20
 
... ...
@@ -145,7 +145,7 @@ LDFLAGS_STATIC=''
145 145
 EXTLDFLAGS_STATIC='-static'
146 146
 # ORIG_BUILDFLAGS is necessary for the cross target which cannot always build
147 147
 # with options like -race.
148
-ORIG_BUILDFLAGS=( -tags "autogen netgo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
148
+ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
149 149
 # see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
150 150
 
151 151
 # When $DOCKER_INCREMENTAL_BINARY is set in the environment, enable incremental
... ...
@@ -5,6 +5,7 @@ set -e
5 5
 	export IAMSTATIC='false'
6 6
 	export LDFLAGS_STATIC_DOCKER=''
7 7
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/netgo /}" ) # disable netgo, since we don't need it for a dynamic binary
8
+	export BUILDFLAGS=( "${BUILDFLAGS[@]/osusergo /}" ) # ditto for osusergo
8 9
 	export BUILDFLAGS=( "${BUILDFLAGS[@]/static_build /}" ) # we're not building a "static" binary here
9 10
 	source "${MAKEDIR}/.binary"
10 11
 )