2018-12-10 10:30:19 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
2021-11-17 11:18:15 -05:00
|
|
|
# Build plugins examples for the host OS/ARCH
|
2018-12-10 10:30:19 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
source ./scripts/build/.variables
|
|
|
|
|
2018-12-11 09:15:04 -05:00
|
|
|
for p in cli-plugins/examples/* "$@" ; do
|
2018-12-10 10:30:19 -05:00
|
|
|
[ -d "$p" ] || continue
|
|
|
|
|
|
|
|
n=$(basename "$p")
|
2021-11-17 11:18:15 -05:00
|
|
|
TARGET_PLUGIN="$(dirname "${TARGET}")/plugins-${GOOS}-${GOARCH}/docker-${n}"
|
|
|
|
mkdir -p "$(dirname "${TARGET_PLUGIN}")"
|
2018-12-10 10:30:19 -05:00
|
|
|
|
2021-11-17 11:18:15 -05:00
|
|
|
echo "Building $GO_LINKMODE $(basename "${TARGET_PLUGIN}")"
|
use GO_LDFLAGS instead of LDFLAGS to prevent inheriting unrelated options
When building on Fedora 36, the build failed. I suspect this is because the
rpm tools also set LDFLAGS, but with options that cannot be used;
GO_LINKMODE=dynamic
+ ./scripts/build/binary
/go/src/github.com/docker/cli ~/rpmbuild/BUILD/src
Building dynamic docker-linux-arm64
+ go build -o build/docker-linux-arm64 -tags ' pkcs11' -ldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dT,/root/rpmbuild/BUILD/src/.package_note-docker-ce-cli-0.0.0.20220330082637.68cad50-0.fc36.aarch64.ld -w -X "github.com/docker/cli/cli/version.GitCommit=68cad50" -X "github.com/docker/cli/cli/version.BuildTime=2022-03-30T20:05:36Z" -X "github.com/docker/cli/cli/version.Version=0.0.0-20220330082637-68cad50" -X "github.com/docker/cli/cli/version.PlatformName=Docker Engine - Community"' -buildmode=pie github.com/docker/cli/cmd/docker
# github.com/docker/cli/cmd/docker
flag provided but not defined: -Wl,-z,relro
usage: link [options] main.o
This patch changes the variable we use to `GO_LDFLAGS`, taking a similar approach
as containerd, and various other projects using this name: https://grep.app/search?q=GO_LDFLAGS
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-03-31 04:30:56 -04:00
|
|
|
(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}")
|
2018-12-10 10:30:19 -05:00
|
|
|
done
|