Source: herbstluftwm
Version: 0.7.0-1
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi!

While working on the "reproducible builds" effort [1], we have noticed
that herbstluftwm could not be built reproducibly.

The attached patch attempts to make the build reproducible by
referring to the SOURCE_DATE_EPOCH environment variable [2] for
deterministic timestamps instead of using the current system time.
However, a fallback is also provided in case SOURCE_DATE_EPOCH is not
set.

Regards,
Fabian Wolff

[1] https://wiki.debian.org/ReproducibleBuilds
[2] https://reproducible-builds.org/specs/source-date-epoch/
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,15 @@
 HERBSTLUFTWMDOC = doc/herbstluftwm.txt
 TUTORIAL = doc/herbstluftwm-tutorial.txt
 
+DATE_FMT = %Y-%m-%d
+ifdef SOURCE_DATE_EPOCH
+    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 || date -u "+$(DATE_FMT)")
+else
+    BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
+endif
+
+export CPPFLAGS += -DBUILD_DATE="\"$(BUILD_DATE)\""
+
 .PHONY: depend all all-nodoc doc install install-nodoc info www
 .PHONY: cleandoc cleanwww cleandeps clean
 
@@ -93,7 +102,7 @@
 
 doc/%.1 doc/%.7: doc/%.txt version.mk
 	$(call colorecho,DOC,$@)
-	$(VERBOSE) $(A2X) -f manpage -a "herbstluftwmversion=herbstluftwm $(VERSION)" -a "date=`date +%Y-%m-%d`" $<
+	$(VERBOSE) $(A2X) -f manpage -a "herbstluftwmversion=herbstluftwm $(VERSION)" -a "date=$(BUILD_DATE)" $<
 
 doc/%.html: doc/%.txt version.mk
 	$(call colorecho,DOC,$@)
--- a/ipc-client/main.c
+++ b/ipc-client/main.c
@@ -17,7 +17,7 @@
 #include "client-utils.h"
 
 #define HERBSTCLIENT_VERSION_STRING \
-    "herbstclient " HERBSTLUFT_VERSION " (built on " __DATE__ ")\n"
+    "herbstclient " HERBSTLUFT_VERSION " (built on " BUILD_DATE ")\n"
 
 void print_help(char* command, FILE* file);
 void init_hook_regex(int argc, char* argv[]);
--- a/src/globals.h
+++ b/src/globals.h
@@ -12,7 +12,7 @@
 #define HERBSTLUFT_AUTOSTART "herbstluftwm/autostart"
 #define WINDOW_MANAGER_NAME "herbstluftwm"
 #define HERBSTLUFT_VERSION_STRING \
-    WINDOW_MANAGER_NAME " " HERBSTLUFT_VERSION " (built on " __DATE__ ")"
+    WINDOW_MANAGER_NAME " " HERBSTLUFT_VERSION " (built on " BUILD_DATE ")"
 
 #define HERBST_FRAME_CLASS "_HERBST_FRAME"
 #define HERBST_DECORATION_CLASS "_HERBST_DECORATION"
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to