# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide. # # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, # reproduction, modification, or disclosure of this program is # strictly prohibited. Any use of this program by an authorized # licensee is strictly subject to the terms and conditions, # including confidentiality obligations, set forth in the applicable # License Agreement between RightScale.com, Inc. and # the licensee module RightConf class PackageInstaller include Singleton include ProgressReporter # Install given packages # # === Parameters # packages(String|Array):: Package name or Packages list # opts[:abort_on_failure](String):: Optional, abort configuration # and display given error message if install fails when set # opts[:report](TrueClass|FalseClass):: Whether to report installation # # === Return # true:: Always return true def install(packages, opts=nil) packages = [ packages ].flatten report = opts && opts.delete(:report) report_check("Installing the following packages:\n#{packages.join(' ')}\nThis could take a while") if report Platform.dispatch(packages, opts) { :install } report_success if report end protected # Install debian packages # # === Return # true:: Always return true def install_linux_ubuntu(packages, opts) return if packages.nil? args = packages.dup args << opts if opts Command.sudo('apt-get', 'install', '-y', *args) end alias :install_linux_debian :install_linux_ubuntu # Install yum packages # # === Return # true:: Always return true def install_linux_centos(packages, opts) return if packages.nil? args = packages.dup args << opts if opts Command.sudo('yum', 'install', '-y', *args) end alias :install_linux_redhat :install_linux_centos # Use brew on Mac OS X # # === Return # true:: Always return true def install_darwin(packages, opts) return if packages.nil? BrewInstaller.check_and_install packages.each do |p| args = [ p ] args << opts if opts Command.execute('brew', 'install', *args) end end # Install Windows software # # === Return # true:: Always return true def install_windows(packages, opts) # TBD end end end