Module: Apt
- Defined in:
- lib/vmbuilder_plugins/apt.rb
Overview
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.
Constant Summary collapse
- APT_GET =
Default apt-get command - reduces any interactivity to the minimum.
"DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get"
Instance Method Summary collapse
-
#autoclean(options = {}) ⇒ Object
Run an apt autoclean.
-
#clean(options = {}) ⇒ Object
Run an apt clean.
-
#clear_cache(options = {}) ⇒ Object
Clear the source list and package cache.
-
#dist_upgrade(options = {}) ⇒ Object
Run an apt distribution upgrade.
-
#install(packages, version, options = {}) ⇒ Object
Run the apt install program across the package list in ‘packages’.
-
#rpm_install(packages, options = {}) ⇒ Object
RPM package install via alien.
-
#update(options = {}) ⇒ Object
Run an apt update.
-
#upgrade(options = {}) ⇒ Object
Run an apt upgrade.
Instance Method Details
#autoclean(options = {}) ⇒ Object
Run an apt autoclean
44 45 46 |
# File 'lib/vmbuilder_plugins/apt.rb', line 44 def autoclean(={}) send(run_method, %{sh -c "#{APT_GET} -qy autoclean"}, ) end |
#clean(options = {}) ⇒ Object
Run an apt clean
39 40 41 |
# File 'lib/vmbuilder_plugins/apt.rb', line 39 def clean(={}) send(run_method, %{sh -c "#{APT_GET} -qy clean"}, ) end |
#clear_cache(options = {}) ⇒ Object
Clear the source list and package cache
73 74 75 76 77 |
# File 'lib/vmbuilder_plugins/apt.rb', line 73 def clear_cache(={}) clean cmd="rm -f /var/cache/apt/*.bin /var/lib/apt/lists/*_* /var/lib/apt/lists/partial/*" send(run_method, cmd, ) end |
#dist_upgrade(options = {}) ⇒ Object
Run an apt distribution upgrade
49 50 51 |
# File 'lib/vmbuilder_plugins/apt.rb', line 49 def dist_upgrade(={}) send(run_method, %{sh -c "#{APT_GET} -qy dist-upgrade"}, ) end |
#install(packages, version, options = {}) ⇒ Object
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.
31 32 33 34 35 36 |
# File 'lib/vmbuilder_plugins/apt.rb', line 31 def install(packages, version, ={}) ="--allow-unauthenticated" if version != :stable send(run_method, %{ sh -c "#{APT_GET} -qyu #{special_options.to_s} install #{package_list(packages, version)}" }, ) end |
#rpm_install(packages, options = {}) ⇒ Object
RPM package install via alien
65 66 67 68 69 70 |
# File 'lib/vmbuilder_plugins/apt.rb', line 65 def rpm_install(packages, ={}) install({:base => %w(wget alien) }, :base) send(run_method, "wget -Ncq #{packages.join(' ')}", ) files=packages.collect { |package| File.basename(package) } send(run_method, "alien -i #{files.join(' ')}", ) end |
#update(options = {}) ⇒ Object
Run an apt update.
60 61 62 |
# File 'lib/vmbuilder_plugins/apt.rb', line 60 def update(={}) send(run_method, %{sh -c "#{APT_GET} -qy update"}, ) end |
#upgrade(options = {}) ⇒ Object
Run an apt upgrade. Use dist_upgrade instead if you want to upgrade the critical base packages.
55 56 57 |
# File 'lib/vmbuilder_plugins/apt.rb', line 55 def upgrade(={}) send(run_method, %{sh -c "#{APT_GET} -qy upgrade"}, ) end |