Bash scripts; use double brackets, fix bare variables, add quotes
These scripts explicitly use Bash, so we should be able to use `[[` instead of `[` (which seems to be recommended). Also added curly brackets to some bare variables, and quoted some paths. This makes my IDE a bit more silent :-) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d147fe0582
commit
297b30df5f
|
@ -13,7 +13,7 @@ set -e
|
||||||
# apparmor sucks and Docker needs to know that it's in a container (c) @tianon
|
# apparmor sucks and Docker needs to know that it's in a container (c) @tianon
|
||||||
export container=docker
|
export container=docker
|
||||||
|
|
||||||
if [ -d /sys/kernel/security ] && ! mountpoint -q /sys/kernel/security; then
|
if [[ -d /sys/kernel/security ]] && ! mountpoint -q /sys/kernel/security; then
|
||||||
mount -t securityfs none /sys/kernel/security || {
|
mount -t securityfs none /sys/kernel/security || {
|
||||||
echo >&2 'Could not mount /sys/kernel/security.'
|
echo >&2 'Could not mount /sys/kernel/security.'
|
||||||
echo >&2 'AppArmor detection and --privileged mode might break.'
|
echo >&2 'AppArmor detection and --privileged mode might break.'
|
||||||
|
@ -25,7 +25,7 @@ if ! mountpoint -q /tmp; then
|
||||||
mount -t tmpfs none /tmp
|
mount -t tmpfs none /tmp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [[ $# -gt 0 ]]; then
|
||||||
exec "$@"
|
exec "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ install_containerd() {
|
||||||
make
|
make
|
||||||
)
|
)
|
||||||
|
|
||||||
mkdir -p ${PREFIX}
|
mkdir -p "${PREFIX}"
|
||||||
|
|
||||||
cp bin/containerd ${PREFIX}/containerd
|
cp bin/containerd "${PREFIX}/containerd"
|
||||||
cp bin/containerd-shim ${PREFIX}/containerd-shim
|
cp bin/containerd-shim "${PREFIX}/containerd-shim"
|
||||||
cp bin/ctr ${PREFIX}/ctr
|
cp bin/ctr "${PREFIX}/ctr"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,13 @@ install_dockercli() {
|
||||||
|
|
||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
# No official release of these platforms
|
# No official release of these platforms
|
||||||
if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then
|
if [ "$arch" != "x86_64" ] && [ "$arch" != "s390x" ]; then
|
||||||
build_dockercli
|
build_dockercli
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
url=https://download.docker.com/linux/static
|
url=https://download.docker.com/linux/static
|
||||||
curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \
|
curl -Ls "${url}/${DOCKERCLI_CHANNEL}/${arch}/docker-${DOCKERCLI_VERSION}.tgz" | tar -xz docker/docker
|
||||||
tar -xz docker/docker
|
|
||||||
mkdir -p ${PREFIX}
|
mkdir -p ${PREFIX}
|
||||||
mv docker/docker ${PREFIX}/
|
mv docker/docker ${PREFIX}/
|
||||||
rmdir docker
|
rmdir docker
|
||||||
|
@ -27,5 +26,5 @@ build_dockercli() {
|
||||||
git checkout -q "v$DOCKERCLI_VERSION"
|
git checkout -q "v$DOCKERCLI_VERSION"
|
||||||
mkdir -p "$GOPATH/src/github.com/docker"
|
mkdir -p "$GOPATH/src/github.com/docker"
|
||||||
mv components/cli "$GOPATH/src/github.com/docker/cli"
|
mv components/cli "$GOPATH/src/github.com/docker/cli"
|
||||||
go build -buildmode=pie -o ${PREFIX}/docker github.com/docker/cli/cmd/docker
|
go build -buildmode=pie -o "${PREFIX}/docker" "github.com/docker/cli/cmd/docker"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,6 @@ install_gometalinter() {
|
||||||
go get -d github.com/alecthomas/gometalinter
|
go get -d github.com/alecthomas/gometalinter
|
||||||
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
|
cd "$GOPATH/src/github.com/alecthomas/gometalinter"
|
||||||
git checkout -q "$GOMETALINTER_COMMIT"
|
git checkout -q "$GOMETALINTER_COMMIT"
|
||||||
go build -buildmode=pie -o ${PREFIX}/gometalinter github.com/alecthomas/gometalinter
|
go build -buildmode=pie -o "${PREFIX}/gometalinter" "github.com/alecthomas/gometalinter"
|
||||||
GOBIN=${PREFIX} ${PREFIX}/gometalinter --install
|
GOBIN=${PREFIX} "${PREFIX}/gometalinter" --install
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ TMP_GOPATH=${TMP_GOPATH:-""}
|
||||||
|
|
||||||
: ${PREFIX:="/usr/local/bin"}
|
: ${PREFIX:="/usr/local/bin"}
|
||||||
|
|
||||||
if [ -z "$TMP_GOPATH" ]; then
|
if [[ -z "$TMP_GOPATH" ]]; then
|
||||||
export GOPATH="$(mktemp -d)"
|
export GOPATH="$(mktemp -d)"
|
||||||
RM_GOPATH=1
|
RM_GOPATH=1
|
||||||
else
|
else
|
||||||
|
@ -21,10 +21,10 @@ dir="$(dirname $0)"
|
||||||
bin=$1
|
bin=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
if [ ! -f "${dir}/${bin}.installer" ]; then
|
if [[ ! -f "${dir}/${bin}.installer" ]]; then
|
||||||
echo "Could not find installer for \"$bin\""
|
echo "Could not find installer for \"$bin\""
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. $dir/$bin.installer
|
. ${dir}/${bin}.installer
|
||||||
install_$bin "$@"
|
install_${bin} "$@"
|
||||||
|
|
|
@ -32,7 +32,7 @@ _install_proxy() {
|
||||||
git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
|
git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork"
|
||||||
cd "$GOPATH/src/github.com/docker/libnetwork"
|
cd "$GOPATH/src/github.com/docker/libnetwork"
|
||||||
git checkout -q "$LIBNETWORK_COMMIT"
|
git checkout -q "$LIBNETWORK_COMMIT"
|
||||||
go build $BUILD_MODE -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
|
go build ${BUILD_MODE} -ldflags="$PROXY_LDFLAGS" -o ${PREFIX}/docker-proxy github.com/docker/libnetwork/cmd/proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,6 @@ install_runc() {
|
||||||
target="$1"
|
target="$1"
|
||||||
fi
|
fi
|
||||||
make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
|
make BUILDTAGS="$RUNC_BUILDTAGS" "$target"
|
||||||
mkdir -p ${PREFIX}
|
mkdir -p "${PREFIX}"
|
||||||
cp runc ${PREFIX}/runc
|
cp runc "${PREFIX}/runc"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@ install_tini() {
|
||||||
git checkout -q "$TINI_COMMIT"
|
git checkout -q "$TINI_COMMIT"
|
||||||
cmake .
|
cmake .
|
||||||
make tini-static
|
make tini-static
|
||||||
mkdir -p ${PREFIX}
|
mkdir -p "${PREFIX}"
|
||||||
cp tini-static ${PREFIX}/docker-init
|
cp tini-static "${PREFIX}/docker-init"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,5 +8,5 @@ install_tomlv() {
|
||||||
echo "Install tomlv version $TOMLV_COMMIT"
|
echo "Install tomlv version $TOMLV_COMMIT"
|
||||||
git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
|
git clone https://github.com/BurntSushi/toml.git "$GOPATH/src/github.com/BurntSushi/toml"
|
||||||
cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
|
cd "$GOPATH/src/github.com/BurntSushi/toml" && git checkout -q "$TOMLV_COMMIT"
|
||||||
go build -v -buildmode=pie -o ${PREFIX}/tomlv github.com/BurntSushi/toml/cmd/tomlv
|
go build -v -buildmode=pie -o "${PREFIX}/tomlv" "github.com/BurntSushi/toml/cmd/tomlv"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,5 @@ install_vndr() {
|
||||||
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
|
git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr"
|
||||||
cd "$GOPATH/src/github.com/LK4D4/vndr"
|
cd "$GOPATH/src/github.com/LK4D4/vndr"
|
||||||
git checkout -q "$VNDR_COMMIT"
|
git checkout -q "$VNDR_COMMIT"
|
||||||
go build -buildmode=pie -v -o ${PREFIX}/vndr .
|
go build -buildmode=pie -v -o "${PREFIX}/vndr" .
|
||||||
}
|
}
|
||||||
|
|
32
hack/make.sh
32
hack/make.sh
|
@ -31,17 +31,17 @@ export PKG_CONFIG=${PKG_CONFIG:-pkg-config}
|
||||||
# We're a nice, sexy, little shell script, and people might try to run us;
|
# We're a nice, sexy, little shell script, and people might try to run us;
|
||||||
# but really, they shouldn't. We want to be in a container!
|
# but really, they shouldn't. We want to be in a container!
|
||||||
inContainer="AssumeSoInitially"
|
inContainer="AssumeSoInitially"
|
||||||
if [ "$(go env GOHOSTOS)" = 'windows' ]; then
|
if [[ "$(go env GOHOSTOS)" = 'windows' ]]; then
|
||||||
if [ -z "$FROM_DOCKERFILE" ]; then
|
if [[ -z "$FROM_DOCKERFILE" ]]; then
|
||||||
unset inContainer
|
unset inContainer
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$PWD" != "/go/src/$DOCKER_PKG" ]; then
|
if [[ "$PWD" != "/go/src/$DOCKER_PKG" ]]; then
|
||||||
unset inContainer
|
unset inContainer
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$inContainer" ]; then
|
if [[ -z "$inContainer" ]]; then
|
||||||
{
|
{
|
||||||
echo "# WARNING! I don't seem to be running in a Docker container."
|
echo "# WARNING! I don't seem to be running in a Docker container."
|
||||||
echo "# The result of this command might be an incorrect build, and will not be"
|
echo "# The result of this command might be an incorrect build, and will not be"
|
||||||
|
@ -67,11 +67,11 @@ DEFAULT_BUNDLES=(
|
||||||
|
|
||||||
VERSION=${VERSION:-dev}
|
VERSION=${VERSION:-dev}
|
||||||
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
|
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
|
||||||
if [ "$DOCKER_GITCOMMIT" ]; then
|
if [[ "$DOCKER_GITCOMMIT" ]]; then
|
||||||
GITCOMMIT="$DOCKER_GITCOMMIT"
|
GITCOMMIT="$DOCKER_GITCOMMIT"
|
||||||
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then
|
||||||
GITCOMMIT=$(git rev-parse --short HEAD)
|
GITCOMMIT=$(git rev-parse --short HEAD)
|
||||||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
|
||||||
GITCOMMIT="$GITCOMMIT-unsupported"
|
GITCOMMIT="$GITCOMMIT-unsupported"
|
||||||
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
echo "# GITCOMMIT = $GITCOMMIT"
|
echo "# GITCOMMIT = $GITCOMMIT"
|
||||||
|
@ -90,14 +90,14 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$AUTO_GOPATH" ]; then
|
if [[ "$AUTO_GOPATH" ]]; then
|
||||||
rm -rf .gopath
|
rm -rf .gopath
|
||||||
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")"
|
||||||
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}"
|
||||||
export GOPATH="${PWD}/.gopath"
|
export GOPATH="${PWD}/.gopath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "$GOPATH" ]; then
|
if [[ ! "$GOPATH" ]]; then
|
||||||
echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH'
|
echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH'
|
||||||
echo >&2 ' alternatively, set AUTO_GOPATH=1'
|
echo >&2 ' alternatively, set AUTO_GOPATH=1'
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -137,7 +137,7 @@ fi
|
||||||
# Use these flags when compiling the tests and final binary
|
# Use these flags when compiling the tests and final binary
|
||||||
|
|
||||||
IAMSTATIC='true'
|
IAMSTATIC='true'
|
||||||
if [ -z "$DOCKER_DEBUG" ]; then
|
if [[ -z "$DOCKER_DEBUG" ]]; then
|
||||||
LDFLAGS='-w'
|
LDFLAGS='-w'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -148,12 +148,12 @@ EXTLDFLAGS_STATIC='-static'
|
||||||
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
|
ORIG_BUILDFLAGS=( -tags "autogen netgo osusergo static_build $DOCKER_BUILDTAGS" -installsuffix netgo )
|
||||||
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
# see https://github.com/golang/go/issues/9369#issuecomment-69864440 for why -installsuffix is necessary here
|
||||||
|
|
||||||
BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" )
|
BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" )
|
||||||
|
|
||||||
# Test timeout.
|
# Test timeout.
|
||||||
if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then
|
if [[ "${DOCKER_ENGINE_GOARCH}" == "arm64" ]] || [[ "${DOCKER_ENGINE_GOARCH}" == "arm" ]]; then
|
||||||
: ${TIMEOUT:=10m}
|
: ${TIMEOUT:=10m}
|
||||||
elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then
|
elif [[ "${DOCKER_ENGINE_GOARCH}" == "windows" ]]; then
|
||||||
: ${TIMEOUT:=8m}
|
: ${TIMEOUT:=8m}
|
||||||
else
|
else
|
||||||
: ${TIMEOUT:=5m}
|
: ${TIMEOUT:=5m}
|
||||||
|
@ -164,7 +164,7 @@ LDFLAGS_STATIC_DOCKER="
|
||||||
-extldflags \"$EXTLDFLAGS_STATIC\"
|
-extldflags \"$EXTLDFLAGS_STATIC\"
|
||||||
"
|
"
|
||||||
|
|
||||||
if [ "$(uname -s)" = 'FreeBSD' ]; then
|
if [[ "$(uname -s)" = 'FreeBSD' ]]; then
|
||||||
# Tell cgo the compiler is Clang, not GCC
|
# Tell cgo the compiler is Clang, not GCC
|
||||||
# https://code.google.com/p/go/source/browse/src/cmd/cgo/gcc.go?spec=svne77e74371f2340ee08622ce602e9f7b15f29d8d3&r=e6794866ebeba2bf8818b9261b54e2eef1c9e588#752
|
# https://code.google.com/p/go/source/browse/src/cmd/cgo/gcc.go?spec=svne77e74371f2340ee08622ce602e9f7b15f29d8d3&r=e6794866ebeba2bf8818b9261b54e2eef1c9e588#752
|
||||||
export CC=clang
|
export CC=clang
|
||||||
|
@ -181,7 +181,7 @@ bundle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if [ -z "${KEEPBUNDLE-}" ]; then
|
if [[ -z "${KEEPBUNDLE-}" ]]; then
|
||||||
echo "Removing bundles/"
|
echo "Removing bundles/"
|
||||||
rm -rf "bundles/*"
|
rm -rf "bundles/*"
|
||||||
echo
|
echo
|
||||||
|
@ -189,13 +189,13 @@ main() {
|
||||||
mkdir -p bundles
|
mkdir -p bundles
|
||||||
|
|
||||||
# Windows and symlinks don't get along well
|
# Windows and symlinks don't get along well
|
||||||
if [ "$(go env GOHOSTOS)" != 'windows' ]; then
|
if [[ "$(go env GOHOSTOS)" != 'windows' ]]; then
|
||||||
rm -f bundles/latest
|
rm -f bundles/latest
|
||||||
# preserve latest symlink for backward compatibility
|
# preserve latest symlink for backward compatibility
|
||||||
ln -sf . bundles/latest
|
ln -sf . bundles/latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [[ $# -lt 1 ]]; then
|
||||||
bundles=(${DEFAULT_BUNDLES[@]})
|
bundles=(${DEFAULT_BUNDLES[@]})
|
||||||
else
|
else
|
||||||
bundles=($@)
|
bundles=($@)
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
|
|
||||||
# a helper to provide ".exe" when it's appropriate
|
# a helper to provide ".exe" when it's appropriate
|
||||||
binary_extension() {
|
binary_extension() {
|
||||||
if [ "$(go env GOOS)" = 'windows' ]; then
|
if [[ "$(go env GOOS)" = 'windows' ]]; then
|
||||||
echo -n '.exe'
|
echo -n '.exe'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
||||||
source "${MAKEDIR}/.go-autogen"
|
source "${MAKEDIR}/.go-autogen"
|
||||||
|
|
||||||
hash_files() {
|
hash_files() {
|
||||||
while [ $# -gt 0 ]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
f="$1"
|
f="$1"
|
||||||
shift
|
shift
|
||||||
dir="$(dirname "$f")"
|
dir="$(dirname "$f")"
|
||||||
|
@ -40,7 +40,7 @@ hash_files() {
|
||||||
(
|
(
|
||||||
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
||||||
|
|
||||||
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
if [[ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]]; then
|
||||||
# must be cross-compiling!
|
# must be cross-compiling!
|
||||||
case "$(go env GOOS)/$(go env GOARCH)" in
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
||||||
windows/amd64)
|
windows/amd64)
|
||||||
|
@ -68,7 +68,7 @@ go build \
|
||||||
$LDFLAGS_STATIC_DOCKER
|
$LDFLAGS_STATIC_DOCKER
|
||||||
$DOCKER_LDFLAGS
|
$DOCKER_LDFLAGS
|
||||||
" \
|
" \
|
||||||
$GO_PACKAGE
|
${GO_PACKAGE}
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|
||||||
|
|
|
@ -36,7 +36,7 @@ DOCKER_CLIENT_GOARCH=${DOCKER_CLIENT_GOARCH:=amd64}
|
||||||
|
|
||||||
DOCKERFILE='Dockerfile'
|
DOCKERFILE='Dockerfile'
|
||||||
|
|
||||||
if [ "${DOCKER_ENGINE_GOOS:-$DOCKER_CLIENT_GOOS}" = "windows" ]; then
|
if [[ "${DOCKER_ENGINE_GOOS:-$DOCKER_CLIENT_GOOS}" = "windows" ]]; then
|
||||||
DOCKERFILE='Dockerfile.windows'
|
DOCKERFILE='Dockerfile.windows'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ if ! docker image inspect emptyfs > /dev/null; then
|
||||||
tar -cf layer.tar --files-from /dev/null
|
tar -cf layer.tar --files-from /dev/null
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
tar -cC "$dir" . | docker load
|
tar -cC "$dir" . | docker load
|
||||||
)
|
)
|
||||||
rm -rf "$dir"
|
rm -rf "$dir"
|
||||||
|
|
|
@ -43,7 +43,7 @@ const (
|
||||||
DVEOF
|
DVEOF
|
||||||
|
|
||||||
# Compile the Windows resources into the sources
|
# Compile the Windows resources into the sources
|
||||||
if [ "$(go env GOOS)" = "windows" ]; then
|
if [[ "$(go env GOOS)" = "windows" ]]; then
|
||||||
mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd
|
mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd
|
||||||
cp hack/make/.resources-windows/resources.go autogen/winresources/docker/
|
cp hack/make/.resources-windows/resources.go autogen/winresources/docker/
|
||||||
cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
|
cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
|
||||||
|
@ -62,12 +62,12 @@ if [ "$(go env GOOS)" = "windows" ]; then
|
||||||
|
|
||||||
# Pass version and commit information into the resource compiler
|
# Pass version and commit information into the resource compiler
|
||||||
defs=
|
defs=
|
||||||
[ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
|
[[ ! -z $VERSION ]] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
|
||||||
[ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
|
[[ ! -z $VERSION_QUAD ]] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
|
||||||
[ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
|
[[ ! -z $GITCOMMIT ]] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
|
||||||
|
|
||||||
function makeres {
|
function makeres {
|
||||||
$WINDRES \
|
${WINDRES} \
|
||||||
-i hack/make/.resources-windows/$1 \
|
-i hack/make/.resources-windows/$1 \
|
||||||
-o $3 \
|
-o $3 \
|
||||||
-F $2 \
|
-F $2 \
|
||||||
|
@ -76,7 +76,7 @@ if [ "$(go env GOOS)" = "windows" ]; then
|
||||||
$defs
|
$defs
|
||||||
}
|
}
|
||||||
|
|
||||||
$WINDMC \
|
${WINDMC} \
|
||||||
hack/make/.resources-windows/event_messages.mc \
|
hack/make/.resources-windows/event_messages.mc \
|
||||||
-h autogen/winresources/tmp \
|
-h autogen/winresources/tmp \
|
||||||
-r autogen/winresources/tmp
|
-r autogen/winresources/tmp
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
source "$MAKEDIR/.detect-daemon-osarch"
|
source "$MAKEDIR/.detect-daemon-osarch"
|
||||||
if [ "$DOCKER_ENGINE_GOOS" != "windows" ]; then
|
if [[ "$DOCKER_ENGINE_GOOS" != "windows" ]]; then
|
||||||
bundle .ensure-emptyfs
|
bundle .ensure-emptyfs
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,7 +7,7 @@ export PATH="$base/binary-daemon:$base/dynbinary-daemon:$PATH"
|
||||||
|
|
||||||
export TEST_CLIENT_BINARY=docker
|
export TEST_CLIENT_BINARY=docker
|
||||||
|
|
||||||
if [ -n "$DOCKER_CLI_PATH" ]; then
|
if [[ -n "$DOCKER_CLI_PATH" ]]; then
|
||||||
export TEST_CLIENT_BINARY=/usr/local/cli/$(basename "$DOCKER_CLI_PATH")
|
export TEST_CLIENT_BINARY=/usr/local/cli/$(basename "$DOCKER_CLI_PATH")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ fi
|
||||||
|
|
||||||
# This is a temporary hack for split-binary mode. It can be removed once
|
# This is a temporary hack for split-binary mode. It can be removed once
|
||||||
# https://github.com/docker/docker/pull/22134 is merged into docker master
|
# https://github.com/docker/docker/pull/22134 is merged into docker master
|
||||||
if [ "$(go env GOOS)" = 'windows' ]; then
|
if [[ "$(go env GOOS)" = 'windows' ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DOCKER_TEST_HOST" ]; then
|
if [[ -z "$DOCKER_TEST_HOST" ]]; then
|
||||||
if docker version &> /dev/null; then
|
if docker version &> /dev/null; then
|
||||||
echo >&2 'skipping daemon start, since daemon appears to be already started'
|
echo >&2 'skipping daemon start, since daemon appears to be already started'
|
||||||
return
|
return
|
||||||
|
@ -43,7 +43,7 @@ export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
|
||||||
|
|
||||||
# example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
|
# example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
|
||||||
storage_params=""
|
storage_params=""
|
||||||
if [ -n "$DOCKER_STORAGE_OPTS" ]; then
|
if [[ -n "$DOCKER_STORAGE_OPTS" ]]; then
|
||||||
IFS=','
|
IFS=','
|
||||||
for i in ${DOCKER_STORAGE_OPTS}; do
|
for i in ${DOCKER_STORAGE_OPTS}; do
|
||||||
storage_params="--storage-opt $i $storage_params"
|
storage_params="--storage-opt $i $storage_params"
|
||||||
|
@ -53,24 +53,24 @@ fi
|
||||||
|
|
||||||
# example usage: DOCKER_REMAP_ROOT=default
|
# example usage: DOCKER_REMAP_ROOT=default
|
||||||
extra_params=""
|
extra_params=""
|
||||||
if [ "$DOCKER_REMAP_ROOT" ]; then
|
if [[ "$DOCKER_REMAP_ROOT" ]]; then
|
||||||
extra_params="--userns-remap $DOCKER_REMAP_ROOT"
|
extra_params="--userns-remap $DOCKER_REMAP_ROOT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# example usage: DOCKER_EXPERIMENTAL=1
|
# example usage: DOCKER_EXPERIMENTAL=1
|
||||||
if [ "$DOCKER_EXPERIMENTAL" ]; then
|
if [[ "$DOCKER_EXPERIMENTAL" ]]; then
|
||||||
echo >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! '
|
echo >&2 '# DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled! '
|
||||||
extra_params="$extra_params --experimental"
|
extra_params="$extra_params --experimental"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DOCKER_TEST_HOST" ]; then
|
if [[ -z "$DOCKER_TEST_HOST" ]]; then
|
||||||
# Start apparmor if it is enabled
|
# Start apparmor if it is enabled
|
||||||
if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
|
if [[ -e "/sys/module/apparmor/parameters/enabled" ]] && [[ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]]; then
|
||||||
# reset container variable so apparmor profile is applied to process
|
# reset container variable so apparmor profile is applied to process
|
||||||
# see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16
|
# see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16
|
||||||
export container=""
|
export container=""
|
||||||
(
|
(
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
/etc/init.d/apparmor start
|
/etc/init.d/apparmor start
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
@ -79,15 +79,15 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
|
||||||
export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock"
|
export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock"
|
||||||
(
|
(
|
||||||
echo "Starting dockerd"
|
echo "Starting dockerd"
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
exec \
|
exec \
|
||||||
dockerd --debug \
|
dockerd --debug \
|
||||||
--host "$DOCKER_HOST" \
|
--host "$DOCKER_HOST" \
|
||||||
--storage-driver "$DOCKER_GRAPHDRIVER" \
|
--storage-driver "$DOCKER_GRAPHDRIVER" \
|
||||||
--pidfile "$DEST/docker.pid" \
|
--pidfile "$DEST/docker.pid" \
|
||||||
--userland-proxy="$DOCKER_USERLANDPROXY" \
|
--userland-proxy="$DOCKER_USERLANDPROXY" \
|
||||||
$storage_params \
|
${storage_params} \
|
||||||
$extra_params \
|
${extra_params} \
|
||||||
&> "$DEST/docker.log"
|
&> "$DEST/docker.log"
|
||||||
) &
|
) &
|
||||||
else
|
else
|
||||||
|
@ -97,19 +97,19 @@ fi
|
||||||
# give it a little time to come up so it's "ready"
|
# give it a little time to come up so it's "ready"
|
||||||
tries=60
|
tries=60
|
||||||
echo "INFO: Waiting for daemon to start..."
|
echo "INFO: Waiting for daemon to start..."
|
||||||
while ! $TEST_CLIENT_BINARY version &> /dev/null; do
|
while ! ${TEST_CLIENT_BINARY} version &> /dev/null; do
|
||||||
(( tries-- ))
|
(( tries-- ))
|
||||||
if [ $tries -le 0 ]; then
|
if [[ $tries -le 0 ]]; then
|
||||||
printf "\n"
|
printf "\n"
|
||||||
if [ -z "$DOCKER_HOST" ]; then
|
if [[ -z "$DOCKER_HOST" ]]; then
|
||||||
echo >&2 "error: daemon failed to start"
|
echo >&2 "error: daemon failed to start"
|
||||||
echo >&2 " check $DEST/docker.log for details"
|
echo >&2 " check $DEST/docker.log for details"
|
||||||
else
|
else
|
||||||
echo >&2 "error: daemon at $DOCKER_HOST fails to '$TEST_CLIENT_BINARY version':"
|
echo >&2 "error: daemon at $DOCKER_HOST fails to '$TEST_CLIENT_BINARY version':"
|
||||||
$TEST_CLIENT_BINARY version >&2 || true
|
${TEST_CLIENT_BINARY} version >&2 || true
|
||||||
# Additional Windows CI debugging as this is a common error as of
|
# Additional Windows CI debugging as this is a common error as of
|
||||||
# January 2016
|
# January 2016
|
||||||
if [ "$(go env GOOS)" = 'windows' ]; then
|
if [[ "$(go env GOOS)" = 'windows' ]]; then
|
||||||
echo >&2 "Container log below:"
|
echo >&2 "Container log below:"
|
||||||
echo >&2 "---"
|
echo >&2 "---"
|
||||||
# Important - use the docker on the CI host, not the one built locally
|
# Important - use the docker on the CI host, not the one built locally
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ ! "$(go env GOOS)" = 'windows' ]; then
|
if [[ ! "$(go env GOOS)" = 'windows' ]]; then
|
||||||
for pidFile in $(find "$DEST" -name docker.pid); do
|
for pidFile in $(find "$DEST" -name docker.pid); do
|
||||||
pid=$([ -n "$TESTDEBUG" ] && set -x; cat "$pidFile")
|
pid=$([[ -n "$TESTDEBUG" ]] && set -x; cat "$pidFile")
|
||||||
(
|
(
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
kill "$pid"
|
kill "$pid"
|
||||||
)
|
)
|
||||||
if ! wait "$pid"; then
|
if ! wait "$pid"; then
|
||||||
|
@ -12,11 +12,11 @@ if [ ! "$(go env GOOS)" = 'windows' ]; then
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$DOCKER_TEST_HOST" ]; then
|
if [[ -z "$DOCKER_TEST_HOST" ]]; then
|
||||||
# Stop apparmor if it is enabled
|
# Stop apparmor if it is enabled
|
||||||
if [ -e "/sys/module/apparmor/parameters/enabled" ] && [ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]; then
|
if [[ -e "/sys/module/apparmor/parameters/enabled" ]] && [[ "$(cat /sys/module/apparmor/parameters/enabled)" == "Y" ]]; then
|
||||||
(
|
(
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
/etc/init.d/apparmor stop
|
/etc/init.d/apparmor stop
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#
|
#
|
||||||
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
|
# TESTFLAGS='-check.f DockerSuite.TestBuild*' ./hack/make.sh binary test-integration
|
||||||
#
|
#
|
||||||
if [ -z $MAKEDIR ]; then
|
if [[ -z ${MAKEDIR} ]]; then
|
||||||
export MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export MAKEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
fi
|
fi
|
||||||
source "$MAKEDIR/.go-autogen"
|
source "$MAKEDIR/.go-autogen"
|
||||||
|
@ -26,11 +26,11 @@ run_test_integration() {
|
||||||
|
|
||||||
run_test_integration_suites() {
|
run_test_integration_suites() {
|
||||||
local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
|
local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS"
|
||||||
for dir in $integration_api_dirs; do
|
for dir in ${integration_api_dirs}; do
|
||||||
if ! (
|
if ! (
|
||||||
cd $dir
|
cd ${dir}
|
||||||
echo "Running $PWD"
|
echo "Running $PWD"
|
||||||
test_env ./test.main $flags
|
test_env ./test.main ${flags}
|
||||||
); then exit 1; fi
|
); then exit 1; fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@ run_test_integration_legacy_suites() {
|
||||||
}
|
}
|
||||||
|
|
||||||
build_test_suite_binaries() {
|
build_test_suite_binaries() {
|
||||||
if [ ${DOCKER_INTEGRATION_TESTS_VERIFIED-} ]; then
|
if [[ ${DOCKER_INTEGRATION_TESTS_VERIFIED-} ]]; then
|
||||||
echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"
|
echo "Skipping building test binaries; as DOCKER_INTEGRATION_TESTS_VERIFIED is set"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
build_test_suite_binary ./integration-cli "test.main"
|
build_test_suite_binary ./integration-cli "test.main"
|
||||||
for dir in $integration_api_dirs; do
|
for dir in ${integration_api_dirs}; do
|
||||||
build_test_suite_binary "$dir" "test.main"
|
build_test_suite_binary "$dir" "test.main"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -64,13 +64,13 @@ build_test_suite_binary() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_test_suite_binaries() {
|
cleanup_test_suite_binaries() {
|
||||||
[ -n "$TESTDEBUG" ] && return
|
[[ -n "$TESTDEBUG" ]] && return
|
||||||
echo "Removing test suite binaries"
|
echo "Removing test suite binaries"
|
||||||
find integration* -name test.main | xargs -r rm
|
find integration* -name test.main | xargs -r rm
|
||||||
}
|
}
|
||||||
|
|
||||||
repeat() {
|
repeat() {
|
||||||
for i in $(seq 1 $TEST_REPEAT); do
|
for i in $(seq 1 ${TEST_REPEAT}); do
|
||||||
echo "Running integration-test (iteration $i)"
|
echo "Running integration-test (iteration $i)"
|
||||||
$@
|
$@
|
||||||
done
|
done
|
||||||
|
@ -80,7 +80,7 @@ repeat() {
|
||||||
test_env() {
|
test_env() {
|
||||||
(
|
(
|
||||||
set -e
|
set -e
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
env -i \
|
env -i \
|
||||||
DEST="$ABS_DEST" \
|
DEST="$ABS_DEST" \
|
||||||
DOCKER_API_VERSION="$DOCKER_API_VERSION" \
|
DOCKER_API_VERSION="$DOCKER_API_VERSION" \
|
||||||
|
@ -107,15 +107,15 @@ test_env() {
|
||||||
|
|
||||||
|
|
||||||
error_on_leaked_containerd_shims() {
|
error_on_leaked_containerd_shims() {
|
||||||
if [ "$(go env GOOS)" == 'windows' ]; then
|
if [[ "$(go env GOOS)" == 'windows' ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
leftovers=$(ps -ax -o pid,cmd |
|
leftovers=$(ps -ax -o pid,cmd |
|
||||||
awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
|
awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
|
||||||
if [ -n "$leftovers" ]; then
|
if [[ -n "$leftovers" ]]; then
|
||||||
ps aux
|
ps aux
|
||||||
kill -9 $leftovers 2> /dev/null
|
kill -9 ${leftovers} 2> /dev/null
|
||||||
echo "!!!! WARNING you have left over shim(s), Cleanup your test !!!!"
|
echo "!!!! WARNING you have left over shim(s), Cleanup your test !!!!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,21 +7,21 @@ copy_binaries() {
|
||||||
# Add nested executables to bundle dir so we have complete set of
|
# Add nested executables to bundle dir so we have complete set of
|
||||||
# them available, but only if the native OS/ARCH is the same as the
|
# them available, but only if the native OS/ARCH is the same as the
|
||||||
# OS/ARCH of the build target
|
# OS/ARCH of the build target
|
||||||
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
if [[ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ! -x /usr/local/bin/runc ]; then
|
if [[ ! -x /usr/local/bin/runc ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo "Copying nested executables into $dir"
|
echo "Copying nested executables into $dir"
|
||||||
for file in containerd containerd-shim ctr runc docker-init docker-proxy; do
|
for file in containerd containerd-shim ctr runc docker-init docker-proxy; do
|
||||||
cp -f `which "$file"` "$dir/"
|
cp -f `which "$file"` "$dir/"
|
||||||
if [ "$hash" == "hash" ]; then
|
if [[ "$hash" == "hash" ]]; then
|
||||||
hash_files "$dir/$file"
|
hash_files "$dir/$file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -z "$KEEPDEST" ] && rm -rf "$DEST"
|
[[ -z "$KEEPDEST" ]] && rm -rf "$DEST"
|
||||||
source "${MAKEDIR}/.binary"
|
source "${MAKEDIR}/.binary"
|
||||||
copy_binaries "$DEST" 'hash'
|
copy_binaries "$DEST" 'hash'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# if we have our linux/amd64 version compiled, let's symlink it in
|
# if we have our linux/amd64 version compiled, let's symlink it in
|
||||||
if [ -x "$DEST/../binary-daemon/dockerd-$VERSION" ]; then
|
if [[ -x "$DEST/../binary-daemon/dockerd-$VERSION" ]]; then
|
||||||
arch=$(go env GOHOSTARCH)
|
arch=$(go env GOHOSTARCH)
|
||||||
mkdir -p "$DEST/linux/${arch}"
|
mkdir -p "$DEST/linux/${arch}"
|
||||||
(
|
(
|
||||||
|
@ -14,7 +14,7 @@ fi
|
||||||
|
|
||||||
DOCKER_CROSSPLATFORMS=${DOCKER_CROSSPLATFORMS:-"linux/amd64 windows/amd64"}
|
DOCKER_CROSSPLATFORMS=${DOCKER_CROSSPLATFORMS:-"linux/amd64 windows/amd64"}
|
||||||
|
|
||||||
for platform in $DOCKER_CROSSPLATFORMS; do
|
for platform in ${DOCKER_CROSSPLATFORMS}; do
|
||||||
(
|
(
|
||||||
export KEEPDEST=1
|
export KEEPDEST=1
|
||||||
export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
|
export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ $platform == "windows/amd64" ]; then
|
if [[ ${platform} == "windows/amd64" ]]; then
|
||||||
source "${MAKEDIR}/containerutility"
|
source "${MAKEDIR}/containerutility"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -6,7 +6,7 @@ rm -rf "$DEST"
|
||||||
install_binary() {
|
install_binary() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
local target="${DOCKER_MAKE_INSTALL_PREFIX:=/usr/local}/bin/"
|
local target="${DOCKER_MAKE_INSTALL_PREFIX:=/usr/local}/bin/"
|
||||||
if [ "$(go env GOOS)" == "linux" ]; then
|
if [[ "$(go env GOOS)" == "linux" ]]; then
|
||||||
echo "Installing $(basename $file) to ${target}"
|
echo "Installing $(basename $file) to ${target}"
|
||||||
mkdir -p "$target"
|
mkdir -p "$target"
|
||||||
cp -f -L "$file" "$target"
|
cp -f -L "$file" "$target"
|
||||||
|
|
|
@ -13,7 +13,7 @@ DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true}
|
||||||
|
|
||||||
# example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
|
# example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G"
|
||||||
storage_params=""
|
storage_params=""
|
||||||
if [ -n "$DOCKER_STORAGE_OPTS" ]; then
|
if [[ -n "$DOCKER_STORAGE_OPTS" ]]; then
|
||||||
IFS=','
|
IFS=','
|
||||||
for i in ${DOCKER_STORAGE_OPTS}; do
|
for i in ${DOCKER_STORAGE_OPTS}; do
|
||||||
storage_params="--storage-opt $i $storage_params"
|
storage_params="--storage-opt $i $storage_params"
|
||||||
|
@ -23,22 +23,22 @@ fi
|
||||||
|
|
||||||
|
|
||||||
listen_port=2375
|
listen_port=2375
|
||||||
if [ -n "$DOCKER_PORT" ]; then
|
if [[ -n "$DOCKER_PORT" ]]; then
|
||||||
IFS=':' read -r -a ports <<< "$DOCKER_PORT"
|
IFS=':' read -r -a ports <<< "$DOCKER_PORT"
|
||||||
listen_port="${ports[-1]}"
|
listen_port="${ports[-1]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
extra_params="$DOCKERD_ARGS"
|
extra_params="$DOCKERD_ARGS"
|
||||||
if [ "$DOCKER_REMAP_ROOT" ]; then
|
if [[ "$DOCKER_REMAP_ROOT" ]]; then
|
||||||
extra_params="$extra_params --userns-remap $DOCKER_REMAP_ROOT"
|
extra_params="$extra_params --userns-remap $DOCKER_REMAP_ROOT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
args="--debug \
|
args="--debug \
|
||||||
--host tcp://0.0.0.0:${listen_port} --host unix:///var/run/docker.sock \
|
--host tcp://0.0.0.0:${listen_port} --host unix:///var/run/docker.sock \
|
||||||
--storage-driver "$DOCKER_GRAPHDRIVER" \
|
--storage-driver "${DOCKER_GRAPHDRIVER}" \
|
||||||
--userland-proxy="$DOCKER_USERLANDPROXY" \
|
--userland-proxy="${DOCKER_USERLANDPROXY}" \
|
||||||
$storage_params \
|
$storage_params \
|
||||||
$extra_params"
|
$extra_params"
|
||||||
|
|
||||||
echo dockerd $args
|
echo dockerd ${args}
|
||||||
exec dockerd $args
|
exec dockerd ${args}
|
||||||
|
|
|
@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers
|
||||||
bundle .integration-daemon-start
|
bundle .integration-daemon-start
|
||||||
|
|
||||||
dockerPy='/docker-py'
|
dockerPy='/docker-py'
|
||||||
[ -d "$dockerPy" ] || {
|
[[ -d "$dockerPy" ]] || {
|
||||||
dockerPy="$DEST/docker-py"
|
dockerPy="$DEST/docker-py"
|
||||||
git clone https://github.com/docker/docker-py.git "$dockerPy"
|
git clone https://github.com/docker/docker-py.git "$dockerPy"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers
|
||||||
bundle .integration-daemon-start
|
bundle .integration-daemon-start
|
||||||
bundle .integration-daemon-setup
|
bundle .integration-daemon-setup
|
||||||
|
|
||||||
local testexit=0
|
testexit=0
|
||||||
( repeat run_test_integration ) || testexit=$?
|
( repeat run_test_integration ) || testexit=$?
|
||||||
|
|
||||||
# Always run cleanup, even if the subshell fails
|
# Always run cleanup, even if the subshell fails
|
||||||
|
@ -16,6 +16,6 @@ source hack/make/.integration-test-helpers
|
||||||
cleanup_test_suite_binaries
|
cleanup_test_suite_binaries
|
||||||
error_on_leaked_containerd_shims
|
error_on_leaked_containerd_shims
|
||||||
|
|
||||||
exit $testexit
|
exit ${testexit}
|
||||||
|
|
||||||
) 2>&1 | tee -a "$DEST/test.log"
|
) 2>&1 | tee -a "$DEST/test.log"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set -e -u -o pipefail
|
set -e -u -o pipefail
|
||||||
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
if [ "$ARCH" == "x86_64" ]; then
|
if [[ "$ARCH" == "x86_64" ]]; then
|
||||||
ARCH="amd64"
|
ARCH="amd64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ run_test_integration_legacy_suites() {
|
||||||
test_env() {
|
test_env() {
|
||||||
(
|
(
|
||||||
set -e +u
|
set -e +u
|
||||||
[ -n "$TESTDEBUG" ] && set -x
|
[[ -n "$TESTDEBUG" ]] && set -x
|
||||||
env -i \
|
env -i \
|
||||||
DOCKER_API_VERSION="$DOCKER_API_VERSION" \
|
DOCKER_API_VERSION="$DOCKER_API_VERSION" \
|
||||||
DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \
|
DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \
|
||||||
|
|
|
@ -24,7 +24,7 @@ for pkg in $pkg_list; do
|
||||||
-cover \
|
-cover \
|
||||||
-coverprofile=profile.out \
|
-coverprofile=profile.out \
|
||||||
-covermode=atomic \
|
-covermode=atomic \
|
||||||
$TESTFLAGS \
|
${TESTFLAGS} \
|
||||||
"${pkg}"
|
"${pkg}"
|
||||||
|
|
||||||
if test -f profile.out; then
|
if test -f profile.out; then
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
if [ -z "$VALIDATE_UPSTREAM" ]; then
|
if [[ -z "$VALIDATE_UPSTREAM" ]]; then
|
||||||
# this is kind of an expensive check, so let's not do this twice if we
|
# this is kind of an expensive check, so let's not do this twice if we
|
||||||
# are running more than one validate bundlescript
|
# are running more than one validate bundlescript
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then
|
||||||
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
|
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
|
||||||
|
|
||||||
validate_diff() {
|
validate_diff() {
|
||||||
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
if [[ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]]; then
|
||||||
git diff "$VALIDATE_COMMIT_DIFF" "$@"
|
git diff "$VALIDATE_COMMIT_DIFF" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
validate_log() {
|
validate_log() {
|
||||||
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
if [[ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]]; then
|
||||||
git log "$VALIDATE_COMMIT_LOG" "$@"
|
git log "$VALIDATE_COMMIT_LOG" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
. $SCRIPTDIR/default
|
. ${SCRIPTDIR}/default
|
||||||
. $SCRIPTDIR/vendor
|
. ${SCRIPTDIR}/vendor
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
changelogFile=${1:-CHANGELOG.md}
|
changelogFile=${1:-CHANGELOG.md}
|
||||||
|
|
||||||
if [ ! -r "$changelogFile" ]; then
|
if [[ ! -r "$changelogFile" ]]; then
|
||||||
echo "Unable to read file $changelogFile" >&2
|
echo "Unable to read file $changelogFile" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
changelogFile=${1:-CHANGELOG.md}
|
changelogFile=${1:-CHANGELOG.md}
|
||||||
|
|
||||||
if [ ! -r "$changelogFile" ]; then
|
if [[ ! -r "$changelogFile" ]]; then
|
||||||
echo "Unable to read file $changelogFile" >&2
|
echo "Unable to read file $changelogFile" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -21,13 +21,13 @@ check_dco() {
|
||||||
grep -qE "$dcoRegex"
|
grep -qE "$dcoRegex"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $adds -eq 0 -a $dels -eq 0 ]; then
|
if [[ ${adds} -eq 0 && ${dels} -eq 0 ]]; then
|
||||||
echo '0 adds, 0 deletions; nothing to validate! :)'
|
echo '0 adds, 0 deletions; nothing to validate! :)'
|
||||||
else
|
else
|
||||||
commits=( $(validate_log --format='format:%H%n') )
|
commits=( $(validate_log --format='format:%H%n') )
|
||||||
badCommits=()
|
badCommits=()
|
||||||
for commit in "${commits[@]}"; do
|
for commit in "${commits[@]}"; do
|
||||||
if [ -z "$(git log -1 --format='format:' --name-status "$commit")" ]; then
|
if [[ -z "$(git log -1 --format='format:' --name-status "$commit")" ]]; then
|
||||||
# no content (ie, Merge commit, etc)
|
# no content (ie, Merge commit, etc)
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -35,7 +35,7 @@ else
|
||||||
badCommits+=( "$commit" )
|
badCommits+=( "$commit" )
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ${#badCommits[@]} -eq 0 ]; then
|
if [[ ${#badCommits[@]} -eq 0 ]]; then
|
||||||
echo "Congratulations! All commits are properly signed with the DCO!"
|
echo "Congratulations! All commits are properly signed with the DCO!"
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
|
|
||||||
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
. $SCRIPTDIR/dco
|
. ${SCRIPTDIR}/dco
|
||||||
. $SCRIPTDIR/default-seccomp
|
. ${SCRIPTDIR}/default-seccomp
|
||||||
. $SCRIPTDIR/gometalinter
|
. ${SCRIPTDIR}/gometalinter
|
||||||
. $SCRIPTDIR/pkg-imports
|
. ${SCRIPTDIR}/pkg-imports
|
||||||
. $SCRIPTDIR/swagger
|
. ${SCRIPTDIR}/swagger
|
||||||
. $SCRIPTDIR/swagger-gen
|
. ${SCRIPTDIR}/swagger-gen
|
||||||
. $SCRIPTDIR/test-imports
|
. ${SCRIPTDIR}/test-imports
|
||||||
. $SCRIPTDIR/toml
|
. ${SCRIPTDIR}/toml
|
||||||
. $SCRIPTDIR/changelog-well-formed
|
. ${SCRIPTDIR}/changelog-well-formed
|
||||||
. $SCRIPTDIR/changelog-date-descending
|
. ${SCRIPTDIR}/changelog-date-descending
|
||||||
. $SCRIPTDIR/deprecate-integration-cli
|
. ${SCRIPTDIR}/deprecate-integration-cli
|
||||||
|
|
|
@ -7,12 +7,12 @@ IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) )
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ ${#files[@]} -gt 0 ]; then
|
if [[ ${#files[@]} -gt 0 ]]; then
|
||||||
# We run 'go generate' and see if we have a diff afterwards
|
# We run 'go generate' and see if we have a diff afterwards
|
||||||
go generate ./profiles/seccomp/ >/dev/null
|
go generate ./profiles/seccomp/ >/dev/null
|
||||||
# Let see if the working directory is clean
|
# Let see if the working directory is clean
|
||||||
diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)"
|
diffs="$(git status --porcelain -- profiles/seccomp 2>/dev/null)"
|
||||||
if [ "$diffs" ]; then
|
if [[ "$diffs" ]]; then
|
||||||
{
|
{
|
||||||
echo 'The result of go generate ./profiles/seccomp/ differs'
|
echo 'The result of go generate ./profiles/seccomp/ differs'
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -9,7 +9,7 @@ new_tests=$(
|
||||||
grep -E '^\+func (.*) Test' || true
|
grep -E '^\+func (.*) Test' || true
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -z "$new_tests" ]; then
|
if [[ -z "$new_tests" ]]; then
|
||||||
echo 'Congratulations! No new tests added to integration-cli.'
|
echo 'Congratulations! No new tests added to integration-cli.'
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -10,4 +10,4 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
gometalinter \
|
gometalinter \
|
||||||
${GOMETALINTER_OPTS} \
|
${GOMETALINTER_OPTS} \
|
||||||
--config $SCRIPTDIR/gometalinter.json ./...
|
--config ${SCRIPTDIR}/gometalinter.json ./...
|
||||||
|
|
|
@ -19,7 +19,7 @@ for f in "${files[@]}"; do
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${#badFiles[@]} -eq 0 ]; then
|
if [[ ${#badFiles[@]} -eq 0 ]]; then
|
||||||
echo 'Congratulations! "./pkg/..." is safely isolated from internal code.'
|
echo 'Congratulations! "./pkg/..." is safely isolated from internal code.'
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true) )
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ ${#files[@]} -gt 0 ]; then
|
if [[ ${#files[@]} -gt 0 ]]; then
|
||||||
yamllint -c ${SCRIPTDIR}/.swagger-yamllint api/swagger.yaml
|
yamllint -c ${SCRIPTDIR}/.swagger-yamllint api/swagger.yaml
|
||||||
swagger validate api/swagger.yaml
|
swagger validate api/swagger.yaml
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,11 +7,11 @@ IFS=$'\n'
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) )
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ ${#files[@]} -gt 0 ]; then
|
if [[ ${#files[@]} -gt 0 ]]; then
|
||||||
${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
|
${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null
|
||||||
# Let see if the working directory is clean
|
# Let see if the working directory is clean
|
||||||
diffs="$(git diff -- api/types/)"
|
diffs="$(git diff -- api/types/)"
|
||||||
if [ "$diffs" ]; then
|
if [[ "$diffs" ]]; then
|
||||||
{
|
{
|
||||||
echo 'The result of hack/generate-swagger-api.sh differs'
|
echo 'The result of hack/generate-swagger-api.sh differs'
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -11,20 +11,20 @@ unset IFS
|
||||||
badFiles=()
|
badFiles=()
|
||||||
for f in "${files[@]}"; do
|
for f in "${files[@]}"; do
|
||||||
# skip check_test.go since it *does* use the testing package
|
# skip check_test.go since it *does* use the testing package
|
||||||
if [ "$f" = "integration-cli/check_test.go" ]; then
|
if [[ "$f" = "integration-cli/check_test.go" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we use "git show" here to validate that what's committed doesn't contain golang built-in testing
|
# we use "git show" here to validate that what's committed doesn't contain golang built-in testing
|
||||||
if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then
|
if git show "$VALIDATE_HEAD:$f" | grep -q testing.T; then
|
||||||
if [ "$(echo $f | grep '_test')" ]; then
|
if [[ "$(echo $f | grep '_test')" ]]; then
|
||||||
# allow testing.T for non- _test files
|
# allow testing.T for non- _test files
|
||||||
badFiles+=( "$f" )
|
badFiles+=( "$f" )
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${#badFiles[@]} -eq 0 ]; then
|
if [[ ${#badFiles[@]} -eq 0 ]]; then
|
||||||
echo 'Congratulations! No testing.T found.'
|
echo 'Congratulations! No testing.T found.'
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ for f in "${files[@]}"; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${#badFiles[@]} -eq 0 ]; then
|
if [[ ${#badFiles[@]} -eq 0 ]]; then
|
||||||
echo 'Congratulations! All toml source files changed here have valid syntax.'
|
echo 'Congratulations! All toml source files changed here have valid syntax.'
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,12 +8,12 @@ validate_vendor_diff(){
|
||||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) )
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) )
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ ${#files[@]} -gt 0 ]; then
|
if [[ ${#files[@]} -gt 0 ]]; then
|
||||||
# recreate vendor/
|
# recreate vendor/
|
||||||
vndr
|
vndr
|
||||||
# check if any files have changed
|
# check if any files have changed
|
||||||
diffs="$(git status --porcelain -- vendor 2>/dev/null)"
|
diffs="$(git status --porcelain -- vendor 2>/dev/null)"
|
||||||
if [ "$diffs" ]; then
|
if [[ "$diffs" ]]; then
|
||||||
{
|
{
|
||||||
echo 'The result of vndr differs'
|
echo 'The result of vndr differs'
|
||||||
echo
|
echo
|
||||||
|
@ -38,7 +38,7 @@ validate_vendor_used() {
|
||||||
for f in $pkgs; do
|
for f in $pkgs; do
|
||||||
if ls -d vendor/$f > /dev/null 2>&1; then
|
if ls -d vendor/$f > /dev/null 2>&1; then
|
||||||
found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
|
found=$(find vendor/$f -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
|
||||||
if [ $found -eq 0 ]; then
|
if [[ ${found} -eq 0 ]]; then
|
||||||
echo "WARNING: could not find copyright information for $f"
|
echo "WARNING: could not find copyright information for $f"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue