Source: asciidoctor
Version: 1.5.4-1
Severity: wishlist
Tags: patch upstream
User: reproducible-builds@lists.alioth.debian.org
Usertags: toolchain
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Dear Maintainer,

While working on the “reproducible builds” effort [1], we have noticed
that several packages (like ruby-build) use asciidoctor in their
building process, resulting in timestamps in man files that break
reproducibility.

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

See the attached patch for a proposed solution.

Regards,
Alexis Bienvenüe.

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


diff -Nru asciidoctor-1.5.4/debian/changelog asciidoctor-1.5.4/debian/changelog
--- asciidoctor-1.5.4/debian/changelog	2016-02-29 20:11:19.000000000 +0100
+++ asciidoctor-1.5.4/debian/changelog	2016-04-08 11:20:04.000000000 +0200
@@ -1,3 +1,10 @@
+asciidoctor (1.5.4-1.0~reproducible1) unstable; urgency=medium
+
+  * Honour SOURCE_DATE_EPOCH to make build of packages using ronn
+    reproducible.
+
+ -- Alexis Bienvenüe <p...@passoire.fr>  Fri, 08 Apr 2016 11:20:04 +0200
+
 asciidoctor (1.5.4-1) unstable; urgency=medium
 
   * Team upload
diff -Nru asciidoctor-1.5.4/debian/patches/honour_SOURCE_DATE_EPOCH.patch asciidoctor-1.5.4/debian/patches/honour_SOURCE_DATE_EPOCH.patch
--- asciidoctor-1.5.4/debian/patches/honour_SOURCE_DATE_EPOCH.patch	1970-01-01 01:00:00.000000000 +0100
+++ asciidoctor-1.5.4/debian/patches/honour_SOURCE_DATE_EPOCH.patch	2016-04-08 12:14:52.000000000 +0200
@@ -0,0 +1,40 @@
+Description: Honour the SOURCE_DATE_EPOCH environment variable
+ Honour the SOURCE_DATE_EPOCH environment variable, so that output documents'
+ timestamp is set to last debian/changelog entry when building packages that
+ use asciidoctor in their building process.
+Author: Alexis Bienvenüe <p...@passoire.fr>
+
+Index: asciidoctor-1.5.4/lib/asciidoctor/document.rb
+===================================================================
+--- asciidoctor-1.5.4.orig/lib/asciidoctor/document.rb
++++ asciidoctor-1.5.4/lib/asciidoctor/document.rb
+@@ -401,7 +401,11 @@ class Document < AbstractBlock
+       #attrs['infile'] = attrs['docfile']
+ 
+       # dynamic intrinstic attribute values
+-      now = ::Time.now
++      if ENV['SOURCE_DATE_EPOCH'].nil?
++        now = ::Time.now
++      else
++        now = ::Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
++      end
+       localdate = (attrs['localdate'] ||= now.strftime('%Y-%m-%d'))
+       unless (localtime = attrs['localtime'])
+         begin
+Index: asciidoctor-1.5.4/lib/asciidoctor.rb
+===================================================================
+--- asciidoctor-1.5.4.orig/lib/asciidoctor.rb
++++ asciidoctor-1.5.4/lib/asciidoctor.rb
+@@ -1308,7 +1308,11 @@ module Asciidoctor
+     if ::File === input
+       # TODO cli checks if input path can be read and is file, but might want to add check to API
+       input_path = ::File.expand_path input.path
+-      input_mtime = input.mtime
++      if ENV['SOURCE_DATE_EPOCH'].nil?
++        input_mtime = input.mtime
++      else
++        input_mtime = ::Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
++      end
+       lines = input.readlines
+       # hold off on setting infile and indir until we get a better sense of their purpose
+       attributes['docfile'] = input_path
diff -Nru asciidoctor-1.5.4/debian/patches/series asciidoctor-1.5.4/debian/patches/series
--- asciidoctor-1.5.4/debian/patches/series	2016-02-29 19:48:47.000000000 +0100
+++ asciidoctor-1.5.4/debian/patches/series	2016-04-08 11:18:11.000000000 +0200
@@ -3,3 +3,4 @@
 skip-asciimath-test.patch
 package-version.patch
 skip-unreadable-file.patch
+honour_SOURCE_DATE_EPOCH.patch
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to