Created
August 25, 2015 15:19
-
-
Save grekko/0a1f1fc83d33024e2a93 to your computer and use it in GitHub Desktop.
Install (via rbenv) rubies with patches (e.g. for memory profiling)
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
#!/usr/bin/env ruby | |
require 'open-uri' | |
require 'pathname' | |
PATCH_REPO_BASE_URL = 'https://raw.githubusercontent.com/skaes/rvm-patchsets/master' | |
PATCH_SET = ARGV[0] | |
PATCH_RUBY_VERSION = ARGV[1] | |
raise 'Please specify a patchset (e.g. railsexpress). `ruby-install-with-patches railsexpress 2.2.3`' if PATCH_SET.nil? | |
raise 'Please specify a ruby version (e.g. 2.2.3). `ruby-install-with-patches railsexpress 2.2.3`' if PATCH_RUBY_VERSION.nil? | |
TEMP_PATCH_DIR = Pathname.new("/tmp/ruby-install-patches/#{PATCH_RUBY_VERSION}/#{PATCH_SET}") | |
puts "Downloading patch files to #{TEMP_PATCH_DIR}" | |
`mkdir -p #{TEMP_PATCH_DIR}` | |
patch_file_paths = open("#{PATCH_REPO_BASE_URL}/patchsets/ruby/#{PATCH_RUBY_VERSION}/#{PATCH_SET}").read.split("\n").map do |patch| | |
patch_url = "#{PATCH_REPO_BASE_URL}/patches/ruby/#{PATCH_RUBY_VERSION}/#{patch}" | |
patch_file_path = "#{TEMP_PATCH_DIR}/#{patch.gsub('/','-')}" | |
puts "Downloading #{patch} to #{patch_file_path}" | |
`curl -s #{patch_url} > #{patch_file_path}` | |
patch_file_path | |
end | |
puts "Installing ruby with rbenv install (#{`rbenv-install --version`.chomp})" | |
`cat #{patch_file_paths.join(' ')} | rbenv install -v --patch #{PATCH_RUBY_VERSION}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment