1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00
one/share/bundler/install_gems
2011-07-12 19:27:15 +02:00

108 lines
2.3 KiB
Ruby
Executable File

#!/usr/bin/env ruby
require 'pp'
PACKAGES=%w{optional sunstone quota cloud ozones_client ozones_server
ozones_server_mysql ozones_server_sqlite}
DEFAULT=%w{optional sunstone quota cloud ozones_server acct}
GROUPS={
:optional => %w{nokogiri libxml-ruby},
:quota => %w{sqlite3 sequel},
:sunstone => %w{json rack sinatra thin},
:cloud => %w{amazon-ec2 rack sinatra thin uuid curb},
:ozones_client => %w{json},
:ozones_server => %w{json datamapper dm-sqlite-adapter dm-mysql-adapter},
:ozones_server_sqlite => %w{json datamapper dm-sqlite-adapter},
:ozones_server_mysql => %w{json datamapper dm-mysql-adapter},
:acct => %w{sequel sqlite3 mysql},
:acct_sqlite => %w{sequel sqlite3 mysql},
:acct_mysql => %w{sequel sqlite3 mysql}
}
class String
def unindent(spaces=4)
self.gsub!(/^ {#{spaces}}/, '')
end
end
def try_library(name, error_message)
begin
require name.to_s
rescue LoadError
STDERR.puts error_message
exit -1
end
end
def install_warning(packages)
puts "Use -h for help"
puts
puts "About to install the gems for these components:"
puts "* "<<packages.join("\n* ")
puts
puts "Are you sure you want to continue? (YES/no)"
yes=STDIN.readline
if yes.strip!="YES"
puts "Installation aborted"
exit(0)
end
end
def help
puts "Specify the package dependencies from this list:"
puts "* "<<PACKAGES.join("\n* ")
puts
puts "If no parameters are specified then this list will be used:"
puts DEFAULT.join(' ')
end
def get_gems(packages)
packages.map do |package|
GROUPS[package.to_sym]
end.flatten.uniq
end
try_library :rubygems, <<-EOT.unindent
rubygems required to use this tool
Use one of these methods:
* Debian/Ubuntu
apt-get install rubygems libopenssl-ruby
* RHEL/CENTOS
yum install rubygems
* Specific rubygems package for your distro
* Follow the instructions from http://rubygems.org/pages/download
EOT
if ARGV.include?('-h')
help
exit(0)
end
if ARGV.length>0
packages=ARGV
else
packages=DEFAULT
end
packages_string=get_gems(packages).join(' ')
command_string = "gem install --no-ri --no-rdoc #{packages_string}"
install_warning(packages)
puts command_string
system command_string