Debian packages

This module provides tools to manage Debian/Ubuntu packages and repositories.
See also
fabtools.require.deb
fabtools.deb.updateindex(_quiet=True)[source]
Update APT package definitions.
fabtools.deb.upgrade(safe=True)[source]
Upgrade all packages.
fabtools.deb.isinstalled(_pkg_name)[source]
Check if a package is installed.
fabtools.deb.install(packages, update=False, options=None, version=None)[source]
Install one or more packages.
If update is True, the package definitions will be updated first, using update_index().
Extra options may be passed to apt-get if necessary.
Example:
import fabtools # Update index, then install a single package fabtools.deb.install(‘build-essential’, update=True) # Install multiple packages fabtools.deb.install([ ‘python-dev’, ‘libxml2-dev’, ]) # Install a specific version fabtools.deb.install(‘emacs’, version=’23.3+1-1ubuntu9’)
fabtools.deb.uninstall(packages, purge=False, options=None)[source]
Remove one or more packages.
If purge is True, the package configuration files will be removed from the system.
Extra options may be passed to apt-get if necessary.
fabtools.deb.preseedpackage(_pkg_name, preseed)[source]
Enable unattended package installation by preseeding debconf parameters.
Example:
import fabtools # Unattended install of Postfix mail server fabtools.deb.preseedpackage(‘postfix’, { ‘postfix/main_mailer_type’: (‘select’, ‘Internet Site’), ‘postfix/mailname’: (‘string’, ‘example.com’), ‘postfix/destinations’: (‘string’, ‘example.com, localhost.localdomain, localhost’), }) fabtools.deb.install(‘postfix’)
fabtools.deb.get_selections()[source]
Get the state of dkpg selections.
Returns a dict with state => [packages].
**fabtools.deb.apt_key_exists(_keyid
)[source]
Check if the given key id exists in apt keyring.
fabtools.deb.addapt_key(_filename=None, url=None, keyid=None, keyserver=’subkeys.pgp.net’, update=False)[source]
Trust packages signed with this public key.
Example:
import fabtools # Varnish signing key from URL and verify fingerprint) fabtools.deb.add_apt_key(keyid=’C4DEFFEB’, url=’http://repo.varnish-cache.org/debian/GPG-key.txt‘) # Nginx signing key from default key server (subkeys.pgp.net) fabtools.deb.add_apt_key(keyid=’7BD9BF62’) # From custom key server fabtools.deb.add_apt_key(keyid=’7BD9BF62’, keyserver=’keyserver.ubuntu.com’) # From a file fabtools.deb.add_apt_key(keyid=’7BD9BF62’, filename=’nginx.asc’
fabtools.deb.last_update_time()[source]
Get the time of last APT index update
This is the last modification time of
/var/lib/apt/periodic/fabtools-update-success-stamp.
Returns
-1** if there was no update before.
Example:
import fabtools print(fabtools.deb.last_update_time()) # 1377603808.02