mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
71e2aa78e4
The script to build (static)binaries also generated checksums for all binaries and scripts included. These checksums were not used, and not included when releasing packages (which are a `tar.gz` for which a separate checksum would be generated). Removing these checksums, as they're unused, and complicated using these artifacts for packagers (who would have to exclude them after building). Before this: ```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 ``` After this: ```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 ├── ctr ├── docker-init ├── docker-proxy ├── dockerd ├── dockerd-rootless-setuptool.sh ├── dockerd-rootless.sh ├── rootlesskit ├── rootlesskit-docker-proxy ├── runc └── vpnkit 1 directory, 12 files ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
96 lines
2.5 KiB
Bash
96 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# a helper to provide ".exe" when it's appropriate
|
|
binary_extension() {
|
|
if [ "$(go env GOOS)" = 'windows' ]; then
|
|
echo -n '.exe'
|
|
fi
|
|
}
|
|
|
|
BINARY_EXTENSION="$(binary_extension)"
|
|
BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
|
|
|
|
source "${MAKEDIR}/.go-autogen"
|
|
|
|
(
|
|
export GOGC=${DOCKER_BUILD_GOGC:-1000}
|
|
|
|
if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
|
|
# must be cross-compiling!
|
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
|
windows/amd64)
|
|
export CC="${CC:-x86_64-w64-mingw32-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
linux/arm)
|
|
case "${GOARM}" in
|
|
5)
|
|
export CC="${CC:-arm-linux-gnueabi-gcc}"
|
|
export CGO_ENABLED=1
|
|
export CGO_CFLAGS="-march=armv5t"
|
|
export CGO_CXXFLAGS="-march=armv5t"
|
|
;;
|
|
6)
|
|
export CC="${CC:-arm-linux-gnueabi-gcc}"
|
|
export CGO_ENABLED=1
|
|
export CGO_CFLAGS="-march=armv6"
|
|
export CGO_CXXFLAGS="-march=armv6"
|
|
;;
|
|
7)
|
|
export CC="${CC:-arm-linux-gnueabihf-gcc}"
|
|
export CGO_ENABLED=1
|
|
export CGO_CFLAGS="-march=armv7-a"
|
|
export CGO_CXXFLAGS="-march=armv7-a"
|
|
;;
|
|
*)
|
|
export CC="${CC:-arm-linux-gnueabihf-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
esac
|
|
;;
|
|
linux/arm64)
|
|
export CC="${CC:-aarch64-linux-gnu-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
linux/amd64)
|
|
export CC="${CC:-x86_64-linux-gnu-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
linux/ppc64le)
|
|
export CC="${CC:-powerpc64le-linux-gnu-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
linux/s390x)
|
|
export CC="${CC:-s390x-linux-gnu-gcc}"
|
|
export CGO_ENABLED=1
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# -buildmode=pie is not supported on Windows and Linux on mips, riscv64 and ppc64be.
|
|
# https://github.com/golang/go/blob/77aa209b386a184e7f4b44938f2a05a1b5c5a3cf/src/cmd/internal/sys/supported.go#L89-L99
|
|
case "$(go env GOOS)/$(go env GOARCH)" in
|
|
windows/* | linux/mips* | linux/riscv* | linux/ppc64) ;;
|
|
# TODO remove windows in Go 1.15+: https://github.com/golang/go/commit/95f382139043059a2a0780ba577b53893408f7e4
|
|
# TODO remove riscv64 in Go 1.16+: https://github.com/golang/go/commit/8eb846fd37eb7bded8a1cf6932be2c59069863e5
|
|
|
|
*)
|
|
BUILDFLAGS+=("-buildmode=pie")
|
|
;;
|
|
esac
|
|
|
|
echo "Building: $DEST/$BINARY_FULLNAME"
|
|
echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""
|
|
go build \
|
|
-o "$DEST/$BINARY_FULLNAME" \
|
|
"${BUILDFLAGS[@]}" \
|
|
-ldflags "
|
|
$LDFLAGS
|
|
$LDFLAGS_STATIC_DOCKER
|
|
$DOCKER_LDFLAGS
|
|
" \
|
|
${GO_PACKAGE}
|
|
)
|
|
|
|
echo "Created binary: $DEST/$BINARY_FULLNAME"
|