lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.21 vs lib/rconf/configurators/ruby_configurator.rb in rconf-0.8.29

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide. +# Copyright (C) 2011-2012 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 @@ -62,11 +62,11 @@ out = Command.execute('rvm', 'use', version).output case out when /is not installed\./ report_failure report_fatal "Failed to install #{ruby}" if @tried - install_ruby(version) + Platform.dispatch(version) { :install_ruby } @tried = true Command.execute_in_ruby('gem', 'install', 'rconf') unless gemset run return true when /^Using / @@ -181,9 +181,33 @@ Platform.dispatch(ruby) { :install_ruby_prerequisites } report_check("Installing #{ruby} (this will take a while, please be patient)") Command.execute('rvm', 'install', ruby, :abort_on_failure => 'Failed to install ruby') report_success true + end + + # Install given ruby version using rvm + # On Lion, need to setup CC env var before running rvm install + # + # === Parameters + # ruby(String):: Ruby version compatible with rvm + # + # === Return + # true:: Always return true + def install_ruby_darwin(ruby) + report_check("Installing #{ruby} (this will take a while, please be patient)") + xml = Command.execute('system_profiler', 'SPDeveloperToolsDataType', '-xml') + version = Command.execute('xpath', '"//*[text()=\'_items\']/following-sibling::array/dict/child::key[text()=\'spdevtools_version\']/following-sibling::string/text()"') + env = {} + if version =~ /^4\.2\./ + if !File.executable?('/usr/bin/gcc-4.2') + report_fatal("The C compiler included with Xcode #{version} produces buggy ruby interpreters, please install the C compilers from https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg and re-run rconf") + else + env['CC'] = '/usr/bin/gcc-4.2' + end + end + Command.execute('rvm', 'install', ruby, :abort_on_failure => 'Failed to install ruby', :env => env) + report_success end # Make sure to install all required linux packages first # # === Return