yum.__init__

The Yum RPM software updater.

_YumPreBaseConf

class yum.__init__._YumPreBaseConf

This is the configuration interface for the YumBase configuration. To change configuration settings such as whether plugins are on or off, or the value of debuglevel, change the values here. Later, when YumBase.conf() is first called, all of the options will be automatically configured.

_YumPreRepoConf

class yum.__init__._YumPreRepoConf

This is the configuration interface for the repos configuration configuration. To change configuration settings such what callbacks are used, change the values here. Later, when YumBase.repos() is first called, all of the options will be automatically configured.

_YumCostExclude

class yum.__init__._YumCostExclude(repo, repos)

This excludes packages that are in repos. of lower cost than the passed repo.

YumBase

class yum.__init__.YumBase

Bases: yum.depsolve.Depsolve

This is a primary structure and base class. It houses the objects and methods needed to perform most things in yum. It is almost an abstract class in that you will need to add your own class above it for most real use.

add_enable_repo(repoid, baseurls=[], mirrorlist=None, **kwargs)

Add and enable a repository.

Parameters:
  • repoid – a string specifying the name of the repository
  • baseurls – a list of strings specifying the urls for the repository. At least one base url, or one mirror, must be given
  • mirrorlist – a list of strings specifying a list of mirrors for the repository. At least one base url, or one mirror must be given
  • kwargs – key word arguments to set any normal repository attribute
Returns:

the new repository that has been added and enabled

bestPackagesFromList(pkglist, arch=None, single_name=False)

Return the best packages from a list of packages. This function is multilib aware, so that it will not compare multilib to singlelib packages.

Parameters:
  • pkglist – the list of packages to return the best packages from
  • arch – packages will be selected that are compatible with the architecture specified by arch
  • single_name – whether to return a single package name
Returns:

a list of the best packages from pkglist

buildTransaction(unfinished_transactions_check=True)

Go through the packages in the transaction set, find them in the packageSack or rpmdb, and pack up the transaction set accordingly.

Parameters:unfinished_transactions_check – whether to check for unfinished transactions before building the new transaction
cleanExpireCache()

Delete the local data saying when the metadata and mirror lists were downloaded for each repository.

cleanHeaders()

Delete the header files from the yum cache.

cleanMetadata()

Delete the metadata files from the yum cache.

cleanPackages()

Delete the package files from the yum cache.

cleanRpmDB()

Delete any cached data from the local rpmdb.

cleanSqlite()

Delete the sqlite files from the yum cache.

cleanUsedHeadersPackages()

Delete the header and package files used in the transaction from the yum cache.

close()

Close the history and repo objects.

closeRpmDB()

Closes down the instances of rpmdb that could be open.

comps

Yum Component/groups object

conf

Yum Config Object

costExcludePackages()

Create an excluder for repositories with higher costs. For example, if repo-A:cost=1 and repo-B:cost=2, this function will set up an excluder on repo-B that looks for packages in repo-B.

deselectGroup(grpid, force=False)

Unmark the packages in the given group from being installed.

Parameters:
  • grpid – the name of the group containing the packages to unmark from installation
  • force – if True, force remove all the packages in the given group from the transaction
disablePlugins()

Disable yum plugins.

doConfigSetup(fn='/etc/yum/yum.conf', root='/', init_plugins=True, plugin_types=(0, ), optparser=None, debuglevel=None, errorlevel=None)

Deprecated. Perform configuration setup.

Parameters:
  • fn – the name of the configuration file to use
  • root – the root directory to use
  • init_plugins – whether to initialize plugins before running yum
  • plugin_types – a tuple containing the types to plugins to load
  • optparser – the option parser to use for configuration
  • debuglevel – the minimum debug logging level to output messages from
  • errorlevel – the minimum error logging level to output messages from
doFileLogSetup(uid, logfile)

Set up the logging file.

Parameters:
  • uid – the user id of the current user
  • logfile – the name of the file to use for logging
doGenericSetup(cache=0)

Do a default setup for all the normal or necessary yum components. This function is really just a shorthand for testing purposes.

Parameters:cache – whether to run in cache only mode, which will run only from the system cache
doGroupLists(uservisible=0, patterns=None, ignore_case=True)

Return two lists of groups: installed groups and available groups.

Parameters:
  • uservisible – If True, only groups marked as uservisible will be returned. Otherwise, all groups will be returned
  • patterns – a list of stings. If given, only groups with names that match the patterns will be included in the lists. If not given, all groups will be included
  • ignore_case – whether to ignore case when determining whether group names match the strings in patterns
doGroupSetup()

Deprecated. Create and populate the groups object.

doLock(lockfile='/var/run/yum.pid')

Acquire the yum lock.

Parameters:lockfile – the file to use for the lock
Raises :yum.Errors.LockError
doLoggingSetup(debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log')

Perform logging related setup.

Parameters:
  • debuglevel – the minimum debug logging level to output messages from
  • errorlevel – the minimum error logging level to output messages from
  • syslog_ident – the ident of the syslog to use
  • syslog_facility – the name of the syslog facility to use
  • syslog_device – the syslog device to use
doPackageLists(pkgnarrow='all', patterns=None, showdups=None, ignore_case=False)

Return a yum.misc.GenericHolder containing lists of package objects. The contents of the lists are specified in various ways by the arguments.

Parameters:
  • pkgnarrow – a string specifying which types of packages lists to produces, such as updates, installed, available, etc.
  • patterns – a list of names or wildcards specifying packages to list
  • showdups – whether to include duplicate packages in the lists
  • ignore_case – whether to ignore case when searching by package names
Returns:

a yum.misc.GenericHolder instance with the following lists defined:

available = list of packageObjects
installed = list of packageObjects
updates = tuples of packageObjects (updating, installed)
extras = list of packageObjects
obsoletes = tuples of packageObjects (obsoleting, installed)
recent = list of packageObjects

doPluginSetup(optparser=None, plugin_types=None, searchpath=None, confpath=None, disabled_plugins=None, enabled_plugins=None)

Initialise and enable yum plugins. Note: _getConfig() will also initialise plugins if instructed to. Only call this method directly if not calling _getConfig() or calling doConfigSetup(init_plugins=False).

Parameters:
  • optparser – the OptionParser instance to use for this run
  • plugin_types – a sequence specifying the types of plugins to load. This should be a sequence containing one or more of the yum.plugins.TYPE_... constants. If None (the default), all plugins will be loaded
  • searchpath – a list of directories to look in for plugins. A default will be used if no value is specified
  • confpath – a list of directories to look in for plugin configuration files. A default will be used if no value is specified
  • disabled_plugins – a list of plugins to be disabled
  • enabled_plugins – a list plugins to be enabled
doRepoSetup(thisrepo=None)

Deprecated. Set up the yum repositories.

Parameters:thisrepo – the repository to set up. If None, all repositories will be set up
Returns:the set up repos
doRpmDBSetup()

Deprecated. Set up the rpm database.

doSackFilelistPopulate()

Convenience function to populate the repositories with the filelist metadata, and emit a log message only if new information is actually populated.

doSackSetup(archlist=None, thisrepo=None)

Deprecated. Populate the package sacks with information from our repositories.

Parameters:
  • archlist – a list of the names of archs to include. If None, all arches are set up
  • thisrepo – the repository to use. If None, all enabled repositories are used
doUnlock(lockfile=None)

Release the yum lock.

Parameters:lockfile – the lock file to use. If not given, the file that was given as a parameter to the doLock() call that closed the lock is used
doUpdateSetup()

Deprecated. Set up the update object in the base class and populate the updates, obsoletes, and other lists.

downgrade(po=None, **kwargs)

Mark a package to be downgraded. This is equivalent to first removing the currently installed package, and then installing the older version.

Parameters:
  • po – the package object to be marked to be downgraded
  • kwargs – if a package object is not given, the keyword arguments will be used to specify a package to be marked to be downgraded
Returns:

a list of the transaction members added to the transaction set by this method

Raises :

yum.Errors.DowngradeError if no packages are specified or available for downgrade

downgradeLocal(pkg, po=None)

Mark a package on the local filesystem (i.e. not from a repository) to be downgraded.

Parameters:
  • pkg – a string specifying the path to an rpm file in the local filesystem to be marked to be downgraded
  • po – a yum.packages.YumLocalPackage
Returns:

a list of the transaction members added to the transaction set by this method

downloadHeader(po)

Download a header from a package object.

Parameters:po – the package object to download the header from
Raises :yum.Errors.RepoError if there are errors obtaining the header
downloadPkgs(pkglist, callback=None, callback_total=None)

Download the packages specified by the given list of package objects.

Parameters:
  • pkglist – a list of package objects specifying the packages to download
  • callback – unused
  • callback_total – a callback to output messages about the download operation
Returns:

a dictionary containing errors from the downloading process

Raises :

URLGrabError

excludePackages(repo=None)

Remove packages from packageSacks based on global exclude lists, command line excludes and per-repository excludes.

Parameters:repo – a repo object to use. If not given, all repositories are used
findDeps(pkgs)

Return the dependencies for a given package object list, as well as possible solutions for those dependencies.

Parameters:pkgs – a list of package objects
Returns:the dependencies as a dictionary of dictionaries: packageobject = [reqs] = [list of satisfying pkgs]
getCAKeyForRepo(repo, callback=None)

Retrieve a key for a repository. If needed, use the given callback to prompt whether the key should be imported.

Parameters:
  • repo – repository object to retrieve the key of
  • callback – callback function to use for asking for verification of key information
getInstalledPackageObject(pkgtup)

Return a yum.packages.YumInstalledPackage object that corresponds to the given package tuple. This function should be used instead of searchPkgTuple() if you are assuming that the package object exists.

Parameters:pkgtup – the package tuple specifying the package object to return
Returns:a yum.packages.YumInstalledPackage object corresponding to the given package tuple
Raises :a yum.Errors.RpmDBError if the specified package object cannot be found
getKeyForPackage(po, askcb=None, fullaskcb=None)

Retrieve a key for a package. If needed, use the given callback to prompt whether the key should be imported.

Parameters:
  • po – the package object to retrieve the key of
  • askcb – Callback function to use to ask permission to import a key. The arguments askck should take are the package object, the userid of the key, and the keyid
  • fullaskcb – Callback function to use to ask permission to import a key. This differs from askcb in that it gets passed a dictionary so that we can expand the values passed.
Raises :

yum.Errors.YumBaseError if there are errors retrieving the keys

getKeyForRepo(repo, callback=None)

Retrieve a key for a repository. If needed, use the given callback to prompt whether the key should be imported.

Parameters:
  • repo – repository object to retrieve the key of
  • callback – callback function to use for asking for verification of key information
getPackageObject(pkgtup, allow_missing=False)

Return a package object that corresponds to the given package tuple.

Parameters:
  • pkgtup – the package tuple specifying the package object to return
  • allow_missing – If no package corresponding to the given package tuple can be found, None is returned if allow_missing is True, and a yum.Errors.DepError is raised if allow_missing is False.
Returns:

a package object corresponding to the given package tuple

Raises :

a yum.Errors.DepError if no package corresponding to the given package tuple can be found, and allow_missing is False

getReposFromConfig()

Read in repositories from the main yum conf file, and from .repo files. The location of the main yum conf file is given by self.conf.config_file_path, and the location of the directory of .repo files is given by self.conf.reposdir.

getReposFromConfigFile(repofn, repo_age=None, validate=None)

Read in repositories from a config .repo file.

Parameters:
  • repofn – a string specifying the path of the .repo file to read
  • repo_age – the last time that the .repo file was modified, in seconds since the epoch
gpgKeyCheck()

Checks for the presence of GPG keys in the rpmdb.

Returns:0 if there are no GPG keys in the rpmdb, and 1 if there are keys
groupRemove(grpid)

Mark all the packages in the given group to be removed.

Parameters:grpid – the name of the group containing the packages to mark for removal
Returns:a list of transaction members added to the transaction set by this function
groupUnremove(grpid)

Unmark any packages in the given group from being removed.

Parameters:grpid – the name of the group to unmark the packages of
history

Yum History Object

history_redo(transaction)

Repeat the transaction represented by the given yum.history.YumHistoryTransaction object.

Parameters:transaction – a yum.history.YumHistoryTransaction object representing the transaction to be repeated
Returns:whether the transaction was repeated successfully
history_undo(transaction)

Undo the transaction represented by the given yum.history.YumHistoryTransaction object.

Parameters:transaction – a yum.history.YumHistoryTransaction object representing the transaction to be undone
Returns:whether the transaction was undone successfully
includePackages(repo)

Remove packages from packageSacks based on list of packages to include.

Parameters:repo – the repository to use
install(po=None, **kwargs)

Mark the specified item for installation. If a package object is given, mark it for installation. Otherwise, mark the best package specified by the key word arguments for installation.

Parameters:
  • po – a package object to install
  • kwargs – if po is not specified, these keyword arguments will be used to find the best package to install
Returns:

a list of the transaction members added to the transaction set by this function

Raises :

yum.Errors.InstallError if there is a problem installing the package

installLocal(pkg, po=None, updateonly=False)

Mark a package on the local filesystem (i.e. not from a repository) for installation.

Parameters:
  • pkg – a string specifying the path to an rpm file in the local filesystem to be marked for installation
  • po – a yum.packages.YumLocalPackage
  • updateonly – if True, the given package will only be marked for installation if it is an upgrade for a package that is already installed. If False, this restriction is not enforced
Returns:

a list of the transaction members added to the transaction set by this method

load_ts(filename, ignorerpm=None, ignoremissing=None)

Load a transaction from a .yumtx file.

Parameters:
  • filename – the name of the file to load the transaction from
  • ignorerpm – whether to ignore messages from rpm
  • ignoremissing – whether to ignore that there may be transaction members missing
Returns:

the members of the loaded transaction

Raises :

yum.Errors.YumBaseError if there are problems loading the transaction

pkgSack

Package sack object - object of yum package objects

pkgtags

Yum Package Tags Object

processTransaction(callback=None, rpmTestDisplay=None, rpmDisplay=None)

Process the current transaction. This involves the following steps:

  • Download the packages
  • Check the GPG signatures of the packages
  • Run the test RPM transaction
  • Run the RPM Transaction

The callback.event method is called at the start, and between each step.

Parameters:
  • callback – a callback object, which must have an event method
  • rpmTestDisplay – name of the display class to use in the RPM test transaction
  • rpmDisplay – name of the display class to use in the rpm transaction
readRepoConfig(parser, section)

Parse an INI file section for a repository.

Parameters:
  • parserConfigParser or similar object to read INI file values from
  • section – INI file section to read
Returns:

yum.yumRepo.YumRepository instance

reinstall(po=None, **kwargs)

Mark the given package for reinstallation. This is accomplished by setting problem filters to allow a reinstall take place, then calling install().

Parameters:
  • po – the package object to mark for reinstallation
  • kwargs – if po is not given, the keyword will be used to specify a package for reinstallation
Returns:

a list of the transaction members added to the transaction set by this method

Raises :

yum.Errors.ReinstallRemoveError or yum.Errors.ReinstallInstallError depending the nature of the error that is encountered

reinstallLocal(pkg, po=None)

Mark a package on the local filesystem (i.e. not from a repository) for reinstallation.

Parameters:
  • pkg – a string specifying the path to an rpm file in the local filesystem to be marked for reinstallation
  • po – a yum.packages.YumLocalPackage
Returns:

a list of the transaction members added to the transaction set by this method

remove(po=None, **kwargs)

Mark the specified packages for removal. If a package object is given, mark it for removal. Otherwise, mark the package specified by the keyword arguments.

Parameters:
  • po – the package object to mark for installation
  • kwargs – If po is not given, the keyword arguments will be used to specify a package to mark for installation
Returns:

a list of the transaction members that were added to the transaction set by this method

Raises :

yum.Errors.RemoveError if nothing is specified to mark for removal

repos

Repo Storage object - object of yum repositories

returnInstalledPackagesByDep(depstring)

Return a list of installed package objects that provide the given dependencies.

Parameters:depstring – a string specifying the dependency to return the packages that fulfil
Returns:a list of installed packages that fulfil the given dependency
returnPackageByDep(depstring)

Return the best, or first, package object that provides the given dependencies.

Parameters:depstring – a string specifying the dependency to return the package that fulfils
Returns:the best, or first, package that fulfils the given dependency
Raises :a yum.Errors.YumBaseError if no packages that fulfil the given dependency can be found
returnPackagesByDep(depstring)

Return a list of package objects that provide the given dependencies.

Parameters:depstring – a string specifying the dependency to return the packages that fulfil
Returns:a list of packages that fulfil the given dependency
rpmdb

RpmSack object

runTransaction(cb)

Perform the transaction.

Parameters:cb – an rpm callback object to use in the transaction
Returns:a yum.misc.GenericHolder containing information about the results of the transaction
Raises :yum.Errors.YumRPMTransError if there is a transaction cannot be completed
save_ts(filename=None, auto=False)

Save out a transaction to a .yumtx file to be loaded later.

Parameters:
  • filename – the name of the file to save the transaction in. If filename is not given, a name will be generated
  • auto – whether to output errors to the logger, rather than raising exceptions
Raises :

yum.Errors.YumBaseError if there are errors saving the transaction

searchGenerator(fields, criteria, showdups=True, keys=False, searchtags=True, searchrpmdb=True)

Yield the packages that match the given search criteria. This generator method will lighten memory load for some searches, and is the preferred search function to use.

Parameters:
  • fields – the fields to search
  • criteria – a list of strings specifying the criteria to search for
  • showdups – whether to yield duplicate packages from different repositories
  • keys – setting keys to True will use the search keys that matched in the sorting, and return the search keys in the results
  • searchtags – whether to search the package tags
  • searchrpmdb – whether to search the rmpdb
searchPackageProvides(args, callback=None, callback_has_matchfor=False)

Search for and return a list package objects that provide the given files or features.

Parameters:
  • args – a list of strings specifying the files and features to search for the packages that provide
  • callback – a callback function to print out the results as they are found
  • callback_has_matchfor – whether the callback function will accept a list of strings to highlight in its output. If this is true, args will be passed to callback so that the files or features that were searched for can be highlighted
searchPackageTags(criteria)

Search for and return a list packages that have tags matching the given criteria.

Parameters:criteria – a list of strings specifying the criteria to search for
Returns:a list of package objects that have tags matching the given criteria
searchPackages(fields, criteria, callback=None)

Deprecated. Search the specified fields for packages that match the given criteria, and return a list of the results.

Parameters:
  • fields – the fields to seach
  • criteria – a list of strings specifying the criteria to search for
  • callback – a function to print out the results as they are found. callback should have the form callback(po, matched values list)
selectGroup(grpid, group_package_types=[], enable_group_conditionals=None)

Mark all the packages in the given group to be installed.

Parameters:
  • grpid – the name of the group containing the packages to mark for installation
  • group_package_types – a list of the types of groups to work with. This overrides self.conf.group_package_types
  • enable_group_conditionals – overrides self.conf.enable_group_conditionals
Returns:

a list of transaction members added to the transaction set by this function

setCacheDir(force=False, tmpdir=None, reuse=True, suffix='/$basearch/$releasever')

Set a new cache directory.

Parameters:
  • force – whether to force the cache directory to be changed
  • tmpdir – a temporary directory
  • reuse – whether the temporary directory can be reused
  • suffix – suffix to attach to the directory name
Returns:

whether the new cache directory is successfully set

sigCheckPkg(po)

Verify the GPG signature of the given package object.

Parameters:po – the package object to verify the signature of
Returns:(result, error_string) where result is:
0 = GPG signature verifies ok or verification is not required.
1 = GPG verification failed but installation of the right GPG key
      might help.
2 = Fatal GPG verification error, give up.
ts

TransactionSet object

tsInfo

Transaction Set information object

up

Updates Object

update(po=None, requiringPo=None, update_to=False, **kwargs)

Mark the specified items to be updated. If a package object is given, mark it. Else, if a package is specified by the keyword arguments, mark it. Finally, if nothing is given, mark all installed packages to be updated.

Parameters:
  • po – the package object to be marked for updating
  • requiringPo – the package object that requires the upgrade
  • update_to

    if update_to is True, the update will only be run if it will update the given package to the given version. For example, if the package foo-1-2 is installed,:

    updatePkgs(["foo-1-2], update_to=False)

    will work identically to:

    updatePkgs(["foo"])
    

    but:

    updatePkgs(["foo-1-2"], update_to=True)
    

    will do nothing

  • kwargs – if po is not given, the names or wildcards in kwargs will be used to find the packages to update
Returns:

a list of transaction members added to the transaction set by this function

verifyChecksum(fo, checksumType, csum)

Verify that the checksum of the given file matches the given checksum.

Parameters:
  • fo – the file object to verify the checksum of
  • checksumType – the type of checksum to use
Parm csum:

the checksum to check against

Returns:

0 if the checksums match

Raises :

URLGrabError if there is an error performing the checksums, or the checksums do not match

verifyHeader(fo, po, raiseError)

Check that the header of the given file object and matches the given package.

Parameters:
  • fo – the file object to check
  • po – the package object to check
  • raiseError – if raiseError is True, a URLGrabError will be raised if the header matches the package object, or cannot be read from the file. If raiseError is False, 0 will be returned in the above cases
Returns:

1 if the header matches the package object, and 0 if they do not match, and raiseError is False

Raises :

URLGrabError if raiseError is True, and the header does not match the package object or cannot be read from the file

verifyPkg(fo, po, raiseError)

Check that the checksum of a remote package matches what we expect it to be. If the checksum of the package file is wrong, and the file is also larger than expected, it cannot be redeemed, so delete it.

Parameters:
  • fo – the file object of the package
  • po – the package object to verify
  • raiseError – if raiseError is 1, and the package does not check out, a :class:`URLGrabError will be raised. Defaults to 0
Returns:

True if the package is verified successfully. Otherwise, False will be returned, unless raiseError is 1, in which case a URLGrabError will be raised

Raises :

URLGrabError if verification fails, and raiseError is 1

verifyTransaction(resultobject=None)

Check that the transaction did what was expected, and propagate external yumdb information. Output error messages if the transaction did not do what was expected.

Parameters:resultobject – the yum.misc.GenericHolder object returned from the runTransaction() call that ran the transaction
verify_plugins_cb(verify_package)

Callback to call a plugin hook for pkg.verify().

Parameters:verify_package – a conduit for the callback
Returns:verify_package
yumUtilsMsg(func, prog)

Output a message that the given tool requires the yum-utils package, if it not installed.

Parameters:
  • func – the function to output the message
  • prog – the name of the tool that requires yum-utils

Table Of Contents

Previous topic

yum.Errors

Next topic

yum.callbacks

This Page