[DRE-commits] [gem2deb] 02/04: dh_ruby: always use changelog date in gemspecs

Antonio Terceiro terceiro at moszumanska.debian.org
Wed Mar 2 20:23:34 UTC 2016


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

terceiro pushed a commit to branch master
in repository gem2deb.

commit d93a18490e3c9359d24ba7dcbd2d2cbe377d0271
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Wed Mar 2 17:11:02 2016 -0300

    dh_ruby: always use changelog date in gemspecs
---
 debian/changelog           |  3 +++
 lib/gem2deb/metadata.rb    |  8 ++++++++
 test/unit/metadata_test.rb | 10 ++++++++++
 3 files changed, 21 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 1177d4a..c1bfb80 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,9 @@ gem2deb (0.26.3) UNRELEASED; urgency=medium
     - with -w/--overwrite, never overwrite debian/copyright, since it will be
       always replace a human-reviewed debian/copyright with a completely dumb
       boilerplate.
+  * dh_ruby:
+    - force generated gemspecs to use the date from debian/changelog to help
+      with build reproducibility
 
  -- Antonio Terceiro <terceiro at debian.org>  Wed, 02 Mar 2016 16:26:58 -0300
 
diff --git a/lib/gem2deb/metadata.rb b/lib/gem2deb/metadata.rb
index fdf230f..999bd32 100644
--- a/lib/gem2deb/metadata.rb
+++ b/lib/gem2deb/metadata.rb
@@ -15,6 +15,7 @@
 
 require 'rubygems'
 require 'rubygems/specification'
+require 'time'
 require 'yaml'
 
 module Gem2Deb
@@ -30,6 +31,7 @@ module Gem2Deb
       Dir.chdir(source_dir) do
         load_gemspec
       end
+      set_gemspec_date
     end
 
     def has_native_extensions?
@@ -113,6 +115,12 @@ module Gem2Deb
       end
     end
 
+    def set_gemspec_date
+      if @gemspec && File.exist?('debian/changelog')
+        @gemspec.date = Time.parse(`dpkg-parsechangelog -SDate`.strip)
+      end
+    end
+
     # FIXME duplicated logic (see below)
     def read_name_from(directory)
       return nil if directory.nil?
diff --git a/test/unit/metadata_test.rb b/test/unit/metadata_test.rb
index 3f6c882..497ea4b 100644
--- a/test/unit/metadata_test.rb
+++ b/test/unit/metadata_test.rb
@@ -149,5 +149,15 @@ class MetaDataTest < Gem2DebTestCase
 
   end
 
+  context 'timestamps' do
+    should 'use date from changelog if available' do
+      Dir.chdir('test/sample/install_as_gem') do
+        @metadata = Gem2Deb::Metadata.new('.')
+      end
+      # the gemspec only stores the date and zeroes the hour
+      assert_equal Time.parse('2015-11-20 00:00:00 UTC'), @metadata.gemspec.date
+    end
+  end
+
 end
 

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



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