# 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 BuildConfigurator include Configurator register :build description 'Builds a repository using the ./configure, make, make install commands' settings :path => 'Path to source files', :pre_step => 'Command ran prior to ./configure', :message => 'Progress message to display if any while building', :configure_opts => 'Hash of options to be given to the configure script. ' + 'The keys are the platform families (:darwin, :linux or :windows)', :only_if => 'Ruby code that should return true for build to proceed' validate_has_settings :path # Run command line # # === Return # true:: Always return true def run_linux if only_if.nil? || instance_eval(only_if) message("Building #{path}") if message.nil? report_check message Dir.chdir(path) do Command.execute(*command_args(pre_step)) if pre_step opts = configure_opts && configure_opts[Platform.family] Command.execute(*command_args("./configure #{opts}")) Command.execute(*command_args('make')) report_success report("Please enter you password to run the install step") Command.sudo('echo') report_check 'Installing' Command.sudo(*command_args('make install')) end report_success end true end alias :run_darwin :run_linux # Run command line on Windows # # === Return # true:: Always return true def run_windows true # TBD end protected # Build arguments for Command.execute from command line # # === Arguments # command(String):: Command line to run # # === Return # args(Array):: Array of arguments to be passed to Command.execute def command_args(command) args = command.split(' ').compact args += [ { :abort_on_failure => "Failed to run #{command.rstrip}" } ] end end end