Package yum :: Class YumBase
[hide private]
[frames] | no frames]

Class YumBase

source code


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.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__del__(self) source code
 
close(self) source code
 
_transactionDataFactory(self)
Factory method returning TransactionData object
source code
 
doGenericSetup(self, cache=0)
do a default setup for all the normal/necessary yum components, really just a shorthand for testing
source code
 
doConfigSetup(self, fn='/etc/yum/yum.conf', root='/', init_plugins=True, plugin_types=(0), optparser=None, debuglevel=None, errorlevel=None) source code
 
_getConfig(self, **kwargs)
Parse and load Yum's configuration files and call hooks initialise plugins and logging.
source code
 
doLoggingSetup(self, debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log')
Perform logging related setup.
source code
 
doFileLogSetup(self, uid, logfile) source code
 
getReposFromConfigFile(self, repofn, repo_age=None, validate=None)
read in repositories from a config .repo file
source code
 
getReposFromConfig(self)
read in repositories from config main and .repo files
source code
 
readRepoConfig(self, parser, section)
Parse an INI file section for a repository.
source code
 
disablePlugins(self)
Disable yum plugins
source code
 
doPluginSetup(self, optparser=None, plugin_types=None, searchpath=None, confpath=None, disabled_plugins=None, enabled_plugins=None)
Initialise and enable yum plugins.
source code
 
doRpmDBSetup(self) source code
 
_getRpmDB(self)
sets up a holder object for important information from the rpmdb
source code
 
closeRpmDB(self)
closes down the instances of the rpmdb we have wangling around
source code
 
_deleteTs(self) source code
 
doRepoSetup(self, thisrepo=None) source code
 
_getRepos(self, thisrepo=None, doSetup=False)
For each enabled repository set up the basics of the repository.
source code
 
_delRepos(self) source code
 
doSackSetup(self, archlist=None, thisrepo=None) source code
 
_getSacks(self, archlist=None, thisrepo=None)
populates the package sacks for information from our repositories, takes optional archlist for archs to include
source code
 
_delSacks(self)
reset the package sacks back to zero - making sure to nuke the ones in the repo objects, too - where it matters
source code
 
doUpdateSetup(self) source code
 
_getUpdates(self)
setups up the update object in the base class and fills out the updates, obsoletes and others lists
source code
 
doGroupSetup(self) source code
 
_setGroups(self, val) source code
 
_getGroups(self)
create the groups object that will store the comps metadata finds the repos with groups, gets their comps data and merge it into the group object
source code
 
_getTags(self)
create the tags object used to search/report from the pkgtags metadata
source code
 
_getHistory(self)
auto create the history object that to access/append the transaction history information.
source code
 
doSackFilelistPopulate(self)
convenience function to populate the repos with the filelist metadata it also is simply to only emit a log if anything actually gets populated
source code
 
yumUtilsMsg(self, func, prog)
Output a message that the tool requires the yum-utils package, if not installed.
source code
 
buildTransaction(self, unfinished_transactions_check=True)
go through the packages in the transaction set, find them in the packageSack or rpmdb, and pack up the ts accordingly
source code
 
_doSkipBroken(self, rescode, restring, clear_skipped=True)
do skip broken if it is enabled
source code
 
_skipPackagesWithProblems(self, rescode, restring)
Remove the packages with depsolve errors and depsolve again
source code
 
_checkMissingObsoleted(self)
If multiple packages is obsoleting the same package then the TS_OBSOLETED can get removed from the transaction so we must make sure that they, exist and else create them
source code
 
_checkUpdatedLeftovers(self)
If multiple packages is updated the same package and this package get removed because of an dep issue then make sure that all the TS_UPDATED get removed.
source code
 
_getPackagesToRemoveAllArch(self, po)
get all compatible arch packages in pkgSack
source code
 
_skipFromTransaction(self, po) source code
 
_removePoFromTransaction(self, po) source code
 
_buildDepTree(self)
create a dictionary with po and deps
source code
 
_printDepTree(self, tree) source code
 
_printTransaction(self) source code
 
_getPackagesToRemove(self, po, deptree, toRemove)
get the (related) pos to remove.
source code
 
_getDepsToRemove(self, po, deptree, toRemove) source code
 
_rpmdb_warn_checks(self, out=None, warn=True, chkcmd='all') source code
 
runTransaction(self, cb)
takes an rpm callback object, performs the transaction
source code
 
verifyTransaction(self, resultobject=None)
checks that the transaction did what we expected it to do.
source code
 
costExcludePackages(self)
Create an excluder for repos.
source code
 
excludePackages(self, repo=None)
removes packages from packageSacks based on global exclude lists, command line excludes and per-repository excludes, takes optional repo object to use.
source code
 
includePackages(self, repo)
removes packages from packageSacks based on list of packages, to include.
source code
 
doLock(self, lockfile='/var/run/yum.pid')
perform the yum locking, raise yum-based exceptions, not OSErrors
source code
 
doUnlock(self, lockfile=None)
do the unlock for yum
source code
 
_lock(self, filename, contents='', mode=511) source code
 
_unlock(self, filename) source code
 
verifyPkg(self, fo, po, raiseError)
verifies the package is what we expect it to be raiseError = defaults to 0 - if 1 then will raise a URLGrabError if the file does not check out.
source code
 
verifyChecksum(self, fo, checksumType, csum)
Verify the checksum of the file versus the provided checksum
source code
 
downloadPkgs(self, pkglist, callback=None, callback_total=None) source code
 
verifyHeader(self, fo, po, raiseError)
check the header out via it's naevr, internally
source code
 
downloadHeader(self, po)
download a header from a package object.
source code
 
sigCheckPkg(self, po)
Take a package object and attempt to verify GPG signature if required
source code
 
cleanUsedHeadersPackages(self) source code
 
cleanHeaders(self) source code
 
cleanPackages(self) source code
 
cleanSqlite(self) source code
 
cleanMetadata(self) source code
 
cleanExpireCache(self) source code
 
cleanRpmDB(self) source code
 
_cleanFiles(self, exts, pathattr, filetype) source code
 
_cleanFilelist(self, filetype, filelist) source code
 
doPackageLists(self, pkgnarrow='all', patterns=None, showdups=None, ignore_case=False)
generates lists of packages, un-reduced, based on pkgnarrow option
source code
 
findDeps(self, pkgs)
Return the dependencies for a given package object list, as well possible solutions for those dependencies.
source code
 
searchGenerator(self, fields, criteria, showdups=True, keys=False)
Generator method to lighten memory load for some searches.
source code
 
searchPackageTags(self, criteria) source code
 
searchPackages(self, fields, criteria, callback=None)
Search specified fields for matches to criteria optional callback specified to print out results as you go.
source code
 
searchPackageProvides(self, args, callback=None, callback_has_matchfor=False) source code
 
doGroupLists(self, uservisible=0, patterns=None, ignore_case=True)
returns two lists of groups, installed groups and available groups optional 'uservisible' bool to tell it whether or not to return only groups marked as uservisible
source code
 
groupRemove(self, grpid)
mark all the packages in this group to be removed
source code
 
groupUnremove(self, grpid)
unmark any packages in the group from being removed
source code
 
selectGroup(self, grpid, group_package_types=[], enable_group_conditionals=None)
mark all the packages in the group to be installed returns a list of transaction members it added to the transaction set Optionally take: group_package_types=List - overrides self.conf.group_package_types enable_group_conditionals=Bool - overrides self.conf.enable_group_conditionals
source code
 
deselectGroup(self, grpid, force=False)
Without the force option set, this removes packages from being installed that were added as part of installing one of the group(s).
source code
 
getPackageObject(self, pkgtup)
retrieves a packageObject from a pkgtuple - if we need to pick and choose which one is best we better call out to some method from here to pick the best pkgobj if there are more than one response - right now it's more rudimentary.
source code
 
getInstalledPackageObject(self, pkgtup)
Returns a YumInstalledPackage object for the pkgtup specified, or raises an exception.
source code
 
gpgKeyCheck(self)
checks for the presence of gpg keys in the rpmdb returns 0 if no keys returns 1 if keys
source code
 
returnPackagesByDep(self, depstring)
Pass in a generic [build]require string and this function will pass back the packages it finds providing that dep.
source code
 
returnPackageByDep(self, depstring)
Pass in a generic [build]require string and this function will pass back the best(or first) package it finds providing that dep.
source code
 
returnInstalledPackagesByDep(self, depstring)
Pass in a generic [build]require string and this function will pass back the installed packages it finds providing that dep.
source code
 
_bestPackageFromList(self, pkglist)
take list of package objects and return the best package object.
source code
 
bestPackagesFromList(self, pkglist, arch=None, single_name=False)
Takes a list of packages, returns the best packages.
source code
 
_pkg2obspkg(self, po)
Given a package return the package it's obsoleted by and so we should install instead.
source code
 
_test_loop(self, node, next_func)
Generic comp.
source code
 
_at_groupinstall(self, pattern)
Do groupinstall via.
source code
 
_at_groupremove(self, pattern)
Do groupremove via.
source code
 
_at_groupdowngrade(self, pattern)
Do downgrade of a group via.
source code
 
_find_obsoletees(self, po)
Return the pkgs.
source code
 
_add_prob_flags(self, *flags)
Add all of the passed flags to the tsInfo.probFilterFlags array.
source code
 
install(self, po=None, **kwargs)
try to mark for install the item specified.
source code
 
_check_new_update_provides(self, opkg, npkg)
Check for any difference in the provides of the old and new update that is needed by the transaction.
source code
 
_newer_update_in_trans(self, pkgtup, available_pkg, tx_return)
We return True if there is a newer package already in the transaction.
source code
 
_add_up_txmbr(self, requiringPo, upkg, ipkg) source code
 
update(self, po=None, requiringPo=None, **kwargs)
try to mark for update the item(s) specified.
source code
 
remove(self, po=None, **kwargs)
try to find and mark for remove the specified package(s) - if po is specified then that package object (if it is installed) will be marked for removal.
source code
 
installLocal(self, pkg, po=None, updateonly=False)
handles installs/updates of rpms provided on the filesystem in a local dir (ie: not from a repo)
source code
 
reinstallLocal(self, pkg, po=None)
handles reinstall of rpms provided on the filesystem in a local dir (ie: not from a repo)
source code
 
reinstall(self, po=None, **kwargs)
Setup the problem filters to allow a reinstall to work, then pass everything off to install
source code
 
downgradeLocal(self, pkg, po=None)
handles downgrades of rpms provided on the filesystem in a local dir (ie: not from a repo)
source code
 
_is_local_exclude(self, po, pkglist)
returns True if the local pkg should be excluded
source code
 
downgrade(self, po=None, **kwargs)
Try to downgrade a package.
source code
 
_nevra_kwarg_parse(self, kwargs) source code
 
history_redo(self, transaction)
Given a valid historical transaction object, try and repeat that transaction.
source code
 
history_undo(self, transaction)
Given a valid historical transaction object, try and undo that transaction.
source code
 
_retrievePublicKey(self, keyurl, repo=None)
Retrieve a key file
source code
 
getKeyForPackage(self, po, askcb=None, fullaskcb=None)
Retrieve a key for a package.
source code
 
getKeyForRepo(self, repo, callback=None)
Retrieve a key for a repository If needed, prompt for if the key should be imported using callback
source code
 
_limit_installonly_pkgs(self)
Limit packages based on conf.installonly_limit, if any of the packages being installed have a provide in conf.installonlypkgs.
source code
 
processTransaction(self, callback=None, rpmTestDisplay=None, rpmDisplay=None)
Process the current Transaction - Download Packages - Check GPG Signatures.
source code
 
_downloadPackages(self, callback)
Download the need packages in the Transaction
source code
 
_checkSignatures(self, pkgs, callback)
The the signatures of the downloaded packages
source code
 
_askForGPGKeyImport(self, po, userid, hexkeyid)
Ask for GPGKeyImport This need to be overloaded in a subclass to make GPG Key import work
source code
 
_doTestTransaction(self, callback, display=None)
Do the RPM test transaction
source code
 
_doTransaction(self, callback, display=None)
do the RPM Transaction
source code
 
_run_rpm_check_debug(self) source code
 
add_enable_repo(self, repoid, baseurls=[], mirrorlist=None, **kwargs)
add and enable a repo with just a baseurl/mirrorlist and repoid requires repoid and at least one of baseurl and mirrorlist additional optional kwargs are: variable_convert=bool (defaults to true) and any other attribute settable to the normal repo setup ex: metadata_expire, enable_groups, gpgcheck, cachedir, etc returns the repo object it added
source code
 
setCacheDir(self, force=False, tmpdir='/var/tmp', reuse=True, suffix='/$basearch/$releasever')
Set a new cache dir, using misc.getCacheDir() and var.
source code
 
_does_this_update(self, pkg1, pkg2)
returns True if pkg1 can update pkg2, False if not.
source code

Inherited from depsolve.Depsolve: allowedMultipleInstalls, cprof_resolveDeps, doTsSetup, initActionTs, isPackageInstalled, populateTs, prof_resolveDeps, resolveDeps, whatProvides

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
Properties [hide private]
  repos
Repo Storage object - object of yum repositories
  pkgSack
Package sack object - object of yum package objects
  conf
Yum Config Object
  rpmdb
RpmSack object
  tsInfo
Transaction Set information object
  ts
TransactionSet object
  up
Updates Object
  comps
Yum Component/groups object
  history
Yum History Object
  pkgtags
Yum Package Tags Object

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

_getConfig(self, **kwargs)

source code 

Parse and load Yum's configuration files and call hooks initialise plugins and logging. Uses self.preconf for pre-configuration, configuration.

doLoggingSetup(self, debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log')

source code 

Perform logging related setup.

Parameters:
  • debuglevel - Debug logging level to use.
  • errorlevel - Error logging level to use.

readRepoConfig(self, parser, section)

source code 

Parse an INI file section for a repository.

Parameters:
  • parser - ConfParser or similar to read INI file values from.
  • section - INI file section to read.
Returns:
YumRepository instance.

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

source code 

Initialise and enable yum plugins.

Note: _getConfig() will 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 for this run (optional)
  • 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 - Plugins to be disabled
  • enabled_plugins - Plugins to be enabled

verifyTransaction(self, resultobject=None)

source code 

checks that the transaction did what we expected it to do. Also propagates our external yumdb info

costExcludePackages(self)

source code 

Create an excluder for repos. with higher cost. Eg. repo-A:cost=1 repo-B:cost=2 ... here we setup an excluder on repo-B that looks for pkgs in repo-B.

includePackages(self, repo)

source code 

removes packages from packageSacks based on list of packages, to include. takes repoid as a mandatory argument.

verifyPkg(self, fo, po, raiseError)

source code 

verifies the package is what we expect it to be raiseError = defaults to 0 - if 1 then will raise a URLGrabError if the file does not check out. otherwise it returns false for a failure, true for success

downloadHeader(self, po)

source code 

download a header from a package object. output based on callback, raise yum.Errors.YumBaseError on problems

sigCheckPkg(self, po)

source code 

Take a package object and attempt to verify GPG signature if required

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.

findDeps(self, pkgs)

source code 

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

Returns the deps as a dict of dicts:

   packageobject = [reqs] = [list of satisfying pkgs]

searchGenerator(self, fields, criteria, showdups=True, keys=False)

source code 

Generator method to lighten memory load for some searches. This is the preferred search function to use. Setting keys to True will use the search keys that matched in the sorting, and return the search keys in the results.

searchPackages(self, fields, criteria, callback=None)

source code 

Search specified fields for matches to criteria optional callback specified to print out results as you go. Callback is a simple function of: callback(po, matched values list). It will just return a dict of dict[po]=matched values list

deselectGroup(self, grpid, force=False)

source code 

Without the force option set, this removes packages from being installed that were added as part of installing one of the group(s). If the force option is set, then all installing packages in the group(s) are force removed from the transaction.

getInstalledPackageObject(self, pkgtup)

source code 

Returns a YumInstalledPackage object for the pkgtup specified, or raises an exception. You should use this instead of searchPkgTuple() if you are assuming there is a value.

_bestPackageFromList(self, pkglist)

source code 

take list of package objects and return the best package object. If the list is empty, return None.

Note: this is not aware of multilib so make sure you're only passing it packages of a single arch group.

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

source code 

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

_pkg2obspkg(self, po)

source code 

Given a package return the package it's obsoleted by and so we should install instead. Or None if there isn't one.

_test_loop(self, node, next_func)

source code 

Generic comp. sci. test for looping, walk the list with two pointers moving one twice as fast as the other. If they are ever == you have a loop. If loop we return None, if no loop the last element.

_at_groupinstall(self, pattern)

source code 

Do groupinstall via. leading @ on the cmd line, for install/update.

_at_groupremove(self, pattern)

source code 

Do groupremove via. leading @ on the cmd line, for remove.

_at_groupdowngrade(self, pattern)

source code 

Do downgrade of a group via. leading @ on the cmd line.

_find_obsoletees(self, po)

source code 

Return the pkgs. that are obsoleted by the po we pass in.

install(self, po=None, **kwargs)

source code 

try to mark for install the item specified. Uses provided package object, if available. If not it uses the kwargs and gets the best packages from the keyword options provided returns the list of txmbr of the items it installs

_check_new_update_provides(self, opkg, npkg)

source code 

Check for any difference in the provides of the old and new update that is needed by the transaction. If so we "update" those pkgs too, to the latest version.

_newer_update_in_trans(self, pkgtup, available_pkg, tx_return)

source code 

We return True if there is a newer package already in the transaction. If there is an older one, we remove it (and update any deps. that aren't satisfied by the newer pkg) and return False so we'll update to this newer pkg.

update(self, po=None, requiringPo=None, **kwargs)

source code 

try to mark for update the item(s) specified. po is a package object - if that is there, mark it for update, if possible else use **kwargs to match the package needing update if nothing is specified at all then attempt to update everything

returns the list of txmbr of the items it marked for update

remove(self, po=None, **kwargs)

source code 

try to find and mark for remove the specified package(s) - if po is specified then that package object (if it is installed) will be marked for removal. if no po then look at kwargs, if neither then raise an exception

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

source code 

handles installs/updates of rpms provided on the filesystem in a local dir (ie: not from a repo)

Return the added transaction members.

Parameters:
  • pkg - a path to an rpm file on disk.
  • po - A YumLocalPackage
  • updateonly - Whether or not true installs are valid.

reinstallLocal(self, pkg, po=None)

source code 

handles reinstall of rpms provided on the filesystem in a local dir (ie: not from a repo)

Return the added transaction members.

Parameters:
  • pkg - a path to an rpm file on disk.
  • po - A YumLocalPackage

downgradeLocal(self, pkg, po=None)

source code 

handles downgrades of rpms provided on the filesystem in a local dir (ie: not from a repo)

Return the added transaction members.

Parameters:
  • pkg - a path to an rpm file on disk.
  • po - A YumLocalPackage

downgrade(self, po=None, **kwargs)

source code 

Try to downgrade a package. Works like: % yum shell <<EOL remove abcd install abcd-<old-version> run EOL

_retrievePublicKey(self, keyurl, repo=None)

source code 

Retrieve a key file

Parameters:
  • keyurl - url to the key to retrieve Returns a list of dicts with all the keyinfo

getKeyForPackage(self, po, askcb=None, fullaskcb=None)

source code 

Retrieve a key for a package. If needed, prompt for if the key should be imported using askcb.

Parameters:
  • po - Package object to retrieve the key of.
  • askcb - Callback function to use for asking for verification. Takes arguments of the po, the userid for the key, and the keyid.
  • fullaskcb - Callback function to use for asking for verification of a key. Differs from askcb in that it gets passed a dictionary so that we can expand the values passed.

getKeyForRepo(self, repo, callback=None)

source code 

Retrieve a key for a repository If needed, prompt for if the key should be imported using callback

Parameters:
  • repo - Repository object to retrieve the key of.
  • callback - Callback function to use for asking for verification of a key. Takes a dictionary of key info.

_limit_installonly_pkgs(self)

source code 

Limit packages based on conf.installonly_limit, if any of the packages being installed have a provide in conf.installonlypkgs. New in 3.2.24: Obey yumdb_info.installonly data.

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

source code 

Process the current Transaction
- Download Packages
- Check GPG Signatures.
- Run Test RPM Transaction
- Run RPM Transaction

callback.event method is called at start/end of each process.

@param callback: callback object (must have an event method)
@param rpmTestDisplay: Name of display class to use in RPM Test Transaction 
@param rpmDisplay: Name of display class to use in RPM Transaction 

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

source code 

Set a new cache dir, using misc.getCacheDir() and var. replace on suffix.

_does_this_update(self, pkg1, pkg2)

source code 

returns True if pkg1 can update pkg2, False if not. This only checks if it can be an update it does not check if it is obsoleting or anything else.


Property Details [hide private]

repos

Repo Storage object - object of yum repositories

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _repos
Delete Method:
unreachable(self)

pkgSack

Package sack object - object of yum package objects

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _pkgSack
Delete Method:
unreachable(self)

conf

Yum Config Object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _conf
Delete Method:
unreachable(self) - _conf

rpmdb

RpmSack object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _rpmdb
Delete Method:
unreachable(self) - _rpmdb

tsInfo

Transaction Set information object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value)
Delete Method:
unreachable(self)

ts

TransactionSet object

Get Method:
unreachable(self)
Delete Method:
unreachable(self)

up

Updates Object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _up
Delete Method:
unreachable(self) - _up

comps

Yum Component/groups object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value)
Delete Method:
unreachable(self) - _comps

history

Yum History Object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _history
Delete Method:
unreachable(self) - _history

pkgtags

Yum Package Tags Object

Get Method:
unreachable(self)
Set Method:
unreachable(self, value) - _tags
Delete Method:
unreachable(self) - _tags