Created
February 26, 2013 19:28
-
-
Save monkstone/5041318 to your computer and use it in GitHub Desktop.
Vendors Rakefile for linux users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake/clean' | |
JRUBY_VERSION = "1.7.3" | |
PROCESSING_VERSION = "2.0b8" | |
CLOBBER.include("processing-#{PROCESSING_VERSION}-linux64.tgz", "jruby-complete-#{JRUBY_VERSION}.jar") | |
desc "download and copy to ruby-processing" | |
task :default => [:download, :copy] | |
desc "download Processing & JRuby upstream sources" | |
task :download => ["processing-#{PROCESSING_VERSION}-linux64.tgz", "jruby-complete-#{JRUBY_VERSION}.jar"] | |
file "processing-#{PROCESSING_VERSION}-linux64.tgz" do | |
sh "wget http://processing.googlecode.com/files/processing-#{PROCESSING_VERSION}-linux64.tgz" | |
check_sha1("processing-#{PROCESSING_VERSION}-linux64.tgz", "67a2d4df82233d96982865581b2c24799ea23518") | |
end | |
file "jruby-complete-#{JRUBY_VERSION}.jar" do | |
sh "wget http://jruby.org.s3.amazonaws.com/downloads/#{JRUBY_VERSION}/jruby-complete-#{JRUBY_VERSION}.jar" | |
check_sha1("jruby-complete-#{JRUBY_VERSION}.jar","fafe20bce6f70ce295f24160a1e470823edba3e7") | |
end | |
directory "../lib/core" | |
desc "copy libs & jars" | |
task :copy => ["../lib/core"] do | |
sh "cp -v jruby-complete-#{JRUBY_VERSION}.jar ../lib/core/jruby-complete.jar" | |
processing_zip = File.expand_path("processing-#{PROCESSING_VERSION}-linux64.tgz") | |
sh "cd ../lib/core && tar --wildcards --strip=3 -zvxf #{processing_zip} processing-#{PROCESSING_VERSION}/core/library/*.jar" | |
dirs = %w{dxf javascript minim net pdf serial video} | |
Dir.chdir("../library/") do | |
sh "rm -rf processing-#{PROCESSING_VERSION}/ #{dirs.join(" ")}" | |
inside_zip_dirs = dirs.collect { |d| "processing-#{PROCESSING_VERSION}/modes/java/libraries/#{d}/library/*" } | |
sh "tar --wildcards -zxvf #{processing_zip} #{inside_zip_dirs.join(" ")}" | |
sh "mv processing-#{PROCESSING_VERSION}/modes/java/libraries/* ." | |
sh "rm -r processing-#{PROCESSING_VERSION}/" | |
end | |
end | |
def check_sha1(filename, expected_hash) | |
require "digest/sha1" | |
sha1 = Digest::SHA1.new | |
File.open(filename, "r") do |f| | |
while buf = f.read(4096) | |
sha1.update(buf) | |
end | |
end | |
if sha1.hexdigest != expected_hash | |
raise "bad sha1 checksum for #{filename} (expected #{expected_hash} got #{sha1.hexdigest})" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment