Skip to contentSkip to conversation

build: use SOURCE_DATE_EPOCH if available to make the build reproducible

PATCH New Michael Olbrich 1 participant 1 message Oct 3, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: use SOURCE_DATE_EPOCH if available to make the build reproducible

The build date is included into the binary. As a result, the binaries change with the build date.
Use SOURCE_DATE_EPOCH[1] if defined. This allows packages to make the build reproducible by setting SOURCE_DATE_EPOCH to a fixed value.

[1] https://reproducible-builds.org/specs/source-date-epoch/

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 96b5df716e4c..bcb4b0704117 100644
@@ -104,7 +104,7 @@ all: keyctl request-key key.dns_resolver
 ###############################################################################
 #RPATH = -Wl,-rpath,$(LIBDIR)
 
-VCPPFLAGS	:= -DPKGBUILD="\"$(shell date -u +%F)\""
+VCPPFLAGS	:= -DPKGBUILD="\"$(shell date $(if $(SOURCE_DATE_EPOCH),--date @$(SOURCE_DATE_EPOCH)) -u +%F)\""
 VCPPFLAGS	+= -DPKGVERSION="\"keyutils-$(VERSION)\""
 VCPPFLAGS	+= -DAPIVERSION="\"libkeyutils-$(APIVERSION)\""
 
Signature · 1 line
2.19.0