Last active
October 25, 2019 06:01
-
-
Save monkstone/159c5a9813c9cd181040b4715e74f6b2 to your computer and use it in GitHub Desktop.
Install JRuby and PiCrate on debian (Rakefile)
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
if [ -z $GEM_HOME ]; then | |
mkdir -p ~/.gem/ruby/2.5.0/bin | |
echo "export GEM_HOME=\"\${HOME}/.gem/ruby/2.5.0\"" >> ~/.profile | |
echo "export GEM_PATH=\"\${HOME}/.gem/ruby/2.5.0\"" >> ~/.profile | |
echo "export PATH=\"\${PATH}:\${GEM_PATH}/bin\"" >> ~/.profile | |
echo "gem: --no-document" >> ~/.gemrc | |
source ~/.profile | |
fi |
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
# frozen_string_literal: true | |
require 'rake/clean' | |
WARNING = <<-WARN.freeze | |
WARNING: Something has gone wrong with download | |
check that the JRUBY_VERSION and download path | |
are still valid | |
WARN | |
JRUBY_VERSION = '9.2.8.0'.freeze | |
URL = [ | |
'https://repo1.maven.org', | |
'maven2', | |
'org', | |
'jruby', | |
'jruby-dist', | |
JRUBY_VERSION, | |
"jruby-dist-#{JRUBY_VERSION}-bin.tar.gz" | |
].join('/').freeze | |
SHA256 = [ | |
URL, | |
'sha256' | |
].join('.').freeze | |
CLOBBER << "jruby-dist-#{JRUBY_VERSION}-bin.tar.gz" | |
CLOBBER << "jruby-dist-#{JRUBY_VERSION}-bin.tar.gz.sha256" | |
task default: %i[download_jruby install_jruby install_gem] | |
desc 'Downloading JRuby' | |
task :download_jruby do | |
begin | |
sh "wget #{URL}" | |
sh "wget #{SHA256}" | |
rescue | |
warn(WARNING) | |
end | |
value = File.read("jruby-dist-#{JRUBY_VERSION}-bin.tar.gz.sha256") | |
check_sha256("jruby-dist-#{JRUBY_VERSION}-bin.tar.gz", value) | |
end | |
desc 'Install JRuby' | |
task :install_jruby do | |
tar_ball = File.join(Dir.pwd, "jruby-dist-#{JRUBY_VERSION}-bin.tar.gz") | |
Dir.chdir('/opt') do | |
sh "sudo tar xzvf #{tar_ball}" | |
end | |
sh "sudo update-alternatives --install /usr/bin/jruby jruby /opt/jruby-#{JRUBY_VERSION}/bin/jruby 51" | |
sh "sudo update-alternatives --install /usr/bin/jirb jirb /opt/jruby-#{JRUBY_VERSION}/bin/jirb 51" | |
sh "sudo update-alternatives --install /usr/bin/jgem jgem /opt/jruby-#{JRUBY_VERSION}/bin/jgem 51" | |
end | |
def check_sha256(filename, expected_hash) | |
require 'digest' | |
sha256 = Digest::SHA256.new | |
File.open(filename, 'r') do |f| | |
while (buf = f.read(4096)) | |
sha256.update(buf) | |
end | |
end | |
return if sha256.hexdigest == expected_hash | |
raise "bad sha256 checksum for #{filename} (expected #{expected_hash} got #{sha256.hexdigest})" | |
end | |
desc 'install gem' | |
task :install_gem do | |
sh 'jgem install picrate' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
suggesting
for L5 of gem_path.sh: fixes typo and is more polite with paths.