enabling reproducible builds

Found a bug in R'n'D? Report it here!

Moderators: Flumminator, Zomis

Post Reply
bmwiedemann
Posts: 3
Joined: Wed Jan 04, 2017 12:22 pm

enabling reproducible builds

Post by bmwiedemann »

For enabling reproducible builds of rnd in openSUSE I made two versions of a simple patch
would be nice if you could merge one of those.

Code: Select all


Index: rnd_jue-3.3.0.0/src/Makefile
===================================================================
--- rnd_jue-3.3.0.0.orig/src/Makefile
+++ rnd_jue-3.3.0.0/src/Makefile
@@ -285,7 +285,7 @@ conf_mus.h: conf_mus.c
        @$(MAKE) auto-conf
 
 $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
-       @date '+"%Y-%m-%d %H:%M"' \
+       @date --date=@$${SOURCE_DATE_EPOCH:-$$(date +%s)} '+"%Y-%m-%d %H:%M"' \
        | sed -e 's/^/#define COMPILE_DATE_STRING /' \
        > $(TIMESTAMP_FILE)
 

Code: Select all

Index: rocksndiamonds-3.3.1.2/src/Makefile
===================================================================
--- rocksndiamonds-3.3.1.2.orig/src/Makefile
+++ rocksndiamonds-3.3.1.2/src/Makefile
@@ -291,7 +291,7 @@ conf_mus.h: conf_mus.c
        @$(MAKE) auto-conf
 
 $(TIMESTAMP_FILE): $(SRCS) $(LIBGAME) $(GAME_EM) $(GAME_SP)
-       @date '+"%Y-%m-%d %H:%M"' \
+       @date -r ../ChangeLog '+"%Y-%m-%d %H:%M"' \
        | sed -e 's/^/#define COMPILE_DATE_STRING /' \
        > $(TIMESTAMP_FILE)
 

User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: enabling reproducible builds

Post by Holger »

Yes, this is indeed a perfectly valid request I already thought about by myself. (And, BTW, great resource you've linked!)

I'm just working at a similar, but slightly different approach to solve this issue, as the two suggestions/patches do not work as best as they could, I think: The first one does not work with the "date" command on BSD style systems (like Mac OS X) (because it needs the "-r" option instead of the "-d/--date" option), and the second one (besides also not working with BSD "date") has the problem that the "ChangeLog" file is not really updated anymore since I switched over to Git, so its file date is no good indicator for the source date anymore (and Git may break it anyway when changing branches, updating it to the current time).

So I've implemented the following approach now:
- use SOURCE_DATE_EPOCH, if it is defined,
- else use the last Git commit date, if there is a ".git" directory and no modified files exist,
- else use the current date (so this is more or less for development only).

I've also changed the text on the "version" screen from "compile time" to "source date" accordingly.

The change will be pushed to the Git repo in the next few days.
bmwiedemann
Posts: 3
Joined: Wed Jan 04, 2017 12:22 pm

Re: enabling reproducible builds

Post by bmwiedemann »

Thanks for your efforts. Should be fine.

For us the ChangeLog approach would also have worked, because the timestamp is fixed in the release tarball.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: enabling reproducible builds

Post by Holger »

For us the ChangeLog approach would also have worked, because the timestamp is fixed in the release tarball.
Yes, for the purpose of reproducible builds this would work just fine, too, but as an indicator of the source date it wouldn't work that well then. So the fix should solve both problems now.

Just pushed it to the Git repo, and should be in the next release version 4.0.0.1 soon.
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: [SOLVED] enabling reproducible builds

Post by Holger »

Just released version 4.0.0.1 with that change, but encountered the following problem with it:

When (repeatedly) doing "make clean && make", I always get the exact same file "src/conftime.h" with the last Git commit timestamp as follows:

Code: Select all

#define SOURCE_DATE_STRING "2017-01-10 20:57"
But my build script that just created the packages for the various platforms effectively created files with the current compile time again. :-/

I haven't debugged this yet, but could you please check if it works or not with your own build/packaging environment?
bmwiedemann
Posts: 3
Joined: Wed Jan 04, 2017 12:22 pm

Re: enabling reproducible builds

Post by bmwiedemann »

I finally got around to test 4.1.0.0 and can tell that it builds reproducibly for openSUSE.
Also submitted the version update in https://build.opensuse.org/request/show/624662
Post Reply