diff --git a/hack/dind b/hack/dind index 3036fa3e3f..3254f9dbe7 100755 --- a/hack/dind +++ b/hack/dind @@ -13,7 +13,7 @@ set -e # apparmor sucks and Docker needs to know that it's in a container (c) @tianon 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 || { echo >&2 'Could not mount /sys/kernel/security.' echo >&2 'AppArmor detection and --privileged mode might break.' @@ -25,7 +25,7 @@ if ! mountpoint -q /tmp; then mount -t tmpfs none /tmp fi -if [[ $# -gt 0 ]]; then +if [ $# -gt 0 ]; then exec "$@" fi diff --git a/hack/dockerfile/install/containerd.installer b/hack/dockerfile/install/containerd.installer index 5d78c8471d..98b06d0b8a 100755 --- a/hack/dockerfile/install/containerd.installer +++ b/hack/dockerfile/install/containerd.installer @@ -28,9 +28,9 @@ install_containerd() { make ) - mkdir -p "${PREFIX}" + mkdir -p ${PREFIX} - cp bin/containerd "${PREFIX}/containerd" - cp bin/containerd-shim "${PREFIX}/containerd-shim" - cp bin/ctr "${PREFIX}/ctr" + cp bin/containerd ${PREFIX}/containerd + cp bin/containerd-shim ${PREFIX}/containerd-shim + cp bin/ctr ${PREFIX}/ctr } diff --git a/hack/dockerfile/install/dockercli.installer b/hack/dockerfile/install/dockercli.installer index 03435fe54b..ae3aa0dd45 100755 --- a/hack/dockerfile/install/dockercli.installer +++ b/hack/dockerfile/install/dockercli.installer @@ -8,13 +8,14 @@ install_dockercli() { arch=$(uname -m) # No official release of these platforms - if [ "$arch" != "x86_64" ] && [ "$arch" != "s390x" ]; then + if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then build_dockercli return fi url=https://download.docker.com/linux/static - curl -Ls "${url}/${DOCKERCLI_CHANNEL}/${arch}/docker-${DOCKERCLI_VERSION}.tgz" | tar -xz docker/docker + curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \ + tar -xz docker/docker mkdir -p ${PREFIX} mv docker/docker ${PREFIX}/ rmdir docker @@ -26,5 +27,5 @@ build_dockercli() { git checkout -q "v$DOCKERCLI_VERSION" mkdir -p "$GOPATH/src/github.com/docker" 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 } diff --git a/hack/dockerfile/install/gometalinter.installer b/hack/dockerfile/install/gometalinter.installer index 461850f936..d921fd739a 100755 --- a/hack/dockerfile/install/gometalinter.installer +++ b/hack/dockerfile/install/gometalinter.installer @@ -7,6 +7,6 @@ install_gometalinter() { go get -d github.com/alecthomas/gometalinter cd "$GOPATH/src/github.com/alecthomas/gometalinter" git checkout -q "$GOMETALINTER_COMMIT" - go build -buildmode=pie -o "${PREFIX}/gometalinter" "github.com/alecthomas/gometalinter" - GOBIN=${PREFIX} "${PREFIX}/gometalinter" --install + go build -buildmode=pie -o ${PREFIX}/gometalinter github.com/alecthomas/gometalinter + GOBIN=${PREFIX} ${PREFIX}/gometalinter --install } diff --git a/hack/dockerfile/install/install.sh b/hack/dockerfile/install/install.sh index c0402a8508..a0ff09da55 100755 --- a/hack/dockerfile/install/install.sh +++ b/hack/dockerfile/install/install.sh @@ -9,7 +9,7 @@ TMP_GOPATH=${TMP_GOPATH:-""} : ${PREFIX:="/usr/local/bin"} -if [[ -z "$TMP_GOPATH" ]]; then +if [ -z "$TMP_GOPATH" ]; then export GOPATH="$(mktemp -d)" RM_GOPATH=1 else @@ -21,10 +21,10 @@ dir="$(dirname $0)" bin=$1 shift -if [[ ! -f "${dir}/${bin}.installer" ]]; then +if [ ! -f "${dir}/${bin}.installer" ]; then echo "Could not find installer for \"$bin\"" exit 1 fi -. ${dir}/${bin}.installer -install_${bin} "$@" +. $dir/$bin.installer +install_$bin "$@" diff --git a/hack/dockerfile/install/proxy.installer b/hack/dockerfile/install/proxy.installer index 06643a435d..b8c19ef0c1 100755 --- a/hack/dockerfile/install/proxy.installer +++ b/hack/dockerfile/install/proxy.installer @@ -32,7 +32,7 @@ _install_proxy() { git clone https://github.com/docker/libnetwork.git "$GOPATH/src/github.com/docker/libnetwork" cd "$GOPATH/src/github.com/docker/libnetwork" 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 } diff --git a/hack/dockerfile/install/runc.installer b/hack/dockerfile/install/runc.installer index 21462686a7..c6d28982f4 100755 --- a/hack/dockerfile/install/runc.installer +++ b/hack/dockerfile/install/runc.installer @@ -25,6 +25,6 @@ install_runc() { target="$1" fi make BUILDTAGS="$RUNC_BUILDTAGS" "$target" - mkdir -p "${PREFIX}" - cp runc "${PREFIX}/runc" + mkdir -p ${PREFIX} + cp runc ${PREFIX}/runc } diff --git a/hack/dockerfile/install/tini.installer b/hack/dockerfile/install/tini.installer index c622357365..34f43f15f4 100755 --- a/hack/dockerfile/install/tini.installer +++ b/hack/dockerfile/install/tini.installer @@ -9,6 +9,6 @@ install_tini() { git checkout -q "$TINI_COMMIT" cmake . make tini-static - mkdir -p "${PREFIX}" - cp tini-static "${PREFIX}/docker-init" + mkdir -p ${PREFIX} + cp tini-static ${PREFIX}/docker-init } diff --git a/hack/dockerfile/install/tomlv.installer b/hack/dockerfile/install/tomlv.installer index cbf23c8e33..8ec6812255 100755 --- a/hack/dockerfile/install/tomlv.installer +++ b/hack/dockerfile/install/tomlv.installer @@ -8,5 +8,5 @@ install_tomlv() { echo "Install tomlv version $TOMLV_COMMIT" 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" - 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 } diff --git a/hack/dockerfile/install/vndr.installer b/hack/dockerfile/install/vndr.installer index d53fadaf7a..e6a94e7071 100755 --- a/hack/dockerfile/install/vndr.installer +++ b/hack/dockerfile/install/vndr.installer @@ -7,5 +7,5 @@ install_vndr() { git clone https://github.com/LK4D4/vndr.git "$GOPATH/src/github.com/LK4D4/vndr" cd "$GOPATH/src/github.com/LK4D4/vndr" git checkout -q "$VNDR_COMMIT" - go build -buildmode=pie -v -o "${PREFIX}/vndr" . + go build -buildmode=pie -v -o ${PREFIX}/vndr . } diff --git a/hack/make.sh b/hack/make.sh index 0d5aa1367b..62c72a09e2 100755 --- a/hack/make.sh +++ b/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; # but really, they shouldn't. We want to be in a container! inContainer="AssumeSoInitially" -if [[ "$(go env GOHOSTOS)" = 'windows' ]]; then - if [[ -z "$FROM_DOCKERFILE" ]]; then +if [ "$(go env GOHOSTOS)" = 'windows' ]; then + if [ -z "$FROM_DOCKERFILE" ]; then unset inContainer fi else - if [[ "$PWD" != "/go/src/$DOCKER_PKG" ]]; then + if [ "$PWD" != "/go/src/$DOCKER_PKG" ]; then unset inContainer fi fi -if [[ -z "$inContainer" ]]; then +if [ -z "$inContainer" ]; then { 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" @@ -67,11 +67,11 @@ DEFAULT_BUNDLES=( VERSION=${VERSION:-dev} ! 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" elif command -v git &> /dev/null && [ -e .git ] && git rev-parse &> /dev/null; then 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" echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "# GITCOMMIT = $GITCOMMIT" @@ -90,14 +90,14 @@ else exit 1 fi -if [[ "$AUTO_GOPATH" ]]; then +if [ "$AUTO_GOPATH" ]; then rm -rf .gopath mkdir -p .gopath/src/"$(dirname "${DOCKER_PKG}")" ln -sf ../../../.. .gopath/src/"${DOCKER_PKG}" export GOPATH="${PWD}/.gopath" fi -if [[ ! "$GOPATH" ]]; then +if [ ! "$GOPATH" ]; then echo >&2 'error: missing GOPATH; please see https://golang.org/doc/code.html#GOPATH' echo >&2 ' alternatively, set AUTO_GOPATH=1' exit 1 @@ -137,7 +137,7 @@ fi # Use these flags when compiling the tests and final binary IAMSTATIC='true' -if [[ -z "$DOCKER_DEBUG" ]]; then +if [ -z "$DOCKER_DEBUG" ]; then LDFLAGS='-w' fi @@ -148,12 +148,12 @@ EXTLDFLAGS_STATIC='-static' 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 -BUILDFLAGS=( ${BUILDFLAGS} "${ORIG_BUILDFLAGS[@]}" ) +BUILDFLAGS=( $BUILDFLAGS "${ORIG_BUILDFLAGS[@]}" ) # Test timeout. -if [[ "${DOCKER_ENGINE_GOARCH}" == "arm64" ]] || [[ "${DOCKER_ENGINE_GOARCH}" == "arm" ]]; then +if [ "${DOCKER_ENGINE_GOARCH}" == "arm64" ] || [ "${DOCKER_ENGINE_GOARCH}" == "arm" ]; then : ${TIMEOUT:=10m} -elif [[ "${DOCKER_ENGINE_GOARCH}" == "windows" ]]; then +elif [ "${DOCKER_ENGINE_GOARCH}" == "windows" ]; then : ${TIMEOUT:=8m} else : ${TIMEOUT:=5m} @@ -164,7 +164,7 @@ LDFLAGS_STATIC_DOCKER=" -extldflags \"$EXTLDFLAGS_STATIC\" " -if [[ "$(uname -s)" = 'FreeBSD' ]]; then +if [ "$(uname -s)" = 'FreeBSD' ]; then # 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 export CC=clang @@ -181,7 +181,7 @@ bundle() { } main() { - if [[ -z "${KEEPBUNDLE-}" ]]; then + if [ -z "${KEEPBUNDLE-}" ]; then echo "Removing bundles/" rm -rf "bundles/*" echo @@ -189,13 +189,13 @@ main() { mkdir -p bundles # Windows and symlinks don't get along well - if [[ "$(go env GOHOSTOS)" != 'windows' ]]; then + if [ "$(go env GOHOSTOS)" != 'windows' ]; then rm -f bundles/latest # preserve latest symlink for backward compatibility ln -sf . bundles/latest fi - if [[ $# -lt 1 ]]; then + if [ $# -lt 1 ]; then bundles=(${DEFAULT_BUNDLES[@]}) else bundles=($@) diff --git a/hack/make/.binary b/hack/make/.binary index 6d2a843428..010c2c11da 100644 --- a/hack/make/.binary +++ b/hack/make/.binary @@ -3,7 +3,7 @@ set -e # a helper to provide ".exe" when it's appropriate binary_extension() { - if [[ "$(go env GOOS)" = 'windows' ]]; then + if [ "$(go env GOOS)" = 'windows' ]; then echo -n '.exe' fi } @@ -17,7 +17,7 @@ BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION" source "${MAKEDIR}/.go-autogen" hash_files() { - while [[ $# -gt 0 ]]; do + while [ $# -gt 0 ]; do f="$1" shift dir="$(dirname "$f")" @@ -40,7 +40,7 @@ hash_files() { ( 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! case "$(go env GOOS)/$(go env GOARCH)" in windows/amd64) @@ -68,7 +68,7 @@ go build \ $LDFLAGS_STATIC_DOCKER $DOCKER_LDFLAGS " \ - ${GO_PACKAGE} + $GO_PACKAGE ) echo "Created binary: $DEST/$BINARY_FULLNAME" diff --git a/hack/make/.detect-daemon-osarch b/hack/make/.detect-daemon-osarch index 92814dedf2..91e2c53c75 100644 --- a/hack/make/.detect-daemon-osarch +++ b/hack/make/.detect-daemon-osarch @@ -36,7 +36,7 @@ DOCKER_CLIENT_GOARCH=${DOCKER_CLIENT_GOARCH:=amd64} DOCKERFILE='Dockerfile' -if [[ "${DOCKER_ENGINE_GOOS:-$DOCKER_CLIENT_GOOS}" = "windows" ]]; then +if [ "${DOCKER_ENGINE_GOOS:-$DOCKER_CLIENT_GOOS}" = "windows" ]; then DOCKERFILE='Dockerfile.windows' fi diff --git a/hack/make/.ensure-emptyfs b/hack/make/.ensure-emptyfs index f2f98f73a1..898cc22834 100644 --- a/hack/make/.ensure-emptyfs +++ b/hack/make/.ensure-emptyfs @@ -16,7 +16,7 @@ if ! docker image inspect emptyfs > /dev/null; then tar -cf layer.tar --files-from /dev/null ) ( - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x tar -cC "$dir" . | docker load ) rm -rf "$dir" diff --git a/hack/make/.go-autogen b/hack/make/.go-autogen index 7ce3994752..6397cdc2d3 100644 --- a/hack/make/.go-autogen +++ b/hack/make/.go-autogen @@ -43,7 +43,7 @@ const ( DVEOF # 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 cp hack/make/.resources-windows/resources.go autogen/winresources/docker/ 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 defs= - [[ ! -z $VERSION ]] && defs="$defs -D DOCKER_VERSION=\"$VERSION\"" - [[ ! -z $VERSION_QUAD ]] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD" - [[ ! -z $GITCOMMIT ]] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\"" + [ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\"" + [ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD" + [ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\"" function makeres { - ${WINDRES} \ + $WINDRES \ -i hack/make/.resources-windows/$1 \ -o $3 \ -F $2 \ @@ -76,7 +76,7 @@ if [[ "$(go env GOOS)" = "windows" ]]; then $defs } - ${WINDMC} \ + $WINDMC \ hack/make/.resources-windows/event_messages.mc \ -h autogen/winresources/tmp \ -r autogen/winresources/tmp diff --git a/hack/make/.integration-daemon-setup b/hack/make/.integration-daemon-setup index 397d833b0a..c130e23560 100644 --- a/hack/make/.integration-daemon-setup +++ b/hack/make/.integration-daemon-setup @@ -2,6 +2,6 @@ set -e source "$MAKEDIR/.detect-daemon-osarch" -if [[ "$DOCKER_ENGINE_GOOS" != "windows" ]]; then +if [ "$DOCKER_ENGINE_GOOS" != "windows" ]; then bundle .ensure-emptyfs fi diff --git a/hack/make/.integration-daemon-start b/hack/make/.integration-daemon-start index f84f0bedb7..20801fccee 100644 --- a/hack/make/.integration-daemon-start +++ b/hack/make/.integration-daemon-start @@ -7,7 +7,7 @@ export PATH="$base/binary-daemon:$base/dynbinary-daemon:$PATH" 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") fi @@ -19,11 +19,11 @@ fi # 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 -if [[ "$(go env GOOS)" = 'windows' ]]; then +if [ "$(go env GOOS)" = 'windows' ]; then return fi -if [[ -z "$DOCKER_TEST_HOST" ]]; then +if [ -z "$DOCKER_TEST_HOST" ]; then if docker version &> /dev/null; then echo >&2 'skipping daemon start, since daemon appears to be already started' return @@ -43,7 +43,7 @@ export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" storage_params="" -if [[ -n "$DOCKER_STORAGE_OPTS" ]]; then +if [ -n "$DOCKER_STORAGE_OPTS" ]; then IFS=',' for i in ${DOCKER_STORAGE_OPTS}; do storage_params="--storage-opt $i $storage_params" @@ -53,24 +53,24 @@ fi # example usage: DOCKER_REMAP_ROOT=default extra_params="" -if [[ "$DOCKER_REMAP_ROOT" ]]; then +if [ "$DOCKER_REMAP_ROOT" ]; then extra_params="--userns-remap $DOCKER_REMAP_ROOT" fi # 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! ' extra_params="$extra_params --experimental" fi -if [[ -z "$DOCKER_TEST_HOST" ]]; then +if [ -z "$DOCKER_TEST_HOST" ]; then # 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 # see https://github.com/docker/libcontainer/blob/master/apparmor/apparmor.go#L16 export container="" ( - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x /etc/init.d/apparmor start ) fi @@ -79,15 +79,15 @@ if [[ -z "$DOCKER_TEST_HOST" ]]; then export DOCKER_HOST="unix://$(cd "$DEST" && pwd)/docker.sock" ( echo "Starting dockerd" - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x exec \ dockerd --debug \ --host "$DOCKER_HOST" \ --storage-driver "$DOCKER_GRAPHDRIVER" \ --pidfile "$DEST/docker.pid" \ --userland-proxy="$DOCKER_USERLANDPROXY" \ - ${storage_params} \ - ${extra_params} \ + $storage_params \ + $extra_params \ &> "$DEST/docker.log" ) & else @@ -97,19 +97,19 @@ fi # give it a little time to come up so it's "ready" tries=60 echo "INFO: Waiting for daemon to start..." -while ! ${TEST_CLIENT_BINARY} version &> /dev/null; do +while ! $TEST_CLIENT_BINARY version &> /dev/null; do (( tries-- )) - if [[ $tries -le 0 ]]; then + if [ $tries -le 0 ]; then printf "\n" - if [[ -z "$DOCKER_HOST" ]]; then + if [ -z "$DOCKER_HOST" ]; then echo >&2 "error: daemon failed to start" echo >&2 " check $DEST/docker.log for details" else 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 # January 2016 - if [[ "$(go env GOOS)" = 'windows' ]]; then + if [ "$(go env GOOS)" = 'windows' ]; then echo >&2 "Container log below:" echo >&2 "---" # Important - use the docker on the CI host, not the one built locally diff --git a/hack/make/.integration-daemon-stop b/hack/make/.integration-daemon-stop index e0d58b7d22..c1d43e1a5e 100644 --- a/hack/make/.integration-daemon-stop +++ b/hack/make/.integration-daemon-stop @@ -1,10 +1,10 @@ #!/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 - pid=$([[ -n "$TESTDEBUG" ]] && set -x; cat "$pidFile") + pid=$([ -n "$TESTDEBUG" ] && set -x; cat "$pidFile") ( - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x kill "$pid" ) if ! wait "$pid"; then @@ -12,11 +12,11 @@ if [[ ! "$(go env GOOS)" = 'windows' ]]; then fi done - if [[ -z "$DOCKER_TEST_HOST" ]]; then + if [ -z "$DOCKER_TEST_HOST" ]; then # 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 ) fi diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 4ece2dedae..149b653800 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -5,7 +5,7 @@ # # 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 )" fi source "$MAKEDIR/.go-autogen" @@ -26,11 +26,11 @@ run_test_integration() { run_test_integration_suites() { local flags="-test.v -test.timeout=${TIMEOUT} $TESTFLAGS" - for dir in ${integration_api_dirs}; do + for dir in $integration_api_dirs; do if ! ( - cd ${dir} + cd $dir echo "Running $PWD" - test_env ./test.main ${flags} + test_env ./test.main $flags ); then exit 1; fi done } @@ -45,12 +45,12 @@ run_test_integration_legacy_suites() { } 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" return fi 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" done } @@ -64,13 +64,13 @@ build_test_suite_binary() { } cleanup_test_suite_binaries() { - [[ -n "$TESTDEBUG" ]] && return + [ -n "$TESTDEBUG" ] && return echo "Removing test suite binaries" find integration* -name test.main | xargs -r rm } repeat() { - for i in $(seq 1 ${TEST_REPEAT}); do + for i in $(seq 1 $TEST_REPEAT); do echo "Running integration-test (iteration $i)" $@ done @@ -80,7 +80,7 @@ repeat() { test_env() { ( set -e - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x env -i \ DEST="$ABS_DEST" \ DOCKER_API_VERSION="$DOCKER_API_VERSION" \ @@ -107,15 +107,15 @@ test_env() { error_on_leaked_containerd_shims() { - if [[ "$(go env GOOS)" == 'windows' ]]; then + if [ "$(go env GOOS)" == 'windows' ]; then return fi leftovers=$(ps -ax -o pid,cmd | awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }') - if [[ -n "$leftovers" ]]; then + if [ -n "$leftovers" ]; then 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 !!!!" exit 1 fi diff --git a/hack/make/binary-daemon b/hack/make/binary-daemon index 13c1d66c76..c1a6e6f9ed 100644 --- a/hack/make/binary-daemon +++ b/hack/make/binary-daemon @@ -7,21 +7,21 @@ copy_binaries() { # 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 # 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 fi - if [[ ! -x /usr/local/bin/runc ]]; then + if [ ! -x /usr/local/bin/runc ]; then return fi echo "Copying nested executables into $dir" for file in containerd containerd-shim ctr runc docker-init docker-proxy; do cp -f `which "$file"` "$dir/" - if [[ "$hash" == "hash" ]]; then + if [ "$hash" == "hash" ]; then hash_files "$dir/$file" fi done } -[[ -z "$KEEPDEST" ]] && rm -rf "$DEST" +[ -z "$KEEPDEST" ] && rm -rf "$DEST" source "${MAKEDIR}/.binary" copy_binaries "$DEST" 'hash' diff --git a/hack/make/cross b/hack/make/cross index 669005beca..497f02ae4b 100644 --- a/hack/make/cross +++ b/hack/make/cross @@ -2,7 +2,7 @@ set -e # 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) mkdir -p "$DEST/linux/${arch}" ( @@ -14,7 +14,7 @@ fi DOCKER_CROSSPLATFORMS=${DOCKER_CROSSPLATFORMS:-"linux/amd64 windows/amd64"} -for platform in ${DOCKER_CROSSPLATFORMS}; do +for platform in $DOCKER_CROSSPLATFORMS; do ( export KEEPDEST=1 export DEST="$DEST/$platform" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION diff --git a/hack/make/cross-platform-dependent b/hack/make/cross-platform-dependent index 135fc031f5..52632c3036 100644 --- a/hack/make/cross-platform-dependent +++ b/hack/make/cross-platform-dependent @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -e -if [[ ${platform} == "windows/amd64" ]]; then +if [ $platform == "windows/amd64" ]; then source "${MAKEDIR}/containerutility" fi diff --git a/hack/make/install-binary b/hack/make/install-binary index 7a1af19b9c..f6a4361fdb 100644 --- a/hack/make/install-binary +++ b/hack/make/install-binary @@ -6,7 +6,7 @@ rm -rf "$DEST" install_binary() { local file="$1" 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}" mkdir -p "$target" cp -f -L "$file" "$target" diff --git a/hack/make/run b/hack/make/run index d8cbb3e46b..3254280260 100644 --- a/hack/make/run +++ b/hack/make/run @@ -13,7 +13,7 @@ DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" storage_params="" -if [[ -n "$DOCKER_STORAGE_OPTS" ]]; then +if [ -n "$DOCKER_STORAGE_OPTS" ]; then IFS=',' for i in ${DOCKER_STORAGE_OPTS}; do storage_params="--storage-opt $i $storage_params" @@ -23,22 +23,22 @@ fi listen_port=2375 -if [[ -n "$DOCKER_PORT" ]]; then +if [ -n "$DOCKER_PORT" ]; then IFS=':' read -r -a ports <<< "$DOCKER_PORT" listen_port="${ports[-1]}" fi extra_params="$DOCKERD_ARGS" -if [[ "$DOCKER_REMAP_ROOT" ]]; then +if [ "$DOCKER_REMAP_ROOT" ]; then extra_params="$extra_params --userns-remap $DOCKER_REMAP_ROOT" fi args="--debug \ --host tcp://0.0.0.0:${listen_port} --host unix:///var/run/docker.sock \ - --storage-driver "${DOCKER_GRAPHDRIVER}" \ - --userland-proxy="${DOCKER_USERLANDPROXY}" \ + --storage-driver "$DOCKER_GRAPHDRIVER" \ + --userland-proxy="$DOCKER_USERLANDPROXY" \ $storage_params \ $extra_params" -echo dockerd ${args} -exec dockerd ${args} +echo dockerd $args +exec dockerd $args diff --git a/hack/make/test-docker-py b/hack/make/test-docker-py index 6a35b44896..b30879e3a0 100644 --- a/hack/make/test-docker-py +++ b/hack/make/test-docker-py @@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers bundle .integration-daemon-start dockerPy='/docker-py' - [[ -d "$dockerPy" ]] || { + [ -d "$dockerPy" ] || { dockerPy="$DEST/docker-py" git clone https://github.com/docker/docker-py.git "$dockerPy" } diff --git a/hack/make/test-integration b/hack/make/test-integration index 6908935d1f..c807cd4978 100755 --- a/hack/make/test-integration +++ b/hack/make/test-integration @@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers bundle .integration-daemon-start bundle .integration-daemon-setup - testexit=0 + local testexit=0 ( repeat run_test_integration ) || testexit=$? # Always run cleanup, even if the subshell fails @@ -16,6 +16,6 @@ source hack/make/.integration-test-helpers cleanup_test_suite_binaries error_on_leaked_containerd_shims - exit ${testexit} + exit $testexit ) 2>&1 | tee -a "$DEST/test.log" diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh index d4ac42b872..122d58f8ef 100755 --- a/hack/test/e2e-run.sh +++ b/hack/test/e2e-run.sh @@ -2,7 +2,7 @@ set -e -u -o pipefail ARCH=$(uname -m) -if [[ "$ARCH" == "x86_64" ]]; then +if [ "$ARCH" == "x86_64" ]; then ARCH="amd64" fi @@ -45,7 +45,7 @@ run_test_integration_legacy_suites() { test_env() { ( set -e +u - [[ -n "$TESTDEBUG" ]] && set -x + [ -n "$TESTDEBUG" ] && set -x env -i \ DOCKER_API_VERSION="$DOCKER_API_VERSION" \ DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \ diff --git a/hack/test/unit b/hack/test/unit index d79c8a4bfb..ac27f68c30 100755 --- a/hack/test/unit +++ b/hack/test/unit @@ -24,7 +24,7 @@ for pkg in $pkg_list; do -cover \ -coverprofile=profile.out \ -covermode=atomic \ - ${TESTFLAGS} \ + $TESTFLAGS \ "${pkg}" if test -f profile.out; then diff --git a/hack/validate/.validate b/hack/validate/.validate index e9c54b25e5..32cb6b6d64 100644 --- a/hack/validate/.validate +++ b/hack/validate/.validate @@ -2,7 +2,7 @@ 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 # are running more than one validate bundlescript @@ -18,12 +18,12 @@ if [[ -z "$VALIDATE_UPSTREAM" ]]; then VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD" validate_diff() { - if [[ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]]; then + if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then git diff "$VALIDATE_COMMIT_DIFF" "$@" fi } validate_log() { - if [[ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]]; then + if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then git log "$VALIDATE_COMMIT_LOG" "$@" fi } diff --git a/hack/validate/all b/hack/validate/all index 8e3cbfcd3b..9d95c2d2fd 100755 --- a/hack/validate/all +++ b/hack/validate/all @@ -4,5 +4,5 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. ${SCRIPTDIR}/default -. ${SCRIPTDIR}/vendor +. $SCRIPTDIR/default +. $SCRIPTDIR/vendor diff --git a/hack/validate/changelog-date-descending b/hack/validate/changelog-date-descending index 183da80700..b9c3368ca6 100755 --- a/hack/validate/changelog-date-descending +++ b/hack/validate/changelog-date-descending @@ -2,7 +2,7 @@ changelogFile=${1:-CHANGELOG.md} -if [[ ! -r "$changelogFile" ]]; then +if [ ! -r "$changelogFile" ]; then echo "Unable to read file $changelogFile" >&2 exit 1 fi diff --git a/hack/validate/changelog-well-formed b/hack/validate/changelog-well-formed index fe629c8d08..6c7ce1a1c0 100755 --- a/hack/validate/changelog-well-formed +++ b/hack/validate/changelog-well-formed @@ -2,7 +2,7 @@ changelogFile=${1:-CHANGELOG.md} -if [[ ! -r "$changelogFile" ]]; then +if [ ! -r "$changelogFile" ]; then echo "Unable to read file $changelogFile" >&2 exit 1 fi diff --git a/hack/validate/dco b/hack/validate/dco index 9051562f90..f391001601 100755 --- a/hack/validate/dco +++ b/hack/validate/dco @@ -21,13 +21,13 @@ check_dco() { grep -qE "$dcoRegex" } -if [[ ${adds} -eq 0 && ${dels} -eq 0 ]]; then +if [ $adds -eq 0 -a $dels -eq 0 ]; then echo '0 adds, 0 deletions; nothing to validate! :)' else commits=( $(validate_log --format='format:%H%n') ) badCommits=() 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) continue fi @@ -35,7 +35,7 @@ else badCommits+=( "$commit" ) fi done - if [[ ${#badCommits[@]} -eq 0 ]]; then + if [ ${#badCommits[@]} -eq 0 ]; then echo "Congratulations! All commits are properly signed with the DCO!" else { diff --git a/hack/validate/default b/hack/validate/default index 4ca7e91476..8ec978876d 100755 --- a/hack/validate/default +++ b/hack/validate/default @@ -4,14 +4,14 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -. ${SCRIPTDIR}/dco -. ${SCRIPTDIR}/default-seccomp -. ${SCRIPTDIR}/gometalinter -. ${SCRIPTDIR}/pkg-imports -. ${SCRIPTDIR}/swagger -. ${SCRIPTDIR}/swagger-gen -. ${SCRIPTDIR}/test-imports -. ${SCRIPTDIR}/toml -. ${SCRIPTDIR}/changelog-well-formed -. ${SCRIPTDIR}/changelog-date-descending -. ${SCRIPTDIR}/deprecate-integration-cli +. $SCRIPTDIR/dco +. $SCRIPTDIR/default-seccomp +. $SCRIPTDIR/gometalinter +. $SCRIPTDIR/pkg-imports +. $SCRIPTDIR/swagger +. $SCRIPTDIR/swagger-gen +. $SCRIPTDIR/test-imports +. $SCRIPTDIR/toml +. $SCRIPTDIR/changelog-well-formed +. $SCRIPTDIR/changelog-date-descending +. $SCRIPTDIR/deprecate-integration-cli diff --git a/hack/validate/default-seccomp b/hack/validate/default-seccomp index 328bd9a68e..24cbf00d24 100755 --- a/hack/validate/default-seccomp +++ b/hack/validate/default-seccomp @@ -7,12 +7,12 @@ IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'profiles/seccomp' || true) ) unset IFS -if [[ ${#files[@]} -gt 0 ]]; then +if [ ${#files[@]} -gt 0 ]; then # We run 'go generate' and see if we have a diff afterwards go generate ./profiles/seccomp/ >/dev/null # Let see if the working directory is clean 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 diff --git a/hack/validate/deprecate-integration-cli b/hack/validate/deprecate-integration-cli index d83a2881d7..da6f8310f4 100755 --- a/hack/validate/deprecate-integration-cli +++ b/hack/validate/deprecate-integration-cli @@ -9,7 +9,7 @@ new_tests=$( grep -E '^\+func (.*) Test' || true ) -if [[ -z "$new_tests" ]]; then +if [ -z "$new_tests" ]; then echo 'Congratulations! No new tests added to integration-cli.' exit fi diff --git a/hack/validate/gometalinter b/hack/validate/gometalinter index 0c0ae0d7ee..8f42597fce 100755 --- a/hack/validate/gometalinter +++ b/hack/validate/gometalinter @@ -10,4 +10,4 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" gometalinter \ ${GOMETALINTER_OPTS} \ - --config ${SCRIPTDIR}/gometalinter.json ./... + --config $SCRIPTDIR/gometalinter.json ./... diff --git a/hack/validate/pkg-imports b/hack/validate/pkg-imports index f25d7291e6..a9aab6456f 100755 --- a/hack/validate/pkg-imports +++ b/hack/validate/pkg-imports @@ -19,7 +19,7 @@ for f in "${files[@]}"; do done done -if [[ ${#badFiles[@]} -eq 0 ]]; then +if [ ${#badFiles[@]} -eq 0 ]; then echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' else { diff --git a/hack/validate/swagger b/hack/validate/swagger index 7eae418d18..0b3c2719d8 100755 --- a/hack/validate/swagger +++ b/hack/validate/swagger @@ -7,7 +7,7 @@ IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true) ) unset IFS -if [[ ${#files[@]} -gt 0 ]]; then +if [ ${#files[@]} -gt 0 ]; then yamllint -c ${SCRIPTDIR}/.swagger-yamllint api/swagger.yaml swagger validate api/swagger.yaml fi diff --git a/hack/validate/swagger-gen b/hack/validate/swagger-gen index f678d524dc..07c22b5a62 100755 --- a/hack/validate/swagger-gen +++ b/hack/validate/swagger-gen @@ -7,11 +7,11 @@ IFS=$'\n' files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/types/' 'api/swagger.yaml' || true) ) unset IFS -if [[ ${#files[@]} -gt 0 ]]; then +if [ ${#files[@]} -gt 0 ]; then ${SCRIPTDIR}/../generate-swagger-api.sh 2> /dev/null # Let see if the working directory is clean diffs="$(git diff -- api/types/)" - if [[ "$diffs" ]]; then + if [ "$diffs" ]; then { echo 'The result of hack/generate-swagger-api.sh differs' echo diff --git a/hack/validate/test-imports b/hack/validate/test-imports index 70440749bd..0e836a31c0 100755 --- a/hack/validate/test-imports +++ b/hack/validate/test-imports @@ -11,20 +11,20 @@ unset IFS badFiles=() for f in "${files[@]}"; do # 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 fi # 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 [[ "$(echo $f | grep '_test')" ]]; then + if [ "$(echo $f | grep '_test')" ]; then # allow testing.T for non- _test files badFiles+=( "$f" ) fi fi done -if [[ ${#badFiles[@]} -eq 0 ]]; then +if [ ${#badFiles[@]} -eq 0 ]; then echo 'Congratulations! No testing.T found.' else { diff --git a/hack/validate/toml b/hack/validate/toml index f8ec729f6b..d5b2ce1c29 100755 --- a/hack/validate/toml +++ b/hack/validate/toml @@ -15,7 +15,7 @@ for f in "${files[@]}"; do fi done -if [[ ${#badFiles[@]} -eq 0 ]]; then +if [ ${#badFiles[@]} -eq 0 ]; then echo 'Congratulations! All toml source files changed here have valid syntax.' else { diff --git a/hack/validate/vendor b/hack/validate/vendor index 60cce34112..41676fed53 100755 --- a/hack/validate/vendor +++ b/hack/validate/vendor @@ -8,12 +8,12 @@ validate_vendor_diff(){ files=( $(validate_diff --diff-filter=ACMR --name-only -- 'vendor.conf' 'vendor/' || true) ) unset IFS - if [[ ${#files[@]} -gt 0 ]]; then + if [ ${#files[@]} -gt 0 ]; then # recreate vendor/ vndr # check if any files have changed diffs="$(git status --porcelain -- vendor 2>/dev/null)" - if [[ "$diffs" ]]; then + if [ "$diffs" ]; then { echo 'The result of vndr differs' echo @@ -38,7 +38,7 @@ validate_vendor_used() { for f in $pkgs; do if ls -d vendor/$f > /dev/null 2>&1; then 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" fi else