Browse code

Make "DEST" a make.sh construct instead of ad-hoc

Using "DEST" for our build artifacts inside individual bundlescripts was already well-established convention, but this officializes it by having `make.sh` itself set the variable and create the directory, also handling CYGWIN oddities in a single central place (instead of letting them spread outward from `hack/make/binary` like was definitely on their roadmap, whether they knew it or not; sneaky oddities).

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>

Tianon Gravi authored on 2015/05/30 05:07:16
Showing 15 changed files
... ...
@@ -198,13 +198,13 @@ go_test_dir() {
198 198
 		# if our current go install has -cover, we want to use it :)
199 199
 		mkdir -p "$DEST/coverprofiles"
200 200
 		coverprofile="docker${dir#.}"
201
-		coverprofile="$DEST/coverprofiles/${coverprofile//\//-}"
201
+		coverprofile="$ABS_DEST/coverprofiles/${coverprofile//\//-}"
202 202
 		testcover=( -cover -coverprofile "$coverprofile" $coverpkg )
203 203
 	fi
204 204
 	(
205
-		export DEST
206 205
 		echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
207 206
 		cd "$dir"
207
+		export DEST="$ABS_DEST" # we're in a subshell, so this is safe -- our integration-cli tests need DEST, and "cd" screws it up
208 208
 		test_env go test ${testcover[@]} -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS
209 209
 	)
210 210
 }
... ...
@@ -217,7 +217,7 @@ test_env() {
217 217
 		DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \
218 218
 		DOCKER_HOST="$DOCKER_HOST" \
219 219
 		GOPATH="$GOPATH" \
220
-		HOME="$DEST/fake-HOME" \
220
+		HOME="$ABS_DEST/fake-HOME" \
221 221
 		PATH="$PATH" \
222 222
 		TEMP="$TEMP" \
223 223
 		TEST_DOCKERINIT_PATH="$TEST_DOCKERINIT_PATH" \
... ...
@@ -272,11 +272,9 @@ hash_files() {
272 272
 }
273 273
 
274 274
 bundle() {
275
-	bundlescript=$1
276
-	bundle=$(basename $bundlescript)
277
-	echo "---> Making bundle: $bundle (in bundles/$VERSION/$bundle)"
278
-	mkdir -p "bundles/$VERSION/$bundle"
279
-	source "$bundlescript" "$(pwd)/bundles/$VERSION/$bundle"
275
+	local bundle="$1"; shift
276
+	echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
277
+	source "$SCRIPTDIR/make/$bundle" "$@"
280 278
 }
281 279
 
282 280
 main() {
... ...
@@ -302,7 +300,14 @@ main() {
302 302
 		bundles=($@)
303 303
 	fi
304 304
 	for bundle in ${bundles[@]}; do
305
-		bundle "$SCRIPTDIR/make/$bundle"
305
+		export DEST="bundles/$VERSION/$(basename "$bundle")"
306
+		# Cygdrive paths don't play well with go build -o.
307
+		if [[ "$(uname -s)" == CYGWIN* ]]; then
308
+			export DEST="$(cygpath -mw "$DEST")"
309
+		fi
310
+		mkdir -p "$DEST"
311
+		ABS_DEST="$(cd "$DEST" && pwd -P)"
312
+		bundle "$bundle"
306 313
 		echo
307 314
 	done
308 315
 }
... ...
@@ -2,7 +2,7 @@
2 2
 
3 3
 # see test-integration-cli for example usage of this script
4 4
 
5
-export PATH="$DEST/../binary:$DEST/../dynbinary:$DEST/../gccgo:$DEST/../dyngccgo:$PATH"
5
+export PATH="$ABS_DEST/../binary:$ABS_DEST/../dynbinary:$ABS_DEST/../gccgo:$ABS_DEST/../dyngccgo:$PATH"
6 6
 
7 7
 if ! command -v docker &> /dev/null; then
8 8
 	echo >&2 'error: binary or dynbinary must be run before .integration-daemon-start'
... ...
@@ -1,16 +1,10 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5 4
 BINARY_NAME="docker-$VERSION"
6 5
 BINARY_EXTENSION="$(binary_extension)"
7 6
 BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
8 7
 
9
-# Cygdrive paths don't play well with go build -o.
10
-if [[ "$(uname -s)" == CYGWIN* ]]; then
11
-	DEST=$(cygpath -mw $DEST)
12
-fi
13
-
14 8
 source "${MAKEDIR}/.go-autogen"
15 9
 
16 10
 echo "Building: $DEST/$BINARY_FULLNAME"
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 # subshell so that we can export PATH without breaking other things
7 5
 (
8 6
 	source "${MAKEDIR}/.integration-daemon-start"
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 # subshell so that we can export PATH without breaking other things
7 5
 (
8 6
 	source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST="$1"
5
-
6 4
 bundle_cover() {
7 5
 	coverprofiles=( "$DEST/../"*"/coverprofiles/"* )
8 6
 	for p in "${coverprofiles[@]}"; do
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 # explicit list of os/arch combos that support being a daemon
7 5
 declare -A daemonSupporting
8 6
 daemonSupporting=(
... ...
@@ -21,13 +19,15 @@ fi
21 21
 
22 22
 for platform in $DOCKER_CROSSPLATFORMS; do
23 23
 	(
24
-		mkdir -p "$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
24
+		export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
25
+		mkdir -p "$DEST"
26
+		ABS_DEST="$(cd "$DEST" && pwd -P)"
25 27
 		export GOOS=${platform%/*}
26 28
 		export GOARCH=${platform##*/}
27 29
 		if [ -z "${daemonSupporting[$platform]}" ]; then
28 30
 			export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms
29 31
 			export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" ) # remove the "daemon" build tag from platforms that aren't supported
30 32
 		fi
31
-		source "${MAKEDIR}/binary" "$DEST/$platform"
33
+		source "${MAKEDIR}/binary"
32 34
 	)
33 35
 done
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 if [ -z "$DOCKER_CLIENTONLY" ]; then
7 5
 	source "${MAKEDIR}/.dockerinit"
8 6
 
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 if [ -z "$DOCKER_CLIENTONLY" ]; then
7 5
 	source "${MAKEDIR}/.dockerinit-gccgo"
8 6
 
... ...
@@ -1,7 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5 4
 BINARY_NAME="docker-$VERSION"
6 5
 BINARY_EXTENSION="$(binary_extension)"
7 6
 BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 # subshell so that we can export PATH without breaking other things
7 5
 (
8 6
 	source "${MAKEDIR}/.integration-daemon-start"
... ...
@@ -1,8 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5
-
6 4
 bundle_test_integration_cli() {
7 5
 	go_test_dir ./integration-cli
8 6
 }
... ...
@@ -1,7 +1,6 @@
1 1
 #!/bin/bash
2 2
 set -e
3 3
 
4
-DEST=$1
5 4
 : ${PARALLEL_JOBS:=$(nproc 2>/dev/null || echo 1)} # if nproc fails (usually because we don't have it), let's not parallelize by default
6 5
 
7 6
 RED=$'\033[31m'
... ...
@@ -26,10 +25,9 @@ bundle_test_unit() {
26 26
 			export LDFLAGS
27 27
 			export TESTFLAGS
28 28
 			export HAVE_GO_TEST_COVER
29
-			export DEST
30 29
 
31 30
 			# some hack to export array variables
32
-			export BUILDFLAGS_FILE="buildflags_file"
31
+			export BUILDFLAGS_FILE="$DEST/buildflags-file"
33 32
 			( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
34 33
 
35 34
 			if command -v parallel &> /dev/null; then
... ...
@@ -59,7 +57,7 @@ go_run_test_dir() {
59 59
 	while read dir; do
60 60
 		echo
61 61
 		echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
62
-		precompiled="$DEST/precompiled/$dir.test$(binary_extension)"
62
+		precompiled="$ABS_DEST/precompiled/$dir.test$(binary_extension)"
63 63
 		if ! ( cd "$dir" && test_env "$precompiled" $TESTFLAGS ); then
64 64
 			TESTS_FAILED+=("$dir")
65 65
 			echo
... ...
@@ -1,6 +1,5 @@
1 1
 #!/bin/bash
2 2
 
3
-DEST="$1"
4 3
 CROSS="$DEST/../cross"
5 4
 
6 5
 set -e
... ...
@@ -1,7 +1,5 @@
1 1
 #!/bin/bash
2 2
 
3
-DEST=$1
4
-
5 3
 PKGVERSION="${VERSION//-/'~'}"
6 4
 # if we have a "-dev" suffix or have change in Git, let's make this package version more complex so it works better
7 5
 if [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then
... ...
@@ -37,7 +35,7 @@ PACKAGE_LICENSE="Apache-2.0"
37 37
 # Build docker as an ubuntu package using FPM and REPREPRO (sue me).
38 38
 # bundle_binary must be called first.
39 39
 bundle_ubuntu() {
40
-	DIR=$DEST/build
40
+	DIR="$ABS_DEST/build"
41 41
 
42 42
 	# Include our udev rules
43 43
 	mkdir -p "$DIR/etc/udev/rules.d"
... ...
@@ -140,9 +138,9 @@ EOF
140 140
 		# create lxc-docker-VERSION package
141 141
 		fpm -s dir -C "$DIR" \
142 142
 			--name "lxc-docker-$VERSION" --version "$PKGVERSION" \
143
-			--after-install "$DEST/postinst" \
144
-			--before-remove "$DEST/prerm" \
145
-			--after-remove "$DEST/postrm" \
143
+			--after-install "$ABS_DEST/postinst" \
144
+			--before-remove "$ABS_DEST/prerm" \
145
+			--after-remove "$ABS_DEST/postrm" \
146 146
 			--architecture "$PACKAGE_ARCHITECTURE" \
147 147
 			--prefix / \
148 148
 			--depends iptables \