[DRE-commits] [ruby-prawn] 03/08: add patches relative to reproducible builds. Thanks Jérémy Bobbio

Cédric Boutillier boutil at moszumanska.debian.org
Wed Apr 29 14:37:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

boutil pushed a commit to branch master
in repository ruby-prawn.

commit f3afd1c1f1d8236600d4f4d35cf3bfd60bbc23b0
Author: Cédric Boutillier <boutil at debian.org>
Date:   Wed Apr 29 14:21:39 2015 +0200

    add patches relative to reproducible builds. Thanks Jérémy Bobbio
---
 ...0700_use_deterministic_keys_for_gradients.patch | 40 +++++++++++++++++
 ...00_enable_manual_to_be_built_reproducibly.patch | 51 ++++++++++++++++++++++
 debian/patches/series                              |  2 +
 debian/rules                                       |  4 ++
 4 files changed, 97 insertions(+)

diff --git a/debian/patches/0700_use_deterministic_keys_for_gradients.patch b/debian/patches/0700_use_deterministic_keys_for_gradients.patch
new file mode 100644
index 0000000..6adde09
--- /dev/null
+++ b/debian/patches/0700_use_deterministic_keys_for_gradients.patch
@@ -0,0 +1,40 @@
+Description: Use deterministic values for gradients
+ Previously, Prawn used #hash for gradients. Unfortunately, this uses
+ #object_id internally and prevent Prawn to create PDF using gradients
+ in a reproducible manner.
+ .
+ We now instead use an internal Hash with an incremental index starting
+ at 1.
+Author: Jérémy Bobbio <lunar at debian.org>
+Forwarded: https://github.com/prawnpdf/prawn/pull/844
+Last-Update: 2015-04-29
+
+--- a/lib/prawn/graphics/patterns.rb
++++ b/lib/prawn/graphics/patterns.rb
+@@ -60,7 +60,7 @@
+       end
+ 
+       def gradient_registry_key(gradient)
+-        if gradient[1].is_a?(Array) # axial
++        key = if gradient[1].is_a?(Array) # axial
+           [
+             map_to_absolute(gradient[0]),
+             map_to_absolute(gradient[1]),
+@@ -74,7 +74,16 @@
+             gradient[3],
+             gradient[4], gradient[5]
+           ]
+-        end.hash
++        end
++        unless @gradient_key_registry
++          @gradient_key_registry ||= {}
++          @gradient_key_index = 1
++        end
++        unless @gradient_key_registry.include?(key)
++          @gradient_key_registry[key] = @gradient_key_index
++          @gradient_key_index += 1
++        end
++        @gradient_key_registry[key]
+       end
+ 
+       def gradient_registry
diff --git a/debian/patches/0800_enable_manual_to_be_built_reproducibly.patch b/debian/patches/0800_enable_manual_to_be_built_reproducibly.patch
new file mode 100644
index 0000000..fc0e137
--- /dev/null
+++ b/debian/patches/0800_enable_manual_to_be_built_reproducibly.patch
@@ -0,0 +1,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 at debian.org>
+Forwarded: https://github.com/prawnpdf/prawn/pull/844
+Last-Update: 2015-04-29
+
+--- 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
+@@ -7,6 +7,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
+ Prawn::Document.generate("metadata.pdf",
+   :info => {
+     :Title        => "My title",
+@@ -15,7 +16,7 @@
+     :Keywords     => "test metadata ruby pdf dry",
+     :Creator      => "ACME Soft App",
+     :Producer     => "Prawn",
+-    :CreationDate => Time.now
++    :CreationDate => creation_date.utc
+   }) do
+ 
+   text "This is a test of setting metadata properties via the info option."
diff --git a/debian/patches/series b/debian/patches/series
index 9be8a9d..6aca906 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,5 @@
 0405_use_system_fonts_manual.patch
 0500_disable_tests_using_removed_files.patch
 0600_replace_require_relative_manual.patch
+0700_use_deterministic_keys_for_gradients.patch
+0800_enable_manual_to_be_built_reproducibly.patch
diff --git a/debian/rules b/debian/rules
index f98f768..5a0b525 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,10 @@
 # If you need to specify the .gemspec (eg there is more than one)
 #export DH_RUBY_GEMSPEC=gem.gemspec
 
+LAST_CHANGE = $(shell dpkg-parsechangelog -S Date)
+BUILD_EPOCH = $(shell date -u +"%s" --date="$(LAST_CHANGE)")
+export BUILD_EPOCH
+
 %:
 	dh $@ --buildsystem=ruby --with ruby
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-prawn.git



More information about the Pkg-ruby-extras-commits mailing list