File: 0800_enable_manual_to_be_built_reproducibly.patch

package info (click to toggle)
ruby-prawn 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,528 kB
  • sloc: ruby: 17,688; sh: 43; makefile: 20
file content (42 lines) | stat: -rw-r--r-- 1,675 bytes parent folder | 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
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: 2019-01-07

--- a/manual/cover.rb
+++ b/manual/cover.rb
@@ -23,6 +23,8 @@ Prawn::ManualBuilder::Peritext.new do
     )
 
     unless ENV['CI']
+      last_update = Time.at(ENV['BUILD_EPOCH'].to_i) if ENV['BUILD_EPOCH']
+      last_update ||= Time.at(`git log -1 --pretty='%ct'`.to_i)
       git_commit =
         if Dir.exist?(File.expand_path('../.git', __dir__))
           commit = `git show --pretty=%h`
@@ -34,7 +36,7 @@ Prawn::ManualBuilder::Peritext.new do
       doc.canvas do
         v_text = [
           {
-            text: "Last Update: #{Time.now.strftime('%Y-%m-%d')}\n" \
+            text: "Last Update: #{last_update.utc.strftime("%Y-%m-%d")}\n" \
               "Prawn Version: #{Prawn::VERSION}\n#{git_commit}",
             font: 'DejaVu',
             size: 12,
--- a/manual/document_and_page_options/metadata.rb
+++ b/manual/document_and_page_options/metadata.rb
@@ -23,7 +23,7 @@ Prawn::ManualBuilder::Chapter.new do
       Keywords: 'test metadata ruby pdf dry',
       Creator: 'ACME Soft App',
       Producer: 'Prawn',
-      CreationDate: Time.now,
+      CreationDate: creation_date.utc,
     }
 
     Prawn::Document.generate('example.pdf', info: info) do