Browse files

JRUBY-4137: ant dist/rake installers should generate sha1 and md5 fil…

…es for installer files
  • Loading branch information...
1 parent 61b1f7f commit 46dbe6e2aad3f2ea5400b837276c02d1cd1fc1d2 @enebo enebo committed Oct 23, 2009
Showing with 42 additions and 2 deletions.
  1. +41 −2 Rakefile
  2. +1 −0 default.build.properties
View
43 Rakefile
@@ -1,7 +1,41 @@
+# FIXME: Move into helper file somewhere for checksum methods
+require 'digest'
+
+class HashTask < Struct.new(:hash, :file)
+ BUF = 100 * 1024
+
+ def calculate_hash
+ open(file) do |io|
+ while !io.eof
+ hash.update io.readpartial(BUF)
+ end
+ end
+ hash.hexdigest
+ end
+
+ def self.hash_for(filename, method=Digest::MD5)
+ File.open(filename + "."+ method.name.split('::').last.downcase, 'w') do |f|
+ f.puts HashTask.new(method.new, filename).calculate_hash
+ end
+ end
+end
+
+# Calculate a md5 checksum and save the file as same name + ".md5"
+def md5_checksum(filename)
+ HashTask.hash_for(filename)
+end
+
+# Calculate a sha1 checksum and save the file as same name + ".sha1"
+def sha1_checksum(filename)
+ HashTask.hash_for(filename, Digest::SHA1)
+end
+
+
task :default => [:build]
Object.const_set(:BASE_DIR, Dir.pwd)
+# FIXME: Move into helper method and call it
File.open("default.build.properties") do |props|
props.each_line do |line|
# skip comments
@@ -174,7 +208,12 @@ end
task :installer do
ant "dist"
- sh "/Applications/install4j\\ 4/bin/install4jc -m win32 -D jruby.version=#{VERSION_JRUBY} install/jruby.install4j" do |ok,res|
- $stderr.puts "** Something went wrong: #{res}" unless ok
+ sh "#{INSTALL4J_EXECUTABLE} -m win32 -D jruby.version=#{VERSION_JRUBY} " \
+ "install/jruby.install4j" do |ok, result|
+ $stderr.puts "** Something went wrong: #{result}" unless ok
end
+ Dir["#{BUILD_DIR}/installers/*.exe"].each do |file|
+ md5_checksum file
+ sha1_checksum file
+ end
end
View
1 default.build.properties
@@ -30,6 +30,7 @@ jruby.launch.memory=512M
jruby.test.memory=512M
jruby.test.jvm=java
ruby.executable=/usr/bin/ruby
+install4j.executable=/Applications/install4j\ 4/bin/install4jc
version.jruby=1.5.0dev
version.ruby.major=1.8
version.ruby.minor=7

0 comments on commit 46dbe6e

Please sign in to comment.