enabling reproducible builds

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

Moderators: Flumminator, Zomis

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

enabling reproducible builds

Post by bmwiedemann » Wed Jan 04, 2017 1:28 pm

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: 2657
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: enabling reproducible builds

Post by Holger » Mon Jan 09, 2017 11:19 am

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: 2
Joined: Wed Jan 04, 2017 12:22 pm

Re: enabling reproducible builds

Post by bmwiedemann » Tue Jan 10, 2017 4:19 pm

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: 2657
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: enabling reproducible builds

Post by Holger » Tue Jan 10, 2017 10:29 pm

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: 2657
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Re: [SOLVED] enabling reproducible builds

Post by Holger » Wed Jan 11, 2017 12:20 am

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest