Source: tree-puzzle
Version: 5.3~rc16+dfsg-1
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0] we noticed that
tree-puzzle could not be built reproducibly.

Patch attached that omits a number of timestamps and timing
information during the build, whilst retaining them at runtime.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      la...@debian.org / chris-lamb.co.uk
       `-
--- a/debian/patches/reproducible-build.patch   1970-01-01 01:00:00.000000000 
+0100
--- b/debian/patches/reproducible-build.patch   2020-05-15 10:04:43.856783106 
+0100
@@ -0,0 +1,88 @@
+Description: Make the build reproducible
+Author: Chris Lamb <la...@debian.org>
+Last-Update: 2020-05-15
+
+--- tree-puzzle-5.3~rc16+dfsg.orig/src/puzzle1.c
++++ tree-puzzle-5.3~rc16+dfsg/src/puzzle1.c
+@@ -3204,7 +3204,9 @@ void initeps(FILE *ofp)
+               fprintf(ofp, "%%%%Creator: %s (version %s%s)\n", PACKAGE, 
VERSION, ALPHA);
+ #     endif
+       fprintf(ofp, "%%%%Title: Likelihood Mapping Analysis\n");
+-      fprintf(ofp, "%%%%CreationDate: %s", asctime(localtime(&Starttime)) );
++      if (getenv("SOURCE_DATE_EPOCH") == NULL) {
++              fprintf(ofp, "%%%%CreationDate: %s", 
asctime(localtime(&Starttime)) );
++      }
+       fprintf(ofp, "%%%%DocumentFonts: Helvetica\n");
+       fprintf(ofp, "%%%%DocumentNeededFonts: Helvetica\n");
+       fprintf(ofp, "%%%%EndComments\n");
+@@ -3826,6 +3828,10 @@ void timestamp(FILE* ofp)
+       timespan = difftime(Stoptime, Starttime);
+       cpuspan  = ((double) (Stopcpu - Startcpu) / CLOCKS_PER_SEC);
+       fprintf(ofp, "\n\nTIME STAMP\n\n");
++      if (getenv("SOURCE_DATE_EPOCH") != NULL) {
++              fprintf(ofp, "Date and time: (reproducible build)");
++              return;
++      }
+       fprintf(ofp, "Date and time: %s", asctime(localtime(&Starttime)) );
+       fprintf(ofp, "Runtime (excl. input) : %.0f seconds (= %.1f minutes = 
%.1f hours)\n",
+               timespan, timespan/60., timespan/3600.);
+@@ -8924,33 +8930,35 @@ fprintf(stderr, "PPP1: %d (%s:%d)\n", PP
+               fprintftimespan(stdout, PStepStoptime, Stoptime, Starttime, 
"Pstep -> end");
+ #     endif /* DEBUG_PRINTTIMES */
+ 
+-      /* runtime message */
+-      fprintf(STDOUT,
+-              "The parameter estimation took %.2f seconds (= %.2f minutes = 
%.2f hours)\n",
+-                      difftime(PEstStoptime, PEstStarttime), 
difftime(PEstStoptime, PEstStarttime)/60.,
+-                      difftime(PEstStoptime, PEstStarttime)/3600.);
+-      if (puzzlemode == QUARTPUZ && typ_optn == TREERECON_OPTN) {
++      if (getenv("SOURCE_DATE_EPOCH") == NULL) {
++              /* runtime message */
+               fprintf(STDOUT,
+-                      "The ML step took              %.2f seconds (= %.2f 
minutes = %.2f hours)\n",
+-                              difftime(MLstepStoptime, MLstepStarttime), 
difftime(MLstepStoptime, MLstepStarttime)/60.,
+-                              difftime(MLstepStoptime, 
MLstepStarttime)/3600.);
+-              fprintf(STDOUT,
+-                      "The puzzling step took        %.2f seconds (= %.2f 
minutes = %.2f hours)\n",
+-                              difftime(PStepStoptime, PStepStarttime), 
difftime(PStepStoptime, PStepStarttime)/60.,
+-                              difftime(PStepStoptime, PStepStarttime)/3600.);
+-      }
+-      fprintf(STDOUT, 
+-              "The computation took %.2f seconds (= %.2f minutes = %.2f 
hours)\n",
+-                      difftime(Stoptime, Starttime), difftime(Stoptime, 
Starttime)/60.,
+-                      difftime(Stoptime, Starttime)/3600.);
+-      fprintf(STDOUT, 
+-              "     including input %.2f seconds (= %.2f minutes = %.2f 
hours)\n",
+-                      fulltime, fulltime/60., fulltime/3600.);
++                      "The parameter estimation took %.2f seconds (= %.2f 
minutes = %.2f hours)\n",
++                              difftime(PEstStoptime, PEstStarttime), 
difftime(PEstStoptime, PEstStarttime)/60.,
++                              difftime(PEstStoptime, PEstStarttime)/3600.);
++              if (puzzlemode == QUARTPUZ && typ_optn == TREERECON_OPTN) {
++                      fprintf(STDOUT,
++                              "The ML step took              %.2f seconds (= 
%.2f minutes = %.2f hours)\n",
++                                      difftime(MLstepStoptime, 
MLstepStarttime), difftime(MLstepStoptime, MLstepStarttime)/60.,
++                                      difftime(MLstepStoptime, 
MLstepStarttime)/3600.);
++                      fprintf(STDOUT,
++                              "The puzzling step took        %.2f seconds (= 
%.2f minutes = %.2f hours)\n",
++                                      difftime(PStepStoptime, 
PStepStarttime), difftime(PStepStoptime, PStepStarttime)/60.,
++                                      difftime(PStepStoptime, 
PStepStarttime)/3600.);
++              }
++              fprintf(STDOUT, 
++                      "The computation took %.2f seconds (= %.2f minutes = 
%.2f hours)\n",
++                              difftime(Stoptime, Starttime), 
difftime(Stoptime, Starttime)/60.,
++                              difftime(Stoptime, Starttime)/3600.);
++              fprintf(STDOUT, 
++                      "     including input %.2f seconds (= %.2f minutes = 
%.2f hours)\n",
++                              fulltime, fulltime/60., fulltime/3600.);
+ #ifdef TIMEDEBUG
+-      fprintf(STDOUT, 
+-              "and %.0f seconds CPU time (= %.2f minutes = %.2f hours)\n\n",
+-                      fullcpu, fullcpu/60., fullcpu/3600.);
++              fprintf(STDOUT, 
++                      "and %.0f seconds CPU time (= %.2f minutes = %.2f 
hours)\n\n",
++                              fullcpu, fullcpu/60., fullcpu/3600.);
+ #endif /* TIMEDEBUG */
++      }
+ 
+       /* free memory */
+       memcleanup();
--- a/debian/patches/series     2020-05-15 09:38:09.193050479 +0100
--- b/debian/patches/series     2020-05-15 09:44:49.247986506 +0100
@@ -3,3 +3,4 @@
 spelling.patch
 fix-mpi3-build.patch
 update_test_results.patch
+reproducible-build.patch

Reply via email to