Package: ruby-prawn / 2.1.0+dfsg-1

0800_enable_manual_to_be_built_reproducibly.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Description: Enable manual to be built reproducibly
 In order to make the manual build reproducibly, we need a way to stop
 writing the current build time in it.
 .
 The following patch will allow this in two ways: if BUILD_DATE is set
 in the environment, the date will be taken from there; otherwise, if
 the Git index is available, the date of the last commit will be used.
Author: Jérémy Bobbio <lunar@debian.org>
Forwarded: https://github.com/prawnpdf/prawn/pull/844
Last-Update: 2015-07-24

--- a/manual/cover.rb
+++ b/manual/cover.rb
@@ -23,14 +23,17 @@
                          :size => 60 }
                      ], :at => [170, cursor - 160])
 
+  last_update = Time.at(ENV['BUILD_EPOCH'].to_i) if ENV['BUILD_EPOCH']
   if Dir.exist?("#{Prawn::BASEDIR}/.git")
     commit = `git show --pretty=%h`
     git_commit = "git commit: #{commit.lines.first}"
+    last_update ||= Time.at(`git log -1 --pretty='%ct'`.to_i)
   else
     git_commit = ""
+    last_update ||= Time.now
   end
 
-  formatted_text_box([  { :text => "Last Update: #{Time.now.strftime("%Y-%m-%d")}\n" +
+  formatted_text_box([  { :text => "Last Update: #{last_update.utc.strftime("%Y-%m-%d")}\n" +
                                    "Prawn Version: #{Prawn::VERSION}\n" +
                                    git_commit,
                           :size => 12 }
--- a/manual/document_and_page_options/metadata.rb
+++ b/manual/document_and_page_options/metadata.rb
@@ -6,6 +6,7 @@
 #
 require File.expand_path(File.join(File.dirname(__FILE__),
                                    %w[.. example_helper]))
+creation_date = ENV['BUILD_EPOCH'] ? Time.at(ENV['BUILD_EPOCH'].to_i) : Time.now
 
 info = {
   :Title        => "My title",
@@ -14,7 +15,7 @@
   :Keywords     => "test metadata ruby pdf dry",
   :Creator      => "ACME Soft App",
   :Producer     => "Prawn",
-  :CreationDate => Time.now
+  :CreationDate => creation_date.utc
 }
 
 Prawn::Document.generate("metadata.pdf", :info => info) do