client/rhel/yum-rhn-plugin/actions/packages.py | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
New commits: commit b86f1f63a1b17417fde0a6ec2b0da8818c25c55a Author: Milan Zazrivec mzazrivec@redhat.com Date: Wed Feb 9 12:44:18 2011 +0100
675780 - remove installed packages from transaction
This fix is to avoid errors in situations when we try to install packages which are already installed, e.g. when kickstarting a system, we always try to install latest available spacewalk-koan. (cherry picked from commit 02195cc81b728a529a59d34b89e722824d1a1c83)
diff --git a/client/rhel/yum-rhn-plugin/actions/packages.py b/client/rhel/yum-rhn-plugin/actions/packages.py index 1630fee..dd1c527 100644 --- a/client/rhel/yum-rhn-plugin/actions/packages.py +++ b/client/rhel/yum-rhn-plugin/actions/packages.py @@ -304,6 +304,38 @@ def update(package_list, cache_only=None):
log.log_debug("Called update", package_list)
+ # Remove already installed packages from the list + for package in package_list: + pkgkeys = { + 'name' : package[0], + 'epoch' : package[3], + 'version' : package[1], + 'release' : package[2], + } + + if len(package) > 4: + pkgkeys['arch'] = package[4] + else: + package.append('') + pkgkeys['arch'] = None + + if pkgkeys['epoch'] == '': + pkgkeys['epoch'] = '0' + + pkgs = yum_base.rpmdb.searchNevra(name=pkgkeys['name'], + epoch=pkgkeys['epoch'], arch=pkgkeys['arch'], + ver=pkgkeys['version'], rel=pkgkeys['release']) + + if pkgs: + log.log_debug('Package %s already installed and latest version' + % _yum_package_tup(package)) + package_list.remove(package) + + # Don't proceed further with empty list, + # since this would result into an empty yum transaction + if not package_list: + return (0, "Requested packages already installed", {}) + transaction_data = __make_transaction(package_list, 'i')
return _runTransaction(transaction_data, cache_only)
spacewalk-commits@lists.fedorahosted.org