From 6e45f4bfe2d09dffa9d9b97acfe1fef7a33324d1 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Tue, 13 Apr 2021 16:12:01 +0000 Subject: [PATCH 1/3] scripts: fix VERSION_QUAD corner case in windows resource When the git checkout is dirty on top of a git tag (i.e., v20.10.6.m), the VERSION_QUAD was keeping a trailing comma. Now the trailing comma is stripped. Signed-off-by: Tibor Vass --- scripts/build/binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/binary b/scripts/build/binary index e4c5e12a6b..c44c2a9cbe 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -56,7 +56,7 @@ fi if [ "$(go env GOOS)" = "windows" ]; then # Generate a Windows file version of the form major,minor,patch,build - VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . , | sed -re 's/^[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+,[0-9]+$/\0,0/') + VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . , | sed -re 's/,$//' | sed -re 's/^[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+,[0-9]+$/\0,0/') set -- [ -n "$VERSION" ] && set -- "$@" -D "DOCKER_VERSION=\"$VERSION\"" From 2c40960ba1bba39ca7b229a671cf7f8e9a8213a3 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Tue, 13 Apr 2021 16:14:49 +0000 Subject: [PATCH 2/3] scripts: use WINDRES env var if set This allows setting WINDRES to mingw's windres. For the record, mingw's windres needs --use-temp-file for a weird reason: in that case, it keeps preprocessor arguments intact (including quotes), without it, mingw's windres calls popen, which happens to pass the entire command to sh -c, stripping quotes after evaluation and causing a syntax error in mingw's windres. To use mingw's windres, set WINDRES to: - `x86_64-w64-mingw32-windres` on 64 bit - `i686-w64-mingw32-windres` on 32 bit Signed-off-by: Tibor Vass --- scripts/build/binary | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/build/binary b/scripts/build/binary index c44c2a9cbe..7c9626a87e 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -63,11 +63,10 @@ if [ "$(go env GOOS)" = "windows" ]; then [ -n "$VERSION_QUAD" ] && set -- "$@" -D "DOCKER_VERSION_QUAD=$VERSION_QUAD" [ -n "$GITCOMMIT" ] && set -- "$@" -D "DOCKER_COMMIT=\"$GITCOMMIT\"" - windres=$($(go env CC) --print-prog-name=windres) - target="$(dirname "$0")/../../cli/winresources/rsrc_$(go env GOARCH).syso" mkdir -p "$(dirname "${target}")" - "$windres" -i "$(dirname "$0")/../winresources/docker.rc" -o "$target" "$@" + : ${WINDRES:="$($(go env CC) --print-prog-name=windres)"} + "$WINDRES" -i "$(dirname "$0")/../winresources/docker.rc" -o "$target" --use-temp-file "$@" echo "package winresources" > "$(dirname "${target}")/stub_windows.go" fi From 83e9eeb8a08abd04a357c32f5fbf94129f569c71 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Tue, 13 Apr 2021 18:23:52 +0000 Subject: [PATCH 3/3] scripts: Allow skipping windres when WINDRES= (empty string) Signed-off-by: Brian Goff Signed-off-by: Tibor Vass --- scripts/build/binary | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scripts/build/binary b/scripts/build/binary index 7c9626a87e..7d134fc6f5 100755 --- a/scripts/build/binary +++ b/scripts/build/binary @@ -55,19 +55,23 @@ if [ -n "$GO_STRIP" ]; then fi if [ "$(go env GOOS)" = "windows" ]; then - # Generate a Windows file version of the form major,minor,patch,build - VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . , | sed -re 's/,$//' | sed -re 's/^[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+,[0-9]+$/\0,0/') + : "${WINDRES=$($(go env CC) --print-prog-name=windres)}" + if [ -z "$WINDRES" ]; then + >&2 echo "Empty WINDRES detected, skipping manifesting binary" + else + # Generate a Windows file version of the form major,minor,patch,build + VERSION_QUAD=$(printf "%s" "$VERSION" | sed -re 's/^([0-9.]*).*$/\1/' | tr . , | sed -re 's/,$//' | sed -re 's/^[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+$/\0,0/' | sed -re 's/^[0-9]+,[0-9]+,[0-9]+$/\0,0/') - set -- - [ -n "$VERSION" ] && set -- "$@" -D "DOCKER_VERSION=\"$VERSION\"" - [ -n "$VERSION_QUAD" ] && set -- "$@" -D "DOCKER_VERSION_QUAD=$VERSION_QUAD" - [ -n "$GITCOMMIT" ] && set -- "$@" -D "DOCKER_COMMIT=\"$GITCOMMIT\"" + set -- + [ -n "$VERSION" ] && set -- "$@" -D "DOCKER_VERSION=\"$VERSION\"" + [ -n "$VERSION_QUAD" ] && set -- "$@" -D "DOCKER_VERSION_QUAD=$VERSION_QUAD" + [ -n "$GITCOMMIT" ] && set -- "$@" -D "DOCKER_COMMIT=\"$GITCOMMIT\"" - target="$(dirname "$0")/../../cli/winresources/rsrc_$(go env GOARCH).syso" - mkdir -p "$(dirname "${target}")" - : ${WINDRES:="$($(go env CC) --print-prog-name=windres)"} - "$WINDRES" -i "$(dirname "$0")/../winresources/docker.rc" -o "$target" --use-temp-file "$@" - echo "package winresources" > "$(dirname "${target}")/stub_windows.go" + target="$(dirname "$0")/../../cli/winresources/rsrc_$(go env GOARCH).syso" + mkdir -p "$(dirname "${target}")" + "$WINDRES" -i "$(dirname "$0")/../winresources/docker.rc" -o "$target" --use-temp-file "$@" + echo "package winresources" > "$(dirname "${target}")/stub_windows.go" + fi fi echo "Building $GO_LINKMODE $(basename "${TARGET}")"