Sack—The fundamental hawkey structure

class hawkey.Sack

Instances of hawkey.Sack represent collections of packages. An application typically needs at least one instance because it provides much of the hawkey’s functionality.

Warning

Any package instance is not supposed to work interchangeably between hawkey.Query, hawkey.Selector or hawkey.Goal created from different hawkey.Sack. Usually for common tasks there is no need to initialize two or more Sacks in your program. Sacks cannot be deeply copied.

cache_dir

A read-only string property giving the path to the location where a metadata cache is stored.

installonly

A write-only sequence of strings property setting the provide names of packages that should only ever be installed, never upgraded.

installonly_limit

A write-only integer property setting how many installonly packages with the same name are allowed to be installed concurrently. If 0, any number of packages can be installed.

__init__(cachedir=_CACHEDIR, arch=_ARCH, rootdir=_ROOTDIR, pkgcls=hawkey.Package, pkginitval=None, make_cache_dir=False, logfile=_LOGFILE)

Initialize the sack with a default cache directory, log file location set to hawkey.log in the cache directory, an automatically detected architecture and the current root (/) as an installroot. The cache is disabled by default.

cachedir is a string giving a path of a cache location.

arch is a string specifying an architecture.

rootdir is a string giving a path to an installroot.

pkgcls is a class of packages retrieved from the sack. The class’ __init__ method must accept two arguments. The first argument is a tuple of the sack and the ID of the package. The second argument is the pkginitval argument. pkginitval cannot be None if pkgcls is specified.

make_cache_dir is a boolean that specifies whether the cache should be used to speedup loading of repositories or not (see Building and Reusing the Repo Cache).

logfile is a string giving a path of a log file location.

__len__()

Returns the number of the packages loaded into the sack.

add_cmdline_package(filename)

Add a package to a command line repository and return it. The package is specified as a string filename of an RPM file. The command line repository will be automatically created if doesn’t exist already. It could be referenced later by hawkey.CMDLINE_REPO_NAME name.

add_excludes(packages)

Add a sequence of packages that cannot be fetched by Queries nor Selectors.

add_includes(packages)

Add a sequence of the only packages that can be fetched by Queries or Selectors.

This is the inverse operation of add_excludes(). Any package that is not in the union of all the included packages is excluded. This works in conjunction with exclude and doesn’t override it. So, if you both include and exclude the same package, the package is considered excluded no matter of the order.

disable_repo(name)

Disable the repository identified by a string name. Packages in that repository cannot be fetched by Queries nor Selectors.

enable_repo(name)

Enable the repository identified by a string name. Packages in that repository can be fetched by Queries or Selectors.

Warning

Execution of add_excludes(), add_includes(), disable_repo() or enable_repo() methods could cause inconsistent results in previously evaluated Query, Selector or Goal. The rule of thumb is to exclude/include packages, enable/disable repositories at first and then do actual computing using Query, Selector or Goal. For more details see developer discussion.

evr_cmp(evr1, evr2)

Compare two EVR strings and return a negative integer if evr1 < evr2, zero if evr1 == evr2 or a positive integer if evr1 > evr2.

get_running_kernel()

Detect and return the package of the currently running kernel. If the package cannot be found, None is returned.

list_arches()

List strings giving all the supported architectures.

load_system_repo(repo=None, build_cache=False)

Load the information about the packages in the system repository (in Fedora it is the RPM database) into the sack. This makes the dependency solving aware of the already installed packages. The system repository is always set to hawkey.SYSTEM_REPO_NAME. The information is not written to the cache by default.

repo is an optional Repo object that represents the system repository. The object is updated during the loading.

build_cache is a boolean that specifies whether the information should be written to the cache (see Building and Reusing the Repo Cache).

load_repo(repo, build_cache=False, load_filelists=False, load_presto=False, load_updateinfo=False)

Load the information about the packages in a Repo into the sack. This makes the dependency solving aware of these packages. The information is not written to the cache by default.

repo is the Repo object to be processed. At least its Repo.repomd_fn must be set. If the cache has to be updated, Repo.primary_fn is needed too. Some information about the loading process and some results of it are written into the internal state of the repository object.

build_cache is a boolean that specifies whether the information should be written to the cache (see Building and Reusing the Repo Cache).

load_filelists, load_presto and load_updateinfo are booleans that specify whether the Repo.filelists_fn, Repo.presto_fn and Repo.updateinfo_fn files of the repository should be processed. These files may contain information needed for dependency solving, downloading or querying of some packages. Enable it if you are not sure (see Case for Loading the Filelists).