mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
d699e3de12
When trying to build with some pretty typical version strings this was
causing failures trying to generate the windows resource file.
The resource file is already gated by an `ifdef` for this var, so
instead of blindly setting based on "VERSION", which can contain some
characters which are incompatible (e.g. 1.2.3.rc.0 will fail due to the
".rc").
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit ce931f28ea
)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
91 lines
2.8 KiB
Bash
91 lines
2.8 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
rm -rf autogen
|
|
|
|
source hack/dockerfile/install/runc.installer
|
|
source hack/dockerfile/install/tini.installer
|
|
source hack/dockerfile/install/containerd.installer
|
|
|
|
cat > dockerversion/version_autogen.go <<DVEOF
|
|
// +build autogen
|
|
|
|
// Package dockerversion is auto-generated at build-time
|
|
package dockerversion
|
|
|
|
// Default build-time variable for library-import.
|
|
// This file is overridden on build with build-time information.
|
|
const (
|
|
GitCommit string = "$GITCOMMIT"
|
|
Version string = "$VERSION"
|
|
BuildTime string = "$BUILDTIME"
|
|
IAmStatic string = "${IAMSTATIC:-true}"
|
|
PlatformName string = "${PLATFORM}"
|
|
ProductName string = "${PRODUCT}"
|
|
DefaultProductLicense string = "${DEFAULT_PRODUCT_LICENSE}"
|
|
)
|
|
|
|
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
|
|
DVEOF
|
|
|
|
cat > dockerversion/version_autogen_unix.go <<DVEOF
|
|
// +build autogen,!windows
|
|
|
|
// Package dockerversion is auto-generated at build-time
|
|
package dockerversion
|
|
|
|
// Default build-time variable for library-import.
|
|
// This file is overridden on build with build-time information.
|
|
const (
|
|
InitCommitID string = "${TINI_COMMIT}"
|
|
)
|
|
|
|
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
|
|
DVEOF
|
|
|
|
# Compile the Windows resources into the sources
|
|
if [ "$(go env GOOS)" = "windows" ]; then
|
|
mkdir -p autogen/winresources/tmp autogen/winresources/docker autogen/winresources/dockerd
|
|
cp hack/make/.resources-windows/resources.go autogen/winresources/docker/
|
|
cp hack/make/.resources-windows/resources.go autogen/winresources/dockerd/
|
|
|
|
if [ "$(go env GOHOSTOS)" == "windows" ]; then
|
|
WINDRES=windres
|
|
WINDMC=windmc
|
|
else
|
|
# Cross compiling
|
|
WINDRES=x86_64-w64-mingw32-windres
|
|
WINDMC=x86_64-w64-mingw32-windmc
|
|
fi
|
|
|
|
# Generate a Windows file version of the form major,minor,patch,build (with any part optional)
|
|
if [ ! -v VERSION_QUAD ]; then
|
|
VERSION_QUAD=$(echo -n $VERSION | sed -re 's/^([0-9.]*).*$/\1/' | tr . ,)
|
|
fi
|
|
|
|
# Pass version and commit information into the resource compiler
|
|
defs=
|
|
[ ! -z $VERSION ] && defs="$defs -D DOCKER_VERSION=\"$VERSION\""
|
|
[ ! -z $VERSION_QUAD ] && defs="$defs -D DOCKER_VERSION_QUAD=$VERSION_QUAD"
|
|
[ ! -z $GITCOMMIT ] && defs="$defs -D DOCKER_COMMIT=\"$GITCOMMIT\""
|
|
|
|
function makeres {
|
|
${WINDRES} \
|
|
-i hack/make/.resources-windows/$1 \
|
|
-o $3 \
|
|
-F $2 \
|
|
--use-temp-file \
|
|
-I autogen/winresources/tmp \
|
|
$defs
|
|
}
|
|
|
|
${WINDMC} \
|
|
hack/make/.resources-windows/event_messages.mc \
|
|
-h autogen/winresources/tmp \
|
|
-r autogen/winresources/tmp
|
|
|
|
makeres docker.rc pe-x86-64 autogen/winresources/docker/rsrc_amd64.syso
|
|
makeres docker.rc pe-i386 autogen/winresources/docker/rsrc_386.syso
|
|
makeres dockerd.rc pe-x86-64 autogen/winresources/dockerd/rsrc_amd64.syso
|
|
|
|
rm -r autogen/winresources/tmp
|
|
fi
|