Bug#824668: gmt: please make the build reproducible (timestamps)

2016-05-18 Thread Sebastiaan Couwenberg
On 05/18/2016 06:44 PM, Alexis Bienvenüe wrote:
> Le 18/05/2016 17:36, Bas Couwenberg a écrit :
>> The transition to GDAl 2.1.0 is almost complete (#823335). I'll upload a
>> new GMT revision that includes the upstreamed patch after GDAL 2.1.0 is
>> in testing.
> 
> Great, thanks!

I've also forwarded your patch in the upstream issue for the earlier
patch. They may want to consider it because your solution also works on
Windows.

 http://gmt.soest.hawaii.edu/issues/905

Kind Regards,

Bas

-- 
 GPG Key ID: 4096R/6750F10AE88D4AF1
Fingerprint: 8182 DE41 7056 408D 6146  50D1 6750 F10A E88D 4AF1



Bug#824668: gmt: please make the build reproducible (timestamps)

2016-05-18 Thread Alexis Bienvenüe
Le 18/05/2016 17:36, Bas Couwenberg a écrit :
> The transition to GDAl 2.1.0 is almost complete (#823335). I'll upload a
> new GMT revision that includes the upstreamed patch after GDAL 2.1.0 is
> in testing.

Great, thanks!

Alexis.



Bug#824668: gmt: please make the build reproducible (timestamps)

2016-05-18 Thread Bas Couwenberg

Control: tags -1 pending

Hi Alexis,

Thanks for your patch, unfortunately it's some duplicate work because I 
recently added a similar patch which has been merged upstream:


 
http://anonscm.debian.org/cgit/pkg-grass/gmt.git/tree/debian/patches/source_date_epoch.patch


My patch doesn't bother patching today.c (although the initial version 
did that too), it handles SOURCE_DATE_EPOCH in CMake.


The transition to GDAl 2.1.0 is almost complete (#823335). I'll upload a 
new GMT revision that includes the upstreamed patch after GDAL 2.1.0 is 
in testing.


Kind Regards,

Bas



Bug#824668: gmt: please make the build reproducible (timestamps)

2016-05-18 Thread Alexis Bienvenüe
Source: gmt
Version: 5.2.1+dfsg-5
Severity: wishlist
Tags: patch upstream
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Dear Maintainer,

While working on the `€œreproducible builds'€ effort [1], we have noticed
that 'gmt' could not be built reproducibly.

The attached patch honours the SOURCE_DATE_EPOCH environment
variable [2] to get a reproducible build date from the last
debian changelog entry.
Once applied, gmt can be built reproducibly in our current
experimental framework.

Regards,
Alexis Bienvenüe.

 [1]: https://wiki.debian.org/ReproducibleBuilds
 [2]: https://reproducible-builds.org/specs/source-date-epoch/

Description: Honour SOURCE_DATE_EPOCH
 Honour the SOURCE_DATE_EPOCH environment variable to set the sources
 last modification date.
 See https://reproducible-builds.org/specs/source-date-epoch/
Author: Alexis Bienvenüe 

Index: gmt-5.2.1+dfsg/cmake/modules/today.c
===
--- gmt-5.2.1+dfsg.orig/cmake/modules/today.c
+++ gmt-5.2.1+dfsg/cmake/modules/today.c
@@ -5,18 +5,32 @@
 
 #include 
 #include 
+#include 
 
 #define BUFSIZE 32
 
 int main () {
 	char today_string[BUFSIZE];
 
-	/* obtain current time as time since epoch */
-	time_t clock = time (NULL);
-
-	/* convert time since epoch to calendar time expressed as local time */
-	struct tm *p_time = localtime (&clock);
+	time_t clock;
+struct tm *p_time;
 
+/* See https://reproducible-builds.org/specs/source-date-epoch/ */
+char* source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+if(source_date_epoch) {
+  /* get sources last modification date from environment */
+  clock = strtoull(source_date_epoch, NULL, 10);
+
+  /* Use UTC for reproducibility */
+  p_time = gmtime (&clock);
+} else {
+  /* obtain current time as time since epoch */
+  clock = time (NULL);
+
+  /* convert time since epoch to calendar time expressed as local time */
+  p_time = localtime (&clock);
+}
+
 	/* convert tm object to custom textual representation ;mm;dd;Mmm*/
 	size_t result = strftime(today_string, BUFSIZE, "%Y;%m;%d;%B", p_time);