1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix a few minor issues with building/running inside msysGit

Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
This commit is contained in:
Tianon Gravi 2015-01-09 17:28:40 -07:00
parent 8ba4484084
commit d43f0b9fc5
10 changed files with 53 additions and 57 deletions

View file

@ -4,7 +4,6 @@ import (
"fmt" "fmt"
"os" "os"
"os/exec" "os/exec"
"runtime"
) )
var ( var (
@ -26,29 +25,16 @@ var (
workingDirectory string workingDirectory string
) )
func binarySearchCommand() *exec.Cmd {
if runtime.GOOS == "windows" {
// Windows where.exe is included since Windows Server 2003. It accepts
// wildcards, which we use here to match the development builds binary
// names (such as docker-$VERSION.exe).
return exec.Command("where.exe", "docker*.exe")
}
return exec.Command("which", "docker")
}
func init() { func init() {
if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" { if dockerBin := os.Getenv("DOCKER_BINARY"); dockerBin != "" {
dockerBinary = dockerBin dockerBinary = dockerBin
} else { }
whichCmd := binarySearchCommand() var err error
out, _, err := runCommandWithOutput(whichCmd) dockerBinary, err = exec.LookPath(dockerBinary)
if err == nil { if err != nil {
dockerBinary = stripTrailingCharacters(out)
} else {
fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err) fmt.Printf("ERROR: couldn't resolve full path to the Docker binary (%v)", err)
os.Exit(1) os.Exit(1)
} }
}
if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" { if registryImage := os.Getenv("REGISTRY_IMAGE"); registryImage != "" {
registryImageName = registryImage registryImageName = registryImage
} }

View file

@ -178,21 +178,28 @@ go_test_dir() {
) )
} }
# a helper to provide ".exe" when it's appropriate
binary_extension() {
if [ "$(go env GOOS)" = 'windows' ]; then
echo -n '.exe'
fi
}
# This helper function walks the current directory looking for directories # This helper function walks the current directory looking for directories
# holding certain files ($1 parameter), and prints their paths on standard # holding certain files ($1 parameter), and prints their paths on standard
# output, one per line. # output, one per line.
find_dirs() { find_dirs() {
find . -not \( \ find . -not \( \
\( \ \( \
-wholename './vendor' \ -path './vendor/*' \
-o -wholename './integration' \ -o -path './integration/*' \
-o -wholename './integration-cli' \ -o -path './integration-cli/*' \
-o -wholename './contrib' \ -o -path './contrib/*' \
-o -wholename './pkg/mflag/example' \ -o -path './pkg/mflag/example/*' \
-o -wholename './.git' \ -o -path './.git/*' \
-o -wholename './bundles' \ -o -path './bundles/*' \
-o -wholename './docs' \ -o -path './docs/*' \
-o -wholename './pkg/libcontainer/nsinit' \ -o -path './pkg/libcontainer/nsinit/*' \
\) \ \) \
-prune \ -prune \
\) -name "$1" -print0 | xargs -0n1 dirname | sort -u \) -name "$1" -print0 | xargs -0n1 dirname | sort -u

View file

@ -4,7 +4,13 @@ set -e
# Compile phase run by parallel in test-unit. No support for coverpkg # Compile phase run by parallel in test-unit. No support for coverpkg
dir=$1 dir=$1
in_file="$dir/$(basename "$dir").test"
out_file="$DEST/precompiled/$dir.test" out_file="$DEST/precompiled/$dir.test"
# we want to use binary_extension() here, but we can't because it's in main.sh and this file gets re-execed
if [ "$(go env GOOS)" = 'windows' ]; then
in_file+='.exe'
out_file+='.exe'
fi
testcover=() testcover=()
if [ "$HAVE_GO_TEST_COVER" ]; then if [ "$HAVE_GO_TEST_COVER" ]; then
# if our current go install has -cover, we want to use it :) # if our current go install has -cover, we want to use it :)
@ -16,11 +22,14 @@ fi
if [ "$BUILDFLAGS_FILE" ]; then if [ "$BUILDFLAGS_FILE" ]; then
readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE" readarray -t BUILDFLAGS < "$BUILDFLAGS_FILE"
fi fi
(
if ! (
cd "$dir" cd "$dir"
go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c go test "${testcover[@]}" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS -c
) ); then
[ $? -ne 0 ] && return 1 exit 1
fi
mkdir -p "$(dirname "$out_file")" mkdir -p "$(dirname "$out_file")"
mv "$dir/$(basename "$dir").test" "$out_file" mv "$in_file" "$out_file"
echo "Precompiled: ${DOCKER_PKG}${dir#.}" echo "Precompiled: ${DOCKER_PKG}${dir#.}"

View file

@ -1,7 +1,9 @@
#!/bin/bash #!/bin/bash
for pid in $(find "$DEST" -name docker.pid); do for pidFile in $(find "$DEST" -name docker.pid); do
DOCKER_PID=$(set -x; cat "$pid") pid=$(set -x; cat "$pidFile")
( set -x; kill $DOCKER_PID ) ( set -x; kill $pid )
wait $DOCKERD_PID || true if ! wait $pid; then
echo >&2 "warning: PID $pid from $pidFile had a nonzero exit code"
fi
done done

View file

@ -3,10 +3,7 @@ set -e
DEST=$1 DEST=$1
BINARY_NAME="docker-$VERSION" BINARY_NAME="docker-$VERSION"
BINARY_EXTENSION= BINARY_EXTENSION="$(binary_extension)"
if [ "$(go env GOOS)" = 'windows' ]; then
BINARY_EXTENSION='.exe'
fi
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
# Cygdrive paths don't play well with go build -o. # Cygdrive paths don't play well with go build -o.

View file

@ -4,7 +4,6 @@ set -e
DEST=$1 DEST=$1
# subshell so that we can export PATH without breaking other things # subshell so that we can export PATH without breaking other things
exec > >(tee -a $DEST/test.log) 2>&1
( (
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
@ -19,4 +18,4 @@ exec > >(tee -a $DEST/test.log) 2>&1
python tests/integration_test.py python tests/integration_test.py
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
) ) 2>&1 | tee -a $DEST/test.log

View file

@ -10,6 +10,6 @@ bundle_test_integration() {
# this "grep" hides some really irritating warnings that "go test -coverpkg" # this "grep" hides some really irritating warnings that "go test -coverpkg"
# spews when it is given packages that aren't used # spews when it is given packages that aren't used
exec > >(tee -a $DEST/test.log) 2>&1
bundle_test_integration 2>&1 \ bundle_test_integration 2>&1 \
| grep --line-buffered -v '^warning: no packages being tested depend on ' | grep --line-buffered -v '^warning: no packages being tested depend on ' \
| tee -a $DEST/test.log

View file

@ -8,7 +8,6 @@ bundle_test_integration_cli() {
} }
# subshell so that we can export PATH without breaking other things # subshell so that we can export PATH without breaking other things
exec > >(tee -a $DEST/test.log) 2>&1
( (
source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" source "$(dirname "$BASH_SOURCE")/.integration-daemon-start"
@ -20,4 +19,4 @@ exec > >(tee -a $DEST/test.log) 2>&1
bundle_test_integration_cli bundle_test_integration_cli
source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop"
) ) 2>&1 | tee -a $DEST/test.log

View file

@ -2,7 +2,7 @@
set -e set -e
DEST=$1 DEST=$1
: ${PARALLEL_JOBS:=$(nproc)} : ${PARALLEL_JOBS:=$(nproc 2>/dev/null || echo 1)} # if nproc fails (usually because we don't have it), let's not parallelize by default
RED=$'\033[31m' RED=$'\033[31m'
GREEN=$'\033[32m' GREEN=$'\033[32m'
@ -38,12 +38,13 @@ bundle_test_unit() {
export BUILDFLAGS_FILE="$HOME/buildflags_file" export BUILDFLAGS_FILE="$HOME/buildflags_file"
( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE" ( IFS=$'\n'; echo "${BUILDFLAGS[*]}" ) > "$BUILDFLAGS_FILE"
echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --halt 2 --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" echo "$TESTDIRS" | parallel --jobs "$PARALLEL_JOBS" --env _ "$(dirname "$BASH_SOURCE")/.go-compile-test-dir"
rm -rf "$HOME" rm -rf "$HOME"
else else
# aww, no "parallel" available - fall back to boring # aww, no "parallel" available - fall back to boring
for test_dir in $TESTDIRS; do for test_dir in $TESTDIRS; do
"$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" "$(dirname "$BASH_SOURCE")/.go-compile-test-dir" "$test_dir" || true
# don't let one directory that fails to build tank _all_ our tests!
done done
fi fi
) )
@ -56,7 +57,7 @@ go_run_test_dir() {
while read dir; do while read dir; do
echo echo
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
precompiled="$DEST/precompiled/$dir.test" precompiled="$DEST/precompiled/$dir.test$(binary_extension)"
if ! ( cd "$dir" && "$precompiled" $TESTFLAGS ); then if ! ( cd "$dir" && "$precompiled" $TESTFLAGS ); then
TESTS_FAILED+=("$dir") TESTS_FAILED+=("$dir")
echo echo
@ -82,5 +83,4 @@ go_run_test_dir() {
fi fi
} }
exec > >(tee -a $DEST/test.log) 2>&1 bundle_test_unit 2>&1 | tee -a $DEST/test.log
bundle_test_unit

View file

@ -14,10 +14,7 @@ for d in "$CROSS/"*/*; do
GOARCH="$(basename "$d")" GOARCH="$(basename "$d")"
GOOS="$(basename "$(dirname "$d")")" GOOS="$(basename "$(dirname "$d")")"
BINARY_NAME="docker-$VERSION" BINARY_NAME="docker-$VERSION"
BINARY_EXTENSION= BINARY_EXTENSION="$(binary_extension)"
if [ "$GOOS" = 'windows' ]; then
BINARY_EXTENSION='.exe'
fi
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
mkdir -p "$DEST/$GOOS/$GOARCH" mkdir -p "$DEST/$GOOS/$GOARCH"
TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME.tgz" TGZ="$DEST/$GOOS/$GOARCH/$BINARY_NAME.tgz"