Просмотр исходного кода

Update build tags such that we can properly compile on all platforms (especially for packagers), and updated hack/PACKAGERS.md to mention the DOCKER_BUILDTAGS variable that will need to be set for binaries that might be used on AppArmor (such as Debian and especially Ubuntu)

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
Tianon Gravi 11 лет назад
Родитель
Сommit
0b23393ba1

+ 1 - 0
Dockerfile

@@ -87,6 +87,7 @@ RUN	git config --global user.email 'docker-dummy@example.com'
 
 
 VOLUME	/var/lib/docker
 VOLUME	/var/lib/docker
 WORKDIR	/go/src/github.com/dotcloud/docker
 WORKDIR	/go/src/github.com/dotcloud/docker
+ENV	DOCKER_BUILDTAGS	apparmor
 
 
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 ENTRYPOINT	["hack/dind"]
 ENTRYPOINT	["hack/dind"]

+ 9 - 0
hack/PACKAGERS.md

@@ -148,6 +148,15 @@ This will cause the build scripts to set up a reasonable `GOPATH` that
 automatically and properly includes both dotcloud/docker from the local
 automatically and properly includes both dotcloud/docker from the local
 directory, and the local "./vendor" directory as necessary.
 directory, and the local "./vendor" directory as necessary.
 
 
+### `DOCKER_BUILDTAGS`
+
+If you're building a binary that may need to be used on platforms that include
+AppArmor, you will need to set `DOCKER_BUILDTAGS` as follows:
+
+```bash
+export DOCKER_BUILDTAGS='apparmor'
+```
+
 ### Static Daemon
 ### Static Daemon
 
 
 If it is feasible within the constraints of your distribution, you should
 If it is feasible within the constraints of your distribution, you should

+ 2 - 3
hack/make.sh

@@ -84,8 +84,7 @@ fi
 # Use these flags when compiling the tests and final binary
 # Use these flags when compiling the tests and final binary
 LDFLAGS='-X github.com/dotcloud/docker/dockerversion.GITCOMMIT "'$GITCOMMIT'" -X github.com/dotcloud/docker/dockerversion.VERSION "'$VERSION'" -w'
 LDFLAGS='-X github.com/dotcloud/docker/dockerversion.GITCOMMIT "'$GITCOMMIT'" -X github.com/dotcloud/docker/dockerversion.VERSION "'$VERSION'" -w'
 LDFLAGS_STATIC='-X github.com/dotcloud/docker/dockerversion.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'
 LDFLAGS_STATIC='-X github.com/dotcloud/docker/dockerversion.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'
-BUILDFLAGS='-a'
-BUILDTAGS="apparmor netgo"
+BUILDFLAGS=( -a -tags "netgo $DOCKER_BUILDTAGS" )
 
 
 HAVE_GO_TEST_COVER=
 HAVE_GO_TEST_COVER=
 if \
 if \
@@ -114,7 +113,7 @@ go_test_dir() {
 	(
 	(
 		set -x
 		set -x
 		cd "$dir"
 		cd "$dir"
-		go test ${testcover[@]} -ldflags "$LDFLAGS" $BUILDFLAGS $TESTFLAGS
+		go test ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS
 	)
 	)
 }
 }
 
 

+ 1 - 1
hack/make/binary

@@ -2,5 +2,5 @@
 
 
 DEST=$1
 DEST=$1
 
 
-go build -o $DEST/docker-$VERSION -ldflags "$LDFLAGS $LDFLAGS_STATIC" $BUILDFLAGS -tags "$BUILDTAGS" ./docker
+go build -o $DEST/docker-$VERSION -ldflags "$LDFLAGS $LDFLAGS_STATIC" "${BUILDFLAGS[@]}" ./docker
 echo "Created binary: $DEST/docker-$VERSION"
 echo "Created binary: $DEST/docker-$VERSION"

+ 0 - 1
hack/make/cross

@@ -18,7 +18,6 @@ for platform in $DOCKER_CROSSPLATFORMS; do
 		export GOOS=${platform%/*}
 		export GOOS=${platform%/*}
 		export GOARCH=${platform##*/}
 		export GOARCH=${platform##*/}
 		export LDFLAGS_STATIC="" # we just need a simple client for these platforms (TODO this might change someday)
 		export LDFLAGS_STATIC="" # we just need a simple client for these platforms (TODO this might change someday)
-		export BUILDTAGS="netgo"
 		source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
 		source "$(dirname "$BASH_SOURCE")/binary" "$DEST/$platform"
 	)
 	)
 done
 done

+ 1 - 1
hack/make/dynbinary

@@ -3,7 +3,7 @@
 DEST=$1
 DEST=$1
 
 
 # dockerinit still needs to be a static binary, even if docker is dynamic
 # dockerinit still needs to be a static binary, even if docker is dynamic
-CGO_ENABLED=0 go build -o $DEST/dockerinit-$VERSION -ldflags "$LDFLAGS -d" $BUILDFLAGS ./dockerinit
+CGO_ENABLED=0 go build -o $DEST/dockerinit-$VERSION -ldflags "$LDFLAGS -d" "${BUILDFLAGS[@]}" ./dockerinit
 echo "Created binary: $DEST/dockerinit-$VERSION"
 echo "Created binary: $DEST/dockerinit-$VERSION"
 ln -sf dockerinit-$VERSION $DEST/dockerinit
 ln -sf dockerinit-$VERSION $DEST/dockerinit
 
 

+ 1 - 1
pkg/libcontainer/apparmor/apparmor.go

@@ -1,4 +1,4 @@
-// +build apparmor
+// +build apparmor,linux,amd64
 
 
 package apparmor
 package apparmor
 
 

+ 1 - 1
pkg/libcontainer/apparmor/apparmor_disabled.go

@@ -1,4 +1,4 @@
-// +build !apparmor
+// +build !apparmor !linux !amd64
 
 
 package apparmor
 package apparmor