module Apt
Purpose¶ ↑
Apt
is a Capistrano plugin module providing a set of methods that invoke the apt package manager (as used in Debian and Ubuntu)
Installs within Capistrano as the plugin apt.
Usage¶ ↑
require 'vmbuilder_plugins/apt'
Prefix all calls to the library with apt.
Constants
- APT_GET
Default apt-get command - reduces any interactivity to the minimum.
Public Instance Methods
autoclean(options={})
click to toggle source
Run an apt autoclean
# File lib/plugins/apt.rb, line 45 def autoclean(options={}) send(run_method, %{sh -c "#{APT_GET} -qy autoclean"}, options) end
clean(options={})
click to toggle source
Run an apt clean
# File lib/plugins/apt.rb, line 40 def clean(options={}) send(run_method, %{sh -c "#{APT_GET} -qy clean"}, options) end
clear_cache(options={})
click to toggle source
Clear the source list and package cache
# File lib/plugins/apt.rb, line 76 def clear_cache(options={}) clean cmd="rm -f /var/cache/apt/*.bin /var/lib/apt/lists/*_* /var/lib/apt/lists/partial/*" send(run_method, cmd, options) end
dist_upgrade(options={})
click to toggle source
Run an apt distribution upgrade
# File lib/plugins/apt.rb, line 50 def dist_upgrade(options={}) update send(run_method, %{sh -c "#{APT_GET} -qy dist-upgrade"}, options) end
install(packages, version, options={})
click to toggle source
Run the apt install program across the package list in ‘packages’. Select those packages referenced by :base
and the version
of the distribution you want to use.
# File lib/plugins/apt.rb, line 31 def install(packages, version, options={}) update special_options="--allow-unauthenticated" if version != :stable send(run_method, %{ sh -c "#{APT_GET} -qyu --force-yes #{special_options.to_s} install #{package_list(packages, version)}" }, options) end
rpm_install(packages, options={})
click to toggle source
RPM package install via alien
# File lib/plugins/apt.rb, line 68 def rpm_install(packages, options={}) install({:base => %w(wget alien) }, :base) send(run_method, "wget -Ncq #{packages.join(' ')}", options) files=packages.collect { |package| File.basename(package) } send(run_method, "alien -i #{files.join(' ')}", options) end
update(options={})
click to toggle source
Run an apt update.
# File lib/plugins/apt.rb, line 63 def update(options={}) send(run_method, %{sh -c "#{APT_GET} -qy update"}, options) end
upgrade(options={})
click to toggle source
Run an apt upgrade. Use dist_upgrade
instead if you want to upgrade the critical base packages.
# File lib/plugins/apt.rb, line 57 def upgrade(options={}) update send(run_method, %{sh -c "#{APT_GET} -qy upgrade"}, options) end
Private Instance Methods
package_list(packages, version)
click to toggle source
Provides a string containing all the package names in the base
list plus those in version
.
# File lib/plugins/apt.rb, line 86 def package_list(packages, version) Array(packages[:base]).join(' ') + ' ' + Array(packages[version]).join(' ') end