moby--moby/hack/make/cross

38 lines
940 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -e
# if we have our linux/amd64 version compiled, let's symlink it in
hack: remove version from binaries, and remove symlinks There may have been some historic reason for doing this, but I couldn't find a practical use for building the (some) binaries with a version (default: "dev") included, only to use a symlink to refer to the actual binary. This patch removes the "${VERSION}" from the binary names in bundles, and removes the code that created symlinks for them. Before this patch: ```bash rm -rf ./bundles docker buildx build --build-arg VERSION=22.06.0-beta.1 --output ./bundles --target binary . tree bundles bundles └── binary-daemon ├── containerd ├── containerd-shim-runc-v2 ├── containerd-shim-runc-v2.md5 ├── containerd-shim-runc-v2.sha256 ├── containerd.md5 ├── containerd.sha256 ├── ctr ├── ctr.md5 ├── ctr.sha256 ├── docker-init ├── docker-init.md5 ├── docker-init.sha256 ├── docker-proxy -> docker-proxy-22.06.0-beta.1 ├── docker-proxy-22.06.0-beta.1 ├── docker-proxy-22.06.0-beta.1.md5 ├── docker-proxy-22.06.0-beta.1.sha256 ├── dockerd -> dockerd-22.06.0-beta.1 ├── dockerd-22.06.0-beta.1 ├── dockerd-22.06.0-beta.1.md5 ├── dockerd-22.06.0-beta.1.sha256 ├── dockerd-rootless-setuptool.sh ├── dockerd-rootless-setuptool.sh.md5 ├── dockerd-rootless-setuptool.sh.sha256 ├── dockerd-rootless.sh ├── dockerd-rootless.sh.md5 ├── dockerd-rootless.sh.sha256 ├── rootlesskit ├── rootlesskit-docker-proxy ├── rootlesskit-docker-proxy.md5 ├── rootlesskit-docker-proxy.sha256 ├── rootlesskit.md5 ├── rootlesskit.sha256 ├── runc ├── runc.md5 ├── runc.sha256 ├── vpnkit ├── vpnkit.md5 └── vpnkit.sha256 1 directory, 38 files ``` After this patch: ```bash rm -rf ./bundles docker buildx build --build-arg VERSION=22.06.0-beta.1 --output ./bundles --target binary . tree bundles bundles └── binary-daemon ├── containerd ├── containerd-shim-runc-v2 ├── containerd-shim-runc-v2.md5 ├── containerd-shim-runc-v2.sha256 ├── containerd.md5 ├── containerd.sha256 ├── ctr ├── ctr.md5 ├── ctr.sha256 ├── docker-init ├── docker-init.md5 ├── docker-init.sha256 ├── docker-proxy ├── docker-proxy.md5 ├── docker-proxy.sha256 ├── dockerd ├── dockerd-rootless-setuptool.sh ├── dockerd-rootless-setuptool.sh.md5 ├── dockerd-rootless-setuptool.sh.sha256 ├── dockerd-rootless.sh ├── dockerd-rootless.sh.md5 ├── dockerd-rootless.sh.sha256 ├── dockerd.md5 ├── dockerd.sha256 ├── rootlesskit ├── rootlesskit-docker-proxy ├── rootlesskit-docker-proxy.md5 ├── rootlesskit-docker-proxy.sha256 ├── rootlesskit.md5 ├── rootlesskit.sha256 ├── runc ├── runc.md5 ├── runc.sha256 ├── vpnkit ├── vpnkit.md5 └── vpnkit.sha256 1 directory, 36 files ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-02 14:57:51 +00:00
if [ -x "${DEST}/../binary-daemon/dockerd" ]; then
arch=$(go env GOHOSTARCH)
mkdir -p "$DEST/linux/${arch}"
(
cd "${DEST}/linux/${arch}"
ln -sf ../../../binary-daemon/* ./
)
echo "Created symlinks:" "${DEST}/linux/${arch}/"*
fi
DOCKER_CROSSPLATFORMS=${DOCKER_CROSSPLATFORMS:-"linux/amd64 windows/amd64 linux/ppc64le linux/s390x"}
for platform in ${DOCKER_CROSSPLATFORMS}; do
(
export KEEPDEST=1
export DEST="${DEST}/${platform}" # bundles/VERSION/cross/GOOS/GOARCH/docker-VERSION
export GOOS=${platform%%/*}
export GOARCH=${platform#*/}
if [[ "${GOARCH}" = "arm/"* ]]; then
GOARM=${GOARCH##*/v}
GOARCH=${GOARCH%/v*}
export GOARM
fi
echo "Cross building: ${DEST}"
mkdir -p "${DEST}"
ABS_DEST="$(cd "${DEST}" && pwd -P)"
source "${MAKEDIR}/binary"
source "${MAKEDIR}/cross-platform-dependent"
)
done