[yum-commits] Branch 'yum-3_2_X' - 3 commits - cli.py output.py shell.py yum/__init__.py yummain.py yum/packages.py yum/transactioninfo.py
James Antill
james at osuosl.org
Thu Jun 2 19:05:22 UTC 2011
cli.py | 6 +++---
output.py | 4 +++-
shell.py | 4 +++-
yum/__init__.py | 33 +++++++++++++++++++++++++++++++--
yum/packages.py | 39 +++++++++++++++++++++++++++++++++++++++
yum/transactioninfo.py | 1 +
yummain.py | 2 ++
7 files changed, 82 insertions(+), 7 deletions(-)
New commits:
commit c33fd8b99c7f797f659eef5795f5f942e470dba3
Author: James Antill <james at and.org>
Date: Thu Jun 2 12:54:19 2011 -0400
Create list of pkgtups we couldn't find, and output them in listTrans.
diff --git a/output.py b/output.py
index 71e4e24..398dafa 100755
--- a/output.py
+++ b/output.py
@@ -1048,7 +1048,9 @@ class YumOutput:
pkglist_lines.append((action, lines))
for (action, pkglist) in [(_('Skipped (dependency problems)'),
- self.skipped_packages),]:
+ self.skipped_packages),
+ (_('Not installed'), self._not_found_i.values()),
+ (_('Not available'), self._not_found_a.values())]:
lines = []
for po in pkglist:
a_wid = _add_line(lines, data, a_wid, po)
diff --git a/yum/__init__.py b/yum/__init__.py
index 209c5c6..77c4d00 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -79,7 +79,7 @@ warnings.simplefilter("ignore", Errors.YumFutureDeprecationWarning)
from packages import parsePackages, comparePoEVR
from packages import YumAvailablePackage, YumLocalPackage, YumInstalledPackage
-from packages import YumUrlPackage
+from packages import YumUrlPackage, YumNotFoundPackage
from constants import *
from yum.rpmtrans import RPMTransaction,SimpleCliCallBack
from yum.i18n import to_unicode, to_str
@@ -182,6 +182,8 @@ class YumBase(depsolve.Depsolve):
self._tags = None
self._ts_save_file = None
self.skipped_packages = [] # packages skip by the skip-broken code
+ self._not_found_a = {}
+ self._not_found_i = {}
self.logger = logging.getLogger("yum.YumBase")
self.verbose_logger = logging.getLogger("yum.verbose.YumBase")
self._override_sigchecks = False
@@ -1225,6 +1227,27 @@ class YumBase(depsolve.Depsolve):
return 1, orig_restring
return rescode, restring
+ def _add_not_found(self, pkgs, nevra_dict):
+ if pkgs:
+ return None
+
+ pkgtup = (nevra_dict['name'], nevra_dict['arch'],
+ nevra_dict['epoch'], nevra_dict['version'],
+ nevra_dict['release'])
+ if None in pkgtup:
+ return None
+ return pkgtup
+ def _add_not_found_a(self, pkgs, nevra_dict):
+ pkgtup = self._add_not_found(pkgs, nevra_dict)
+ if pkgtup is None:
+ return
+ self._not_found_a[pkgtup] = YumNotFoundPackage(pkgtup)
+ def _add_not_found_i(self, pkgs, nevra_dict):
+ pkgtup = self._add_not_found(pkgs, nevra_dict)
+ if pkgtup is None:
+ return
+ self._not_found_i[pkgtup] = YumNotFoundPackage(pkgtup)
+
def _checkMissingObsoleted(self):
"""
If multiple packages is obsoleting the same package
@@ -2973,6 +2996,7 @@ class YumBase(depsolve.Depsolve):
pkgs = self.pkgSack.searchPkgTuple(pkgtup)
if len(pkgs) == 0:
+ self._add_not_found_a(pkgs, pkgtup)
if allow_missing: # This can happen due to excludes after .up has
return None # happened.
raise Errors.DepError, _('Package tuple %s could not be found in packagesack') % str(pkgtup)
@@ -2994,6 +3018,7 @@ class YumBase(depsolve.Depsolve):
pkgs = self.rpmdb.searchPkgTuple(pkgtup)
if len(pkgs) == 0:
+ self._add_not_found_i(pkgs, pkgtup)
raise Errors.RpmDBError, _('Package tuple %s could not be found in rpmdb') % str(pkgtup)
# Dito. FIXME from getPackageObject() for len() > 1 ... :)
@@ -3419,6 +3444,7 @@ class YumBase(depsolve.Depsolve):
pkgs = self.pkgSack.searchNevra(name=nevra_dict['name'],
epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
ver=nevra_dict['version'], rel=nevra_dict['release'])
+ self._add_not_found_a(pkgs, nevra_dict)
if pkgs:
# if was_pattern or nevra-dict['arch'] is none, take the list
@@ -3759,6 +3785,7 @@ class YumBase(depsolve.Depsolve):
availpkgs = self.pkgSack.searchNevra(name=nevra_dict['name'],
epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
ver=nevra_dict['version'], rel=nevra_dict['release'])
+ self._add_not_found_a(availpkgs, nevra_dict)
if len(availpkgs) > 1:
availpkgs = self._compare_providers(availpkgs, requiringPo)
availpkgs = map(lambda x: x[0], availpkgs)
@@ -3949,7 +3976,7 @@ class YumBase(depsolve.Depsolve):
pkgs = self.rpmdb.searchNevra(name=nevra_dict['name'],
epoch=nevra_dict['epoch'], arch=nevra_dict['arch'],
ver=nevra_dict['version'], rel=nevra_dict['release'])
-
+ self._add_not_found_i(pkgs, nevra_dict)
if len(pkgs) == 0:
if not kwargs.get('silence_warnings', False):
self.logger.warning(_("No package matched to remove"))
@@ -4268,6 +4295,8 @@ class YumBase(depsolve.Depsolve):
arch=nevra_dict['arch'],
ver=nevra_dict['version'],
rel=nevra_dict['release'])
+ self._add_not_found_a(apkgs, nevra_dict)
+
if not apkgs:
# Do we still want to return errors here?
# We don't in the cases below, so I didn't here...
diff --git a/yum/packages.py b/yum/packages.py
index 95c50a1..0d16293 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -274,6 +274,15 @@ class PackageObject(object):
def __str__(self):
return self.ui_envra
+ def printVer(self):
+ """returns a printable version string - including epoch, if it's set"""
+ if self.epoch != '0':
+ ver = '%s:%s-%s' % (self.epoch, self.version, self.release)
+ else:
+ ver = '%s-%s' % (self.version, self.release)
+
+ return ver
+
def verCMP(self, other):
""" Compare package to another one, only rpm-version ordering. """
if not other:
@@ -354,6 +363,36 @@ class PackageObject(object):
if csumid:
return (csumtype, csum)
+
+_not_found_repo = FakeRepository('-')
+_not_found_repo.cost = 0
+class YumNotFoundPackage(PackageObject):
+
+ def __init__(self, pkgtup):
+ self.name = pkgtup[0]
+ self.arch = pkgtup[1]
+ self.epoch = pkgtup[2]
+ self.version = pkgtup[3]
+ self.release = pkgtup[4]
+ self.pkgtup = pkgtup
+
+ self.size = 0
+ self._checksums = [] # (type, checksum, id(0,1)
+
+ self.repo = _not_found_repo
+ self.repoid = _not_found_repo.id
+
+ # Fakeout output.py that it's a real pkg. ...
+ def _ui_from_repo(self):
+ """ This just returns '-' """
+ return self.repoid
+ ui_from_repo = property(fget=lambda self: self._ui_from_repo())
+
+ def verifyLocalPkg(self):
+ """check the package checksum vs the localPkg
+ return True if pkg is good, False if not"""
+ return False
+
# This is the virtual base class of actual packages, it basically requires a
# repo. even though it doesn't set one up in it's __init__. It also doesn't have
# PackageObject methods ... so is basically unusable on it's own
commit d9522c3d328465984e27176bf6ded9912e7b8f17
Author: James Antill <james at and.org>
Date: Thu Jun 2 11:54:04 2011 -0400
Return -1 from doTransaction() if user/GPG fails, diff. text. BZ 586690.
diff --git a/cli.py b/cli.py
index f4bd7b1..7ef147d 100644
--- a/cli.py
+++ b/cli.py
@@ -448,7 +448,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# just make sure there's not, well, nothing to do
if len(self.tsInfo) == 0:
self.verbose_logger.info(_('Trying to run the transaction but nothing to do. Exiting.'))
- return 1
+ return -1
# NOTE: In theory we can skip this in -q -y mode, for a slight perf.
# gain. But it's probably doom to have a different code path.
@@ -495,7 +495,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if self._promptWanted():
if not self.userconfirm():
self.verbose_logger.info(_('Exiting on user Command'))
- return 1
+ return -1
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('Downloading Packages:'))
@@ -512,7 +512,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# Check GPG signatures
if self.gpgsigcheck(downloadpkgs) != 0:
- return 1
+ return -1
self.initActionTs()
# save our dsCallback out
diff --git a/shell.py b/shell.py
index 7eef413..999bffc 100644
--- a/shell.py
+++ b/shell.py
@@ -355,11 +355,13 @@ class YumShell(cmd.Cmd):
if e.errno == 32:
self.logger.critical('\n\nExiting on Broken Pipe')
else:
- if returnval not in [0,1]:
+ if returnval not in [0,1,-1]:
self.verbose_logger.info('Transaction encountered a serious error.')
else:
if returnval == 1:
self.verbose_logger.info('There were non-fatal errors in the transaction')
+ elif returnval == -1:
+ self.verbose_logger.info("Transaction didn't start")
self.verbose_logger.log(logginglevels.INFO_2,
'Finished Transaction')
self.base.closeRpmDB()
diff --git a/yummain.py b/yummain.py
index ea85926..e3efd10 100755
--- a/yummain.py
+++ b/yummain.py
@@ -228,6 +228,8 @@ def main(args):
return_code = result
if base._ts_save_file:
verbose_logger.info(_("Your transaction was saved, rerun it with: yum load-transaction %s") % base._ts_save_file)
+ elif return_code < 0:
+ return_code = 1 # Means the pre-transaction checks failed...
else:
verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
commit b19e7994bf28ebd40fe3ccfe002226a14a7a4c16
Author: James Antill <james at and.org>
Date: Thu Jun 2 12:05:50 2011 -0400
Add failed to __init__ of TransData.
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index b0c7ddd..4d89d83 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -104,6 +104,7 @@ class TransactionData:
self.depupdated = []
self.reinstalled = []
self.downgraded = []
+ self.failed = []
def __len__(self):
return len(self.pkgdict)
More information about the Yum-commits
mailing list