Bug#819914: imagemagick: please honour SOURCE_DATE_EPOCH

2024-01-05 Thread James Addison
Followup-For: Bug #819914
X-Debbugs-Cc: p...@passoire.fr
Control: forwarded -1 https://github.com/ImageMagick/ImageMagick/pull/1496
Control: tags -1 fixed-upstream
Control: fixed -1 imagemagick/8:6.9.11.24+dfsg-1
Control: close -1

Handling of SOURCE_DATE_EPOCH has been implemented by upstream, and no more
reproducibility failures appear due to imagemagick timestamps in PDFs in the
reproducible build tests[1] (this ref is to unstable, but I've checked all
suites).

(I admit I mentioned PDF there, not postscript -- if I'm mistaken about this
bug being closable, please re-open and let me know)

[1] - 
https://tests.reproducible-builds.org/debian/issues/unstable/timestamps_in_pdf_generated_by_imagemagick_issue.html



Bug#819914: imagemagick: please honour SOURCE_DATE_EPOCH

2016-04-03 Thread Alexis Bienvenüe
Source: imagemagick
Version: 8:6.8.9.9-7
Severity: wishlist
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: toolchain
X-Debbugs-Cc: reproducible-bui...@lists.alioth.debian.org

Dear Maintainer,

While working on the “reproducible builds” effort [1], we have noticed
that some packages (like kannel) use 'convert' in their building
process, resulting in timestamps in postscript files that break
reproducibility.

To solve this kind of issues, it would be nice to have 'convert' support
the SOURCE_DATE_EPOCH environment variable [2].

See the attached patch for a solution to this issue.

Regards,
Alexis Bienvenüe.

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

diff -Nru imagemagick-6.8.9.9/debian/changelog imagemagick-6.8.9.9/debian/changelog
--- imagemagick-6.8.9.9/debian/changelog	2016-01-17 21:45:14.0 +0100
+++ imagemagick-6.8.9.9/debian/changelog	2016-04-01 01:11:37.0 +0200
@@ -1,3 +1,10 @@
+imagemagick (8:6.8.9.9-7.0reproducible1) unstable; urgency=medium
+
+  * Honour the SOURCE_DATE_EPOCH environment variable
+when writing to files.
+
+ -- Alexis Bienvenüe   Fri, 01 Apr 2016 01:11:36 +0200
+
 imagemagick (8:6.8.9.9-7) unstable; urgency=low
 
   * Fix various minor security issues 
diff -Nru imagemagick-6.8.9.9/debian/patches/0076-Honour-SOURCE_DATE_EPOCH-when-writing.patch imagemagick-6.8.9.9/debian/patches/0076-Honour-SOURCE_DATE_EPOCH-when-writing.patch
--- imagemagick-6.8.9.9/debian/patches/0076-Honour-SOURCE_DATE_EPOCH-when-writing.patch	1970-01-01 01:00:00.0 +0100
+++ imagemagick-6.8.9.9/debian/patches/0076-Honour-SOURCE_DATE_EPOCH-when-writing.patch	2016-04-03 15:48:56.0 +0200
@@ -0,0 +1,307 @@
+Description: Honour the SOURCE_DATE_EPOCH variable when writing
+ Honour the SOURCE_DATE_EPOCH environment variable when writing
+ to some files: PS, PDF, PNG, CIN, DPX, MAT, PDB, setting the timestamp
+ to the provided value and using GM time instead of local time.
+Author: Alexis Bienvenüe 
+
+Index: imagemagick-6.8.9.9/coders/cin.c
+===
+--- imagemagick-6.8.9.9.orig/coders/cin.c
 imagemagick-6.8.9.9/coders/cin.c
+@@ -971,14 +971,14 @@ static MagickBooleanType WriteCINImage(c
+   sizeof(cin.file.filename));
+   offset+=WriteBlob(image,sizeof(cin.file.filename),(unsigned char *)
+ cin.file.filename);
+-  seconds=time((time_t *) NULL);
+-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
+-  (void) localtime_r(&seconds,&local_time);
+-#else
+-  (void) memcpy(&local_time,localtime(&seconds),sizeof(local_time));
+-#endif
++  seconds=CurrentTime();
++  (void) LocalOrGMTime(&seconds,&local_time);
+   (void) memset(timestamp,0,sizeof(timestamp));
+-  (void) strftime(timestamp,MaxTextExtent,"%Y:%m:%d:%H:%M:%S%Z",&local_time);
++  if(getenv("SOURCE_DATE_EPOCH")) {
++(void) strftime(timestamp,MaxTextExtent,"%Y:%m:%d:%H:%M:%SUTC",&local_time);
++  } else {
++(void) strftime(timestamp,MaxTextExtent,"%Y:%m:%d:%H:%M:%S%Z",&local_time);
++  }
+   (void) memset(cin.file.create_date,0,sizeof(cin.file.create_date));
+   (void) CopyMagickString(cin.file.create_date,timestamp,11);
+   offset+=WriteBlob(image,sizeof(cin.file.create_date),(unsigned char *)
+@@ -1074,9 +1074,6 @@ static MagickBooleanType WriteCINImage(c
+   sizeof(cin.origination.filename));
+   offset+=WriteBlob(image,sizeof(cin.origination.filename),(unsigned char *)
+ cin.origination.filename);
+-  seconds=time((time_t *) NULL);
+-  (void) memset(timestamp,0,sizeof(timestamp));
+-  (void) strftime(timestamp,MaxTextExtent,"%Y:%m:%d:%H:%M:%S%Z",&local_time);
+   (void) memset(cin.origination.create_date,0,
+ sizeof(cin.origination.create_date));
+   (void) CopyMagickString(cin.origination.create_date,timestamp,11);
+Index: imagemagick-6.8.9.9/coders/dpx.c
+===
+--- imagemagick-6.8.9.9.orig/coders/dpx.c
 imagemagick-6.8.9.9/coders/dpx.c
+@@ -1535,7 +1535,7 @@ static MagickBooleanType WriteDPXImage(c
+ (void) strncpy(dpx.file.filename,value,sizeof(dpx.file.filename)-1);
+   offset+=WriteBlob(image,sizeof(dpx.file.filename),(unsigned char *)
+ dpx.file.filename);
+-  seconds=time((time_t *) NULL);
++  seconds=CurrentTime();
+   (void) FormatMagickTime(seconds,sizeof(dpx.file.timestamp),
+ dpx.file.timestamp);
+   offset+=WriteBlob(image,sizeof(dpx.file.timestamp),(unsigned char *)
+Index: imagemagick-6.8.9.9/coders/mat.c
+===
+--- imagemagick-6.8.9.9.orig/coders/mat.c
 imagemagick-6.8.9.9/coders/mat.c
+@@ -1224,12 +1224,8 @@ static MagickBooleanType WriteMATImage(c
+ return(MagickFalse);
+   image->depth=8;
+ 
+-  current_time=time((time_t *) NULL);
+-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
+-  (void) localtime_r(¤t_time,&local_time);
+-#else
+-  (void) memcpy(&local_time,localtime(¤t_time),sizeof(local_tim