diff --git a/scripts/build/.variables b/scripts/build/.variables index f29195f142..76b0602f06 100755 --- a/scripts/build/.variables +++ b/scripts/build/.variables @@ -63,23 +63,23 @@ if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then fi export GO_BUILDMODE -LDFLAGS="${LDFLAGS:-} -w" -LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\"" -LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\"" -LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\"" +GO_LDFLAGS="${GO_LDFLAGS:-} -w" +GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\"" +GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\"" +GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\"" if test -n "${PLATFORM}"; then - LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\"" + GO_LDFLAGS="$GO_LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\"" fi if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then - LDFLAGS="$LDFLAGS -extldflags -static" + GO_LDFLAGS="$GO_LDFLAGS -extldflags -static" fi if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ]; then # compiling statically with CGO enabled requires osusergo to be set. GO_BUILDTAGS="$GO_BUILDTAGS osusergo" fi if [ -n "$GO_STRIP" ]; then - LDFLAGS="$LDFLAGS -s" + GO_LDFLAGS="$GO_LDFLAGS -s" fi -export LDFLAGS="$LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064 +export GO_LDFLAGS="$GO_LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064 export SOURCE="github.com/docker/cli/cmd/docker" diff --git a/scripts/build/binary b/scripts/build/binary index 8e3324cf2c..44cd4f14fd 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -24,6 +24,6 @@ if [ "$(go env GOOS)" = "windows" ]; then fi fi -(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}") +(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}") ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker" diff --git a/scripts/build/plugins b/scripts/build/plugins index 10268f54ec..fa78b9536b 100755 --- a/scripts/build/plugins +++ b/scripts/build/plugins @@ -15,5 +15,5 @@ for p in cli-plugins/examples/* "$@" ; do mkdir -p "$(dirname "${TARGET_PLUGIN}")" echo "Building $GO_LINKMODE $(basename "${TARGET_PLUGIN}")" - (set -x ; CGO_ENABLED=0 GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}") + (set -x ; CGO_ENABLED=0 GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${GO_LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}") done