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
# DinD: a wrapper script which allows docker to be run inside a docker container.

View File

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

View File

@ -8,14 +8,13 @@ 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
@ -27,5 +26,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"
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ go build \
$LDFLAGS_STATIC_DOCKER
$DOCKER_LDFLAGS
" \
$GO_PACKAGE
${GO_PACKAGE}
)
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\""
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

View File

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

View File

@ -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
}
@ -50,7 +50,7 @@ build_test_suite_binaries() {
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
}
@ -70,7 +70,7 @@ cleanup_test_suite_binaries() {
}
repeat() {
for i in $(seq 1 $TEST_REPEAT); do
for i in $(seq 1 ${TEST_REPEAT}); do
echo "Running integration-test (iteration $i)"
$@
done
@ -115,7 +115,7 @@ error_on_leaked_containerd_shims() {
awk '$2 == "containerd-shim" && $4 ~ /.*\/bundles\/.*\/test-integration/ { print $1 }')
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

View File

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

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -e
if [ $platform == "windows/amd64" ]; then
if [ ${platform} == "windows/amd64" ]; then
source "${MAKEDIR}/containerutility"
fi

View File

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

View File

@ -8,7 +8,7 @@ source hack/make/.integration-test-helpers
bundle .integration-daemon-start
bundle .integration-daemon-setup
local testexit=0
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"

View File

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

View File

@ -4,5 +4,5 @@
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. $SCRIPTDIR/default
. $SCRIPTDIR/vendor
. ${SCRIPTDIR}/default
. ${SCRIPTDIR}/vendor

View File

@ -21,7 +21,7 @@ check_dco() {
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! :)'
else
commits=( $(validate_log --format='format:%H%n') )

View File

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

View File

@ -10,4 +10,4 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
gometalinter \
${GOMETALINTER_OPTS} \
--config $SCRIPTDIR/gometalinter.json ./...
--config ${SCRIPTDIR}/gometalinter.json ./...