From 8814f3801a896020c145d1c4dd13147a042ddaa2 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Mon, 16 Dec 2024 16:56:10 +0100 Subject: [PATCH] Don't print errors when building without git Suppress the error messages when the git commands fail. Add a somewhat meaningful fallback for VERSION when git describe fails. Signed-off-by: Tom Wieczorek --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e00342a8972a..a7e7c5d04f64 100644 --- a/Makefile +++ b/Makefile @@ -45,14 +45,14 @@ BUILD_CGO_CFLAGS := BUILD_GO_LDFLAGS_EXTRA := DEBUG ?= false -VERSION ?= $(shell git describe --tags) +VERSION ?= $(shell git describe --tags 2>/dev/null || printf v%s-dev+k0s '$(kubernetes_version)') ifeq ($(DEBUG), false) LD_FLAGS ?= -w -s endif # https://reproducible-builds.org/docs/source-date-epoch/#makefile # https://reproducible-builds.org/docs/source-date-epoch/#git -SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct || date -u +%s) +SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct 2>/dev/null || date -u +%s) BUILD_DATE_FMT = %Y-%m-%dT%H:%M:%SZ BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(BUILD_DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(BUILD_DATE_FMT)" 2>/dev/null || date -u "+$(BUILD_DATE_FMT)")