|
|
dd2565 |
From 091459248d3ce814e10d50cc4421f0c0454ef61f Mon Sep 17 00:00:00 2001
|
|
|
dd2565 |
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
|
|
|
dd2565 |
Date: Sun, 30 Apr 2017 22:47:40 +0200
|
|
|
dd2565 |
Subject: [PATCH 1/4] created.rid: use SOURCE_DATE_EPOCH
|
|
|
dd2565 |
|
|
|
dd2565 |
use SOURCE_DATE_EPOCH instead of current time in created.rid top line
|
|
|
dd2565 |
to enable reproducible builds of ruby docs
|
|
|
dd2565 |
|
|
|
dd2565 |
See https://reproducible-builds.org/ for why this is good
|
|
|
dd2565 |
and https://reproducible-builds.org/specs/source-date-epoch/
|
|
|
dd2565 |
for the definition of this variable.
|
|
|
dd2565 |
---
|
|
|
dd2565 |
lib/rdoc/rdoc.rb | 3 +++
|
|
|
dd2565 |
1 file changed, 3 insertions(+)
|
|
|
dd2565 |
|
|
|
dd2565 |
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
|
|
|
dd2565 |
index 68775c8be1..a2711fbbd1 100644
|
|
|
dd2565 |
--- a/lib/rdoc/rdoc.rb
|
|
|
dd2565 |
+++ b/lib/rdoc/rdoc.rb
|
|
|
dd2565 |
@@ -232,6 +232,9 @@ def store= store
|
|
|
dd2565 |
|
|
|
dd2565 |
def update_output_dir(op_dir, time, last = {})
|
|
|
dd2565 |
return if @options.dry_run or not @options.update_output_dir
|
|
|
dd2565 |
+ unless ENV['SOURCE_DATE_EPOCH'].nil?
|
|
|
dd2565 |
+ time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
|
|
|
dd2565 |
+ end
|
|
|
dd2565 |
|
|
|
dd2565 |
open output_flag_file(op_dir), "w" do |f|
|
|
|
dd2565 |
f.puts time.rfc2822
|
|
|
dd2565 |
--
|
|
|
dd2565 |
2.21.0
|
|
|
dd2565 |
|
|
|
dd2565 |
From 73a935e9fa63b056ea0be69c0c923afdfb4d88da Mon Sep 17 00:00:00 2001
|
|
|
dd2565 |
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
|
|
|
dd2565 |
Date: Thu, 14 Dec 2017 10:54:54 +0100
|
|
|
dd2565 |
Subject: [PATCH 2/4] Do not store current timestamps in gz headers
|
|
|
dd2565 |
|
|
|
dd2565 |
to enable reproducible builds of rdoc
|
|
|
dd2565 |
|
|
|
dd2565 |
Normally, 0 would be the preferred value to indicate "no date"
|
|
|
dd2565 |
but that value is handled differently in Zlib::GzipWriter
|
|
|
dd2565 |
to put in the current time
|
|
|
dd2565 |
---
|
|
|
dd2565 |
lib/rdoc/generator/json_index.rb | 4 ++--
|
|
|
dd2565 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
dd2565 |
|
|
|
dd2565 |
diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
index e4cfe967c6..a059a5d4d0 100644
|
|
|
dd2565 |
--- a/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
+++ b/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
@@ -175,7 +175,7 @@ def generate_gzipped
|
|
|
dd2565 |
debug_msg "Writing gzipped search index to %s" % outfile
|
|
|
dd2565 |
|
|
|
dd2565 |
Zlib::GzipWriter.open(outfile) do |gz|
|
|
|
dd2565 |
- gz.mtime = File.mtime(search_index_file)
|
|
|
dd2565 |
+ gz.mtime = 1 # make output reproducible
|
|
|
dd2565 |
gz.orig_name = search_index_file.basename.to_s
|
|
|
dd2565 |
gz.write search_index
|
|
|
dd2565 |
gz.close
|
|
|
dd2565 |
@@ -193,7 +193,7 @@ def generate_gzipped
|
|
|
dd2565 |
debug_msg "Writing gzipped file to %s" % outfile
|
|
|
dd2565 |
|
|
|
dd2565 |
Zlib::GzipWriter.open(outfile) do |gz|
|
|
|
dd2565 |
- gz.mtime = File.mtime(dest)
|
|
|
dd2565 |
+ gz.mtime = 1 # make output reproducible
|
|
|
dd2565 |
gz.orig_name = dest.basename.to_s
|
|
|
dd2565 |
gz.write data
|
|
|
dd2565 |
gz.close
|
|
|
dd2565 |
--
|
|
|
dd2565 |
2.21.0
|
|
|
dd2565 |
|
|
|
dd2565 |
From 1b34b337b72918e83c3b952eed6998ad47974960 Mon Sep 17 00:00:00 2001
|
|
|
dd2565 |
From: aycabta <aycabta@gmail.com>
|
|
|
dd2565 |
Date: Sat, 27 Jan 2018 14:37:42 +0900
|
|
|
dd2565 |
Subject: [PATCH 3/4] Improve reproducible builds for .js and .js.gz files
|
|
|
dd2565 |
|
|
|
dd2565 |
The mtime for search_index.js.gz should be updated because it's
|
|
|
dd2565 |
generated dynamically. So uses SOURCE_DATE_EPOCH after
|
|
|
dd2565 |
RDoc::Generator::JsonIndex#generate creates index file.
|
|
|
dd2565 |
|
|
|
dd2565 |
FileUtils.install in RDoc::Generator::JsonIndex#generate with :preserve
|
|
|
dd2565 |
option because the mtime value is based on original .js file.
|
|
|
dd2565 |
---
|
|
|
dd2565 |
lib/rdoc/generator/json_index.rb | 9 +++++---
|
|
|
dd2565 |
test/rdoc/test_rdoc_generator_json_index.rb | 25 ++++++++++++++++++++-
|
|
|
dd2565 |
2 files changed, 30 insertions(+), 4 deletions(-)
|
|
|
dd2565 |
|
|
|
dd2565 |
diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
index a059a5d4d0..3a1000033d 100644
|
|
|
dd2565 |
--- a/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
+++ b/lib/rdoc/generator/json_index.rb
|
|
|
dd2565 |
@@ -147,12 +147,15 @@ def generate
|
|
|
dd2565 |
|
|
|
dd2565 |
JSON.dump data, io, 0
|
|
|
dd2565 |
end
|
|
|
dd2565 |
+ unless ENV['SOURCE_DATE_EPOCH'].nil?
|
|
|
dd2565 |
+ index_file.utime index_file.atime, Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
|
|
|
dd2565 |
+ end
|
|
|
dd2565 |
|
|
|
dd2565 |
Dir.chdir @template_dir do
|
|
|
dd2565 |
Dir['**/*.js'].each do |source|
|
|
|
dd2565 |
dest = File.join out_dir, source
|
|
|
dd2565 |
|
|
|
dd2565 |
- FileUtils.install source, dest, :mode => 0644, :verbose => $DEBUG_RDOC
|
|
|
dd2565 |
+ FileUtils.install source, dest, :mode => 0644, :preserve => true, :verbose => $DEBUG_RDOC
|
|
|
dd2565 |
end
|
|
|
dd2565 |
end
|
|
|
dd2565 |
end
|
|
|
dd2565 |
@@ -175,7 +178,7 @@ def generate_gzipped
|
|
|
dd2565 |
debug_msg "Writing gzipped search index to %s" % outfile
|
|
|
dd2565 |
|
|
|
dd2565 |
Zlib::GzipWriter.open(outfile) do |gz|
|
|
|
dd2565 |
- gz.mtime = 1 # make output reproducible
|
|
|
dd2565 |
+ gz.mtime = File.mtime(search_index_file)
|
|
|
dd2565 |
gz.orig_name = search_index_file.basename.to_s
|
|
|
dd2565 |
gz.write search_index
|
|
|
dd2565 |
gz.close
|
|
|
dd2565 |
@@ -193,7 +196,7 @@ def generate_gzipped
|
|
|
dd2565 |
debug_msg "Writing gzipped file to %s" % outfile
|
|
|
dd2565 |
|
|
|
dd2565 |
Zlib::GzipWriter.open(outfile) do |gz|
|
|
|
dd2565 |
- gz.mtime = 1 # make output reproducible
|
|
|
dd2565 |
+ gz.mtime = File.mtime(dest)
|
|
|
dd2565 |
gz.orig_name = dest.basename.to_s
|
|
|
dd2565 |
gz.write data
|
|
|
dd2565 |
gz.close
|
|
|
dd2565 |
diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
index 6cb5463d29..65e7f087cc 100644
|
|
|
dd2565 |
--- a/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
+++ b/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
@@ -8,7 +8,7 @@ class TestRDocGeneratorJsonIndex < RDoc::TestCase
|
|
|
dd2565 |
def setup
|
|
|
dd2565 |
super
|
|
|
dd2565 |
|
|
|
dd2565 |
- @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_darkfish_#{$$}"
|
|
|
dd2565 |
+ @tmpdir = Dir.mktmpdir "test_rdoc_generator_darkfish_#{$$}_"
|
|
|
dd2565 |
FileUtils.mkdir_p @tmpdir
|
|
|
dd2565 |
|
|
|
dd2565 |
@options = RDoc::Options.new
|
|
|
dd2565 |
@@ -89,12 +89,21 @@ def test_file_dir
|
|
|
dd2565 |
end
|
|
|
dd2565 |
|
|
|
dd2565 |
def test_generate
|
|
|
dd2565 |
+ now = Time.now
|
|
|
dd2565 |
@g.generate
|
|
|
dd2565 |
|
|
|
dd2565 |
assert_file 'js/searcher.js'
|
|
|
dd2565 |
assert_file 'js/navigation.js'
|
|
|
dd2565 |
assert_file 'js/search_index.js'
|
|
|
dd2565 |
|
|
|
dd2565 |
+ orig_file = Pathname(File.join @pwd, 'lib/rdoc/generator/template/json_index/js/navigation.js')
|
|
|
dd2565 |
+ generated_file = Pathname(File.join @tmpdir, 'js/navigation.js')
|
|
|
dd2565 |
+ assert_equal orig_file.mtime, generated_file.mtime
|
|
|
dd2565 |
+ assert generated_file.mtime < now, '.js files should be the same timestamp'
|
|
|
dd2565 |
+
|
|
|
dd2565 |
+ generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
|
|
|
dd2565 |
+ assert generated_search_index.mtime > (now - 1), 'search_index.js should be generated timestamp'
|
|
|
dd2565 |
+
|
|
|
dd2565 |
json = File.read 'js/search_index.js'
|
|
|
dd2565 |
|
|
|
dd2565 |
json =~ /\Avar search_data = /
|
|
|
dd2565 |
@@ -137,6 +146,20 @@ def test_generate
|
|
|
dd2565 |
assert_equal expected, index
|
|
|
dd2565 |
end
|
|
|
dd2565 |
|
|
|
dd2565 |
+ def test_generate_search_index_with_reproducible_builds
|
|
|
dd2565 |
+ backup_epoch = ENV['SOURCE_DATE_EPOCH']
|
|
|
dd2565 |
+ ruby_birthday = Time.parse 'Wed, 24 Feb 1993 21:00:00 +0900'
|
|
|
dd2565 |
+ ENV['SOURCE_DATE_EPOCH'] = ruby_birthday.to_i.to_s
|
|
|
dd2565 |
+
|
|
|
dd2565 |
+ @g.generate
|
|
|
dd2565 |
+
|
|
|
dd2565 |
+ assert_file 'js/search_index.js'
|
|
|
dd2565 |
+ generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
|
|
|
dd2565 |
+ assert_equal ruby_birthday, generated_search_index.mtime
|
|
|
dd2565 |
+
|
|
|
dd2565 |
+ ENV['SOURCE_DATE_EPOCH'] = backup_epoch
|
|
|
dd2565 |
+ end
|
|
|
dd2565 |
+
|
|
|
dd2565 |
def test_generate_gzipped
|
|
|
dd2565 |
begin
|
|
|
dd2565 |
require 'zlib'
|
|
|
dd2565 |
--
|
|
|
dd2565 |
2.21.0
|
|
|
dd2565 |
|
|
|
dd2565 |
From 74c1e201f2146e7175e74d6fc0b9386c2e95210f Mon Sep 17 00:00:00 2001
|
|
|
dd2565 |
From: aycabta <aycabta@gmail.com>
|
|
|
dd2565 |
Date: Sat, 27 Jan 2018 17:54:31 +0900
|
|
|
dd2565 |
Subject: [PATCH 4/4] Use dirty hack on JRuby for MiniTest 4
|
|
|
dd2565 |
|
|
|
dd2565 |
---
|
|
|
dd2565 |
test/rdoc/test_rdoc_generator_json_index.rb | 6 +++++-
|
|
|
dd2565 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
dd2565 |
|
|
|
dd2565 |
diff --git a/test/rdoc/test_rdoc_generator_json_index.rb b/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
index 65e7f087cc..714d496195 100644
|
|
|
dd2565 |
--- a/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
+++ b/test/rdoc/test_rdoc_generator_json_index.rb
|
|
|
dd2565 |
@@ -98,7 +98,11 @@ def test_generate
|
|
|
dd2565 |
|
|
|
dd2565 |
orig_file = Pathname(File.join @pwd, 'lib/rdoc/generator/template/json_index/js/navigation.js')
|
|
|
dd2565 |
generated_file = Pathname(File.join @tmpdir, 'js/navigation.js')
|
|
|
dd2565 |
- assert_equal orig_file.mtime, generated_file.mtime
|
|
|
dd2565 |
+
|
|
|
dd2565 |
+ # This is dirty hack on JRuby for MiniTest 4
|
|
|
dd2565 |
+ assert orig_file.mtime.inspect == generated_file.mtime.inspect,
|
|
|
dd2565 |
+ '.js files should be tha same timestamp of original'
|
|
|
dd2565 |
+
|
|
|
dd2565 |
assert generated_file.mtime < now, '.js files should be the same timestamp'
|
|
|
dd2565 |
|
|
|
dd2565 |
generated_search_index = Pathname(File.join @tmpdir, 'js/search_index.js')
|
|
|
dd2565 |
--
|
|
|
dd2565 |
2.21.0
|
|
|
dd2565 |
|