Class | AutomateIt::PackageManager::CPAN |
In: |
lib/automateit/package_manager/cpan.rb
|
Parent: | ::AutomateIt::PackageManager::BaseDriver |
A PackageManager driver for Perl CPAN (Comprehensive Perl Archive Network) software packages.
Unlike other AutomateIt PackageManager drivers, the CPAN driver will not install a package‘s dependencies automatically. This protects you because many CPAN packages require a specific version of Perl, often one which you don‘t have installed, and installing that dependency will destroy your Perl interpreter and everything that depends on it. Therefore, you must specify all package dependencies manually. If a package dependency isn‘t found, the install will fail.
Use setup to specify the Perl interpreter to use for all subsequent calls.
Example:
package_manager[:cpan].setup(:perl => "/usr/local/bin/perl") package_manager.install %w(File::Next App::Ack), :with => :cpan
CPAN_WRAPPER | = | File.join(::AutomateIt::Constants::HELPERS_DIR, "cpan_wrapper.pl") |
perl | [RW] | Path to Perl interpreter |
Options:
See AutomateIt::PackageManager#install
# File lib/automateit/package_manager/cpan.rb, line 76 def install(*packages) return _install_helper(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --install #{list.join(' ')}" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end
Options:
See AutomateIt::PackageManager#installed?
# File lib/automateit/package_manager/cpan.rb, line 51 def installed?(*packages) return _installed_helper?(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --query #{list.join(' ')}" # FIXME if CPAN isn't configured, this will hang because Perl will demand input log.debug(PEXEC+cmd) output = `#{cmd}` output.sub!(/.*---(\s[^\n]+)?\n/m, '') struct = ::YAML.load(output) struct["available"] || [] end end
See AutomateIt::PackageManager#not_installed?
# File lib/automateit/package_manager/cpan.rb, line 67 def not_installed?(*packages) # TODO Move #not_installed? up to BaseDriver return _not_installed_helper?(*packages) end
Setup the PackageManager::CPAN driver.
Options:
# File lib/automateit/package_manager/cpan.rb, line 31 def setup(*args) super(*args) args, opts = args_and_opts(*args) if opts[:perl] self.perl = opts[:perl] else self.perl ||= "perl" end end
Options:
See AutomateIt::PackageManager#uninstall
# File lib/automateit/package_manager/cpan.rb, line 91 def uninstall(*packages) return _uninstall_helper(*packages) do |list, opts| perl = opts[:perl] || self.perl cmd = "#{perl} #{CPAN_WRAPPER} --uninstall #{list.join(' ')} < /dev/null" cmd << " > /dev/null" if opts[:quiet] cmd << " 2>&1" interpreter.sh(cmd) end end