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

Shell scripts: fix bare variables

This makes my IDE a bit more silent :-)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-01-10 02:50:47 +01:00
parent c3650770cc
commit 37498f009d
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
24 changed files with 65 additions and 66 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/sh
set -e set -e
# DinD: a wrapper script which allows docker to be run inside a docker container. # DinD: a wrapper script which allows docker to be run inside a docker container.

View file

@ -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"
} }

View file

@ -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"
} }

View file

@ -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
} }

View file

@ -26,5 +26,5 @@ if [ ! -f "${dir}/${bin}.installer" ]; then
exit 1 exit 1
fi fi
. $dir/$bin.installer . ${dir}/${bin}.installer
install_$bin "$@" install_${bin} "$@"

View file

@ -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
} }

View file

@ -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"
} }

View file

@ -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"
} }

View file

@ -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"
} }

View file

@ -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" .
} }

View file

@ -148,7 +148,7 @@ 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

View file

@ -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"

View file

@ -67,7 +67,7 @@ if [ "$(go env GOOS)" = "windows" ]; then
[ ! -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

View file

@ -86,8 +86,8 @@ if [ -z "$DOCKER_TEST_HOST" ]; then
--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,7 +97,7 @@ 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"
@ -106,7 +106,7 @@ while ! $TEST_CLIENT_BINARY version &> /dev/null; do
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

View file

@ -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
} }
@ -50,7 +50,7 @@ build_test_suite_binaries() {
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
} }
@ -70,7 +70,7 @@ cleanup_test_suite_binaries() {
} }
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
@ -115,7 +115,7 @@ error_on_leaked_containerd_shims() {
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

View file

@ -2,28 +2,28 @@
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}"
( (
cd "$DEST/linux/${arch}" cd "${DEST}/linux/${arch}"
ln -sf ../../../binary-daemon/* ./ ln -sf ../../../binary-daemon/* ./
) )
echo "Created symlinks:" "$DEST/linux/${arch}/"* echo "Created symlinks:" "${DEST}/linux/${arch}/"*
fi 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
export GOOS=${platform%/*} export GOOS=${platform%/*}
export GOARCH=${platform##*/} export GOARCH=${platform##*/}
echo "Cross building: $DEST" echo "Cross building: ${DEST}"
mkdir -p "$DEST" mkdir -p "${DEST}"
ABS_DEST="$(cd "$DEST" && pwd -P)" ABS_DEST="$(cd "${DEST}" && pwd -P)"
source "${MAKEDIR}/binary-daemon" source "${MAKEDIR}/binary-daemon"
source "${MAKEDIR}/cross-platform-dependent" source "${MAKEDIR}/cross-platform-dependent"

View file

@ -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

View file

@ -35,10 +35,10 @@ 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}

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -21,7 +21,7 @@ check_dco() {
grep -qE "$dcoRegex" grep -qE "$dcoRegex"
} }
if [ $adds -eq 0 -a $dels -eq 0 ]; then if [ ${adds} -eq 0 -a ${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') )

View file

@ -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

View file

@ -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 ./...