lib/capitate/plugins/script.rb in capitate-0.2.6 vs lib/capitate/plugins/script.rb in capitate-0.2.7
- old
+ new
@@ -1,65 +1,7 @@
module Capitate::Plugins::Script
- # Configure, make, make install.
- #
- # ==== Options
- # +name+:: Name for app
- # +options+:: Options
- # - +build_dest+:: Place to build from, ex. /usr/src, defaults to /tmp/name
- # - +url+:: URL to download package from
- # - +configure_options+:: Options for ./configure
- # - +unpack_dir+:: Directory that is unpacked from tgz (if not matching the file name)
- # - +to_log+:: If specified, will redirect output to this path
- #
- # ==== Examples (in capistrano task)
- # script.make_install("nginx", { :url => "http://sysoev.ru/nginx/nginx-0.5.35.tar.gz", ... })
- #
- def make_install(name, options)
- install(name, options) do |dir|
- configure_options = options[:configure_options] || ""
-
- # Whether to capture build output
- unless options.has_key?(:to_log)
- to_log = ">> debug.log"
- else
- to_log = ""
- to_log = ">> #{options[:to_log]}" unless options[:to_log].blank?
- end
-
- run_all <<-CMDS
- sh -c "cd #{dir} && ./configure #{configure_options} #{to_log}"
- sh -c "cd #{dir} && make #{to_log}"
- sh -c "cd #{dir} && make install #{to_log}"
- CMDS
- end
- end
-
- # Download, unpack and yield (unpacked source director).
- #
- # ==== Options
- # +name+:: Name for app
- # +options+:: Options
- # - +build_dest+:: Place to build from, ex. /usr/src, defaults to /tmp/name
- # - +url+:: URL to download package from
- #
- # ==== Examples (in capistrano task)
- # script.make("rubygems", { :url => :url => "http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz" }) do |dir|
- # sudo "echo 'Running setup...' && cd #{dir} && ruby #{dir}/setup.rb"
- # end
- #
- def install(name, options, &block)
- build_dest = options[:build_dest]
- build_dest ||= "/tmp/#{name}"
- url = options[:url]
-
- unpack(url, build_dest, options) do |dir|
- yield(dir) if block_given?
- end
- end
-
-
# Run (sh) script. If script has .erb extension it will evaluate it.
#
# ==== Options
# +script+:: Name of sh file (relative to templates dir)
# +override_binding++:: Binding to override, otherwise defaults to current (task) context
@@ -130,10 +72,9 @@
run_via "rm -rf #{dest}" if clean
end
end
# Run all commands (separated by newlines).
- # Runs with <tt>sh -c</tt>, so sudo can work with any command
#
# ==== Options
# +cmds+:: Commands (separated by newlines)
# +options+:: See invoke_command options
#
\ No newline at end of file