Skip to content

Commit eb57463

Browse files
author
Cornelius Weig
committed
Enable repeatable builds
See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This date call works with various variants of date.
1 parent 05a1a57 commit eb57463

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ CHECKSUMS += $(BUNDLE).sha256
3434

3535
VERSION_PACKAGE := $(REPOPATH)/pkg/ketall/version
3636

37+
DATE_FMT = %Y-%m-%dT%H:%M:%SZ
38+
ifdef SOURCE_DATE_EPOCH
39+
# GNU and BSD date require different options for a fixed date
40+
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null)
41+
else
42+
BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
43+
endif
3744
GO_LDFLAGS :="-s -w
3845
GO_LDFLAGS += -X $(VERSION_PACKAGE).version=$(VERSION)
39-
GO_LDFLAGS += -X $(VERSION_PACKAGE).buildDate=$(shell date +'%Y-%m-%dT%H:%M:%SZ')
46+
GO_LDFLAGS += -X $(VERSION_PACKAGE).buildDate=$(BUILD_DATE)
4047
GO_LDFLAGS += -X $(VERSION_PACKAGE).gitCommit=$(COMMIT)
4148
GO_LDFLAGS +="
4249

0 commit comments

Comments
 (0)