Skip to content

Instantly share code, notes, and snippets.

@jnewland
Created August 13, 2009 13:00
Show Gist options
  • Save jnewland/167155 to your computer and use it in GitHub Desktop.
Save jnewland/167155 to your computer and use it in GitHub Desktop.
#!/opt/ree/bin/ruby
# originally from http://griffin.oobleyboo.com/archive/ruby-enterprise-edition-gem-install-script/
#
# Usage:
#
# $ sudo -s
# # OLD_GEM=/usr/bin/gem NEW_GEM=/opt/ree-whatever/bin/gem /opt/ree/bin/ruby ree_gem_reinstall.rb
# The command to run for your vanila Ruby 'gem' command
ENV['OLD_GEM'] ||= '/usr/bin/gem'
# The command to run for REE's 'gem' command
ENV['NEW_GEM'] ||= '/opt/ree/bin/gem'
output=`#{ENV['OLD_GEM']} list`
new_list=`#{ENV['NEW_GEM']} list`
output.each do |line|
# Skip lines that don't look like a gem version
matches=line.match(/([A-Z].+) \(([0-9\., ]+)\)/i)
if matches then
gem_name=matches[1]
# skip passenger and mysql
next if gem_name == 'mysql' || gem_name == 'passenger'
versions=matches[2]
versions.split(', ').each do |ver|
cmd="#{ENV['NEW_GEM']} install #{gem_name} -v #{ver} --no-rdoc --no-ri --backtrace"
# See if this gem is already installed
if new_list =~ /#{gem_name} \(.*#{ver}.*\)/i then
puts "#{gem_name} #{ver} is already installed. Skipping"
else
puts cmd
system(cmd)
end
end
end
end
#install mysql
cmd = "#{ENV['NEW_GEM']} install mysql -- --with-mysql-config"
puts cmd
system(cmd)
puts "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment