avocado.utils.software_manager.backends package

Submodules

avocado.utils.software_manager.backends.apt module

class avocado.utils.software_manager.backends.apt.AptBackend

Bases: avocado.utils.software_manager.backends.dpkg.DpkgBackend

Implements the apt backend for software manager.

Set of operations for the apt package manager, commonly found on Debian and Debian based distributions, such as Ubuntu Linux.

Initializes the base command and the debian package repository.

add_repo(repo)

Add an apt repository.

Parameters

repo – Repository string. Example: ‘deb http://archive.ubuntu.com/ubuntu/ maverick universe’

build_dep(name)

Installed build-dependencies of a given package [name].

Parameters

name – parameter package to install build-dependencies for.

Return True

If packages are installed properly

get_source(name, path)

Download source for provided package. Returns the path with source placed.

Parameters

name – parameter wildcard package to get the source for

Return path

path of ready-to-build source

install(name)

Installs package [name].

Parameters

name – Package name.

provides(name)

Return a list of packages that provide [name of package/file].

Parameters

name – File name.

remove(name)

Remove package [name].

Parameters

name – Package name.

remove_repo(repo)

Remove an apt repository.

Parameters

repo – Repository string. Example: ‘deb http://archive.ubuntu.com/ubuntu/ maverick universe’

upgrade(name=None)

Upgrade all packages of the system with eventual new versions.

Optionally, upgrade individual packages.

Parameters

name (str) – optional parameter wildcard spec to upgrade

avocado.utils.software_manager.backends.base module

class avocado.utils.software_manager.backends.base.BaseBackend

Bases: object

This class implements all common methods among backends.

install_what_provides(path)

Installs package that provides [path].

Parameters

path – Path to file.

avocado.utils.software_manager.backends.dnf module

class avocado.utils.software_manager.backends.dnf.DnfBackend

Bases: avocado.utils.software_manager.backends.yum.YumBackend

Implements the dnf backend for software manager.

DNF is the successor to yum in recent Fedora.

Initializes the base command and the DNF package repository.

build_dep(name)

Install build-dependencies for package [name]

Parameters

name – name of the package

Return True

If build dependencies are installed properly

avocado.utils.software_manager.backends.dpkg module

class avocado.utils.software_manager.backends.dpkg.DpkgBackend

Bases: avocado.utils.software_manager.backends.base.BaseBackend

This class implements operations executed with the dpkg package manager.

dpkg is a lower level package manager, used by higher level managers such as apt and aptitude.

INSTALLED_OUTPUT = 'install ok installed'
PACKAGE_TYPE = 'deb'
check_installed(name)
static extract_from_package(package_path, dest_path=None)

Extracts the package content to a specific destination path.

Parameters
  • package_path (str) – path to the deb package.

  • dest_path – destination path to extract the files. Default is the current directory.

Returns

path of the extracted file

Returns

the path of the extracted files.

Return type

str

static is_valid(package_path)

Verifies if a package is a valid deb file.

Parameters

package_path (str) – .deb package path.

Returns

True if valid, otherwise false.

Return type

bool

static list_all()

List all packages available in the system.

list_files(package)

List files installed by package [package].

Parameters

package – Package name.

Returns

List of paths installed by package.

avocado.utils.software_manager.backends.rpm module

class avocado.utils.software_manager.backends.rpm.RpmBackend

Bases: avocado.utils.software_manager.backends.base.BaseBackend

This class implements operations executed with the rpm package manager.

rpm is a lower level package manager, used by higher level managers such as yum and zypper.

PACKAGE_TYPE = 'rpm'
SOFTWARE_COMPONENT_QRY = 'rpm %{NAME} %{VERSION} %{RELEASE} %{SIGMD5} %{ARCH}'
check_installed(name, version=None, arch=None)

Check if package [name] is installed.

Parameters
  • name – Package name.

  • version – Package version.

  • arch – Package architecture.

static extract_from_package(package_path, dest_path=None)

Extracts the package content to a specific destination path.

Parameters
  • package_path (str) – path to the rpm package.

  • dest_path – destination path to extract the files. Default it will be the current directory.

Returns

path of the extracted file

Returns

the path of the extracted files.

Return type

str

find_rpm_packages(rpm_dir)

Extract product dependencies from a defined RPM directory and all its subdirectories.

Parameters

rpm_dir (str) – directory to search in

Returns

found RPM packages

Return type

[str]

static is_valid(package_path)

Verifies if a package is a valid rpm file.

Parameters

package_path (str) – .rpm package path.

Returns

True if valid, otherwise false.

Return type

bool

list_all(software_components=True)

List all installed packages.

Parameters

software_components – log in a format suitable for the SoftwareComponent schema

static list_files(name)

List files installed on the system by package [name].

Parameters

name – Package name.

perform_setup(packages, no_dependencies=False)

General RPM setup with automatic handling of dependencies based on install attempts.

Parameters

packages ([str]) – the RPM packages to install in dependency-friendly order

Returns

whether setup completed successfully

Return type

bool

static prepare_source(spec_file, dest_path=None)

Rpmbuild the spec path and return build dir

Parameters

spec_path – spec path to install

Return path

build directory

static rpm_erase(package_name)

Erase an RPM package.

Parameters

package_name (str) – name of the erased package

Returns

whether file is erased properly

Return type

bool

static rpm_install(file_path, no_dependencies=False, replace=False)

Install the rpm file [file_path] provided.

Parameters
  • file_path (str) – file path of the installed package

  • no_dependencies (bool) – whether to add “nodeps” flag

  • replace (bool) – whether to replace existing package

Returns

whether file is installed properly

Return type

bool

static rpm_verify(package_name)

Verify an RPM package with an installed one.

Parameters

package_name (str) – name of the verified package

Returns

whether the verification was successful

Return type

bool

avocado.utils.software_manager.backends.yum module

class avocado.utils.software_manager.backends.yum.YumBackend(cmd='yum')

Bases: avocado.utils.software_manager.backends.rpm.RpmBackend

Implements the yum backend for software manager.

Set of operations for the yum package manager, commonly found on Yellow Dog Linux and Red Hat based distributions, such as Fedora and Red Hat Enterprise Linux.

Initializes the base command and the yum package repository.

REPO_FILE_PATH = '/etc/yum.repos.d/avocado-managed.repo'

Path to the repository managed by Avocado

add_repo(url)

Adds package repository located on [url].

Parameters

url – Universal Resource Locator of the repository.

static build_dep(name)

Install build-dependencies for package [name]

Parameters

name – name of the package

Return True

If build dependencies are installed properly

get_source(name, dest_path)

Downloads the source package and prepares it in the given dest_path to be ready to build.

Parameters
  • name – name of the package

  • dest_path – destination_path

Return final_dir

path of ready-to-build directory

install(name)

Installs package [name]. Handles local installs.

provides(name)

Returns a list of packages that provides a given capability.

Parameters

name – Capability name (eg, ‘foo’).

remove(name)

Removes package [name].

Parameters

name – Package name (eg. ‘ipython’).

remove_repo(url)

Removes package repository located on [url].

Parameters

url – Universal Resource Locator of the repository.

property repo_config_parser
upgrade(name=None)

Upgrade all available packages.

Optionally, upgrade individual packages.

Parameters

name (str) – optional parameter wildcard spec to upgrade

property yum_base

avocado.utils.software_manager.backends.zypper module

class avocado.utils.software_manager.backends.zypper.ZypperBackend

Bases: avocado.utils.software_manager.backends.rpm.RpmBackend

Implements the zypper backend for software manager.

Set of operations for the zypper package manager, found on SUSE Linux.

Initializes the base command and the yum package repository.

add_repo(url)

Adds repository [url].

Parameters

url – URL for the package repository.

build_dep(name)

Return True if build-dependencies are installed for provided package

Keyword argument: name – name of the package

get_source(name, dest_path)

Downloads the source package and prepares it in the given dest_path to be ready to build

Parameters
  • name – name of the package

  • dest_path – destination_path

Return final_dir

path of ready-to-build directory

install(name)

Installs package [name]. Handles local installs.

Parameters

name – Package Name.

provides(name)

Searches for what provides a given file.

Parameters

name – File path.

remove(name)

Removes package [name].

remove_repo(url)

Removes repository [url].

Parameters

url – URL for the package repository.

upgrade(name=None)

Upgrades all packages of the system.

Optionally, upgrade individual packages.

Parameters

name (str) – Optional parameter wildcard spec to upgrade

Module contents