From 7541baff87e47ff4e98b06ef5c7b2dbb5ab8fa23 Mon Sep 17 00:00:00 2001 From: Matt <33697686+mttradebyte@users.noreply.github.com> Date: Tue, 6 Sep 2022 13:24:06 +0100 Subject: [PATCH] Make build script compatible with older gzip (#11256) * Add RHEL7 compatibility for gzip options Signed-off-by: Matthew Themis Signed-off-by: Matt <33697686+mttradebyte@users.noreply.github.com> Co-authored-by: Julien Pivotto --- scripts/compress_assets.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/compress_assets.sh b/scripts/compress_assets.sh index 58486089e..615e30c43 100755 --- a/scripts/compress_assets.sh +++ b/scripts/compress_assets.sh @@ -6,6 +6,11 @@ set -euo pipefail cd web/ui cp embed.go.tmpl embed.go + +GZIP_OPTS="-fk" +# gzip option '-k' may not always exist in the latest gzip available on different distros. +if ! gzip -k -h &>/dev/null; then GZIP_OPTS="-f"; fi + find static -type f -name '*.gz' -delete -find static -type f -exec gzip -fk '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go +find static -type f -exec gzip $GZIP_OPTS '{}' \; -print0 | xargs -0 -I % echo %.gz | xargs echo //go:embed >> embed.go echo var EmbedFS embed.FS >> embed.go