[yum-commits] Branch 'yum-3_2_X' - 5 commits - cli.py output.py yum/depsolve.py yum/transactioninfo.py yum/yumRepo.py
James Antill
james at osuosl.org
Fri Apr 24 16:34:48 UTC 2009
cli.py | 5 ++
output.py | 87 +++++++++++++++++++++++++++++++++++++++++++------
yum/depsolve.py | 25 ++++++++++++--
yum/transactioninfo.py | 7 +--
yum/yumRepo.py | 15 ++++++--
5 files changed, 119 insertions(+), 20 deletions(-)
New commits:
commit 84cd637e0d95ffad1e810752ed036734098fc350
Author: James Antill <james at and.org>
Date: Fri Apr 24 12:34:40 2009 -0400
Add prestodelta to the MD lists
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b621032..e94e889 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -256,7 +256,7 @@ class YumRepository(Repository, config.RepoConf):
self.copy_local = 0
# holder for stuff we've grabbed
self.retrieved = { 'primary':0, 'filelists':0, 'other':0, 'group':0,
- 'updateinfo':0}
+ 'updateinfo':0, 'prestodelta' : 0}
# callbacks
self.callback = None # for the grabber
@@ -1315,9 +1315,11 @@ class YumRepository(Repository, config.RepoConf):
return self._groupLoadRepoXML(text)
if self.mdpolicy in ["group:main"]:
return self._groupLoadRepoXML(text, ["primary", "group",
- "filelists", "updateinfo"])
+ "filelists", "updateinfo",
+ "prestodelta"])
if self.mdpolicy in ["group:small"]:
- return self._groupLoadRepoXML(text, ["primary", "updateinfo"])
+ return self._groupLoadRepoXML(text, ["primary", "updateinfo",
+ "prestodelta"])
if self.mdpolicy in ["group:primary"]:
return self._groupLoadRepoXML(text, ["primary"])
except KeyboardInterrupt:
commit cf35046590232fa041a618622d71993386cd262c
Author: James Antill <james at and.org>
Date: Fri Apr 24 12:30:25 2009 -0400
Catch Errors.RepoMDError, for not valid mdtype, and report
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index db3d44b..b621032 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1433,7 +1433,12 @@ class YumRepository(Repository, config.RepoConf):
def _retrieveMD(self, mdtype, retrieve_can_fail=False):
""" Internal function, use .retrieveMD() from outside yum. """
- thisdata = self.repoXML.getData(mdtype)
+ try:
+ thisdata = self.repoXML.getData(mdtype)
+ except Errors.RepoMDError, e: # mdtype not in repo
+ if retrieve_can_fail:
+ return None
+ raise Errors.RepoError, e.message
(r_base, remote) = thisdata.location
fname = os.path.basename(remote)
commit 35a7f1276b3a99e307770ee371a2387282a6c684
Author: James Antill <james at and.org>
Date: Thu Apr 23 19:34:47 2009 -0400
Add callbacks (back compat.) to show packages in requires/conflicts msgs
diff --git a/output.py b/output.py
index db28d95..4cf8734 100755
--- a/output.py
+++ b/output.py
@@ -1197,6 +1197,11 @@ class DepSolveProgressCallBack:
_('--> Processing Dependency: %s for package: %s'), formatted_req,
name)
+ def procReqPo(self, po, formatted_req):
+ self.verbose_logger.log(logginglevels.INFO_2,
+ _('--> Processing Dependency: %s for package: %s'), formatted_req,
+ po)
+
def unresolved(self, msg):
self.verbose_logger.log(logginglevels.INFO_2, _('--> Unresolved Dependency: %s'),
msg)
@@ -1207,6 +1212,11 @@ class DepSolveProgressCallBack:
_('--> Processing Conflict: %s conflicts %s'),
name, confname)
+ def procConflictPo(self, po, confname):
+ self.verbose_logger.log(logginglevels.INFO_2,
+ _('--> Processing Conflict: %s conflicts %s'),
+ po, confname)
+
def transactionPopulation(self):
self.verbose_logger.log(logginglevels.INFO_2, _('--> Populating transaction set '
'with selected packages. Please wait.'))
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 0c09a2c..370d12a 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -263,6 +263,17 @@ class Depsolve(object):
self.verbose_logger.log(logginglevels.DEBUG_1,
_('Removing Package %s'), txmbr.po)
+ def _dscb_procReq(self, po, niceformatneed):
+ """ Call the callback for processing requires, call the nicest one
+ available. """
+ if not self.dsCallback:
+ return
+
+ if hasattr(self.dsCallback, 'procReqPo'):
+ self.dsCallback.procReqPo(po, niceformatneed)
+ else:
+ self.dsCallback.procReq(po.name, niceformatneed)
+
def _processReq(self, po, requirement):
"""processes a Requires dep from the resolveDeps functions, returns a tuple
of (CheckDeps, missingdep, conflicts, errors) the last item is an array
@@ -273,7 +284,7 @@ class Depsolve(object):
needname, flags, needversion = requirement
niceformatneed = rpmUtils.miscutils.formatRequire(needname, needversion, flags)
self.verbose_logger.log(logginglevels.DEBUG_1, _('%s requires: %s'), po, niceformatneed)
- if self.dsCallback: self.dsCallback.procReq(po.name, niceformatneed)
+ self._dscb_procReq(po, niceformatneed)
try:
if po.repo.id != "installed":
@@ -596,6 +607,16 @@ class Depsolve(object):
return checkdeps, missingdep
+ def _dscb_procConflict(self, po, niceformatneed):
+ """ Call the callback for processing requires, call the nicest one
+ available. """
+ if not self.dsCallback:
+ return
+
+ if hasattr(self.dsCallback, 'procConflictPo'):
+ self.dsCallback.procConflictPo(po, niceformatneed)
+ else:
+ self.dsCallback.procConflict(po.name, niceformatneed)
def _processConflict(self, po, conflict, conflicting_po):
"""processes a Conflict dep from the resolveDeps() method"""
@@ -607,7 +628,7 @@ class Depsolve(object):
(name, arch, epoch, ver, rel) = po.pkgtup
niceformatneed = rpmUtils.miscutils.formatRequire(needname, needversion, flags)
- if self.dsCallback: self.dsCallback.procConflict(name, niceformatneed)
+ self._dscb_procConflict(po, niceformatneed)
length = len(self.tsInfo)
if flags & rpm.RPMSENSE_LESS:
commit af47f93fc73d88de315781ff22ceebac05f854d0
Author: James Antill <james at and.org>
Date: Thu Apr 23 13:36:06 2009 -0400
Try to convert pkgname into pkg, to work around rpm event
diff --git a/cli.py b/cli.py
index 9abf843..8d6eaf7 100644
--- a/cli.py
+++ b/cli.py
@@ -28,6 +28,8 @@ import logging
from optparse import OptionParser,OptionGroup
import rpm
+from weakref import proxy as weakref
+
import output
import shell
import yum
@@ -468,7 +470,8 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# put back our depcheck callback
self.dsCallback = dscb
# setup our rpm ts callback
- cb = RPMTransaction(self, display=output.YumCliRPMCallBack)
+ cb = RPMTransaction(self,
+ display=output.YumCliRPMCallBack(weakref(self)))
if self.conf.debuglevel < 2:
cb.display.output = False
diff --git a/output.py b/output.py
index 099f8fc..db28d95 100755
--- a/output.py
+++ b/output.py
@@ -26,6 +26,8 @@ import rpm
import re # For YumTerm
+from weakref import proxy as weakref
+
from urlgrabber.progress import TextMeter
import urlgrabber.progress
from urlgrabber.grabber import URLGrabError
@@ -1089,7 +1091,7 @@ Remove %5.5s Package(s)
self.repos.setInterruptCallback(self.interrupt_callback)
# setup our depsolve progress callback
- dscb = DepSolveProgressCallBack()
+ dscb = DepSolveProgressCallBack(weakref(self))
self.dsCallback = dscb
def setupProgessCallbacks(self):
@@ -1156,11 +1158,12 @@ Remove %5.5s Package(s)
class DepSolveProgressCallBack:
"""provides text output callback functions for Dependency Solver callback"""
- def __init__(self):
+ def __init__(self, ayum=None):
"""requires yum-cli log and errorlog functions as arguments"""
self.verbose_logger = logging.getLogger("yum.verbose.cli")
self.loops = 0
-
+ self.ayum = ayum
+
def pkgAdded(self, pkgtup, mode):
modedict = { 'i': _('installed'),
'u': _('updated'),
@@ -1193,8 +1196,7 @@ class DepSolveProgressCallBack:
self.verbose_logger.log(logginglevels.INFO_2,
_('--> Processing Dependency: %s for package: %s'), formatted_req,
name)
-
-
+
def unresolved(self, msg):
self.verbose_logger.log(logginglevels.INFO_2, _('--> Unresolved Dependency: %s'),
msg)
@@ -1202,7 +1204,8 @@ class DepSolveProgressCallBack:
def procConflict(self, name, confname):
self.verbose_logger.log(logginglevels.INFO_2,
- _('--> Processing Conflict: %s conflicts %s'), name, confname)
+ _('--> Processing Conflict: %s conflicts %s'),
+ name, confname)
def transactionPopulation(self):
self.verbose_logger.log(logginglevels.INFO_2, _('--> Populating transaction set '
@@ -1236,6 +1239,55 @@ class CacheProgressCallback:
def progressbar(self, current, total, name=None):
progressbar(current, total, name)
+def _pkgname_ui(ayum, pkgname, ts_states=None):
+ """ Get more information on a simple pkgname, if we can. We need to search
+ packages that we are dealing with atm. and installed packages (if the
+ transaction isn't complete). """
+ if ayum is None:
+ return pkgname
+
+ if ts_states is None:
+ # Note 'd' is a placeholder for downgrade, and
+ # 'r' is a placeholder for reinstall. Neither exist atm.
+ ts_states = ('d', 'e', 'i', 'r', 'u')
+
+ matches = []
+ def _cond_add(po):
+ if matches and matches[0].arch == po.arch and matches[0].verEQ(po):
+ return
+ matches.append(po)
+
+ for txmbr in ayum.tsInfo.matchNaevr(name=pkgname):
+ if txmbr.ts_state not in ts_states:
+ continue
+ _cond_add(txmbr.po)
+
+ if not matches:
+ return pkgname
+ fmatch = matches.pop(0)
+ if not matches:
+ return str(fmatch)
+
+ show_ver = True
+ show_arch = True
+ for match in matches:
+ if not fmatch.verEQ(match):
+ show_ver = False
+ if fmatch.arch != match.arch:
+ show_arch = False
+
+ if show_ver: # Multilib. *sigh*
+ if fmatch.epoch == '0':
+ return '%s-%s-%s' % (fmatch.name, fmatch.version, fmatch.release)
+ else:
+ return '%s:%s-%s-%s' % (fmatch.epoch, fmatch.name,
+ fmatch.version, fmatch.release)
+
+ if show_arch:
+ return '%s.%s' % (fmatch.name, fmatch.arch)
+
+ return pkgname
+
class YumCliRPMCallBack(RPMBaseCallback):
"""
@@ -1244,7 +1296,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
width = property(lambda x: _term_width())
- def __init__(self):
+ def __init__(self, ayum=None):
RPMBaseCallback.__init__(self)
self.lastmsg = to_unicode("")
self.lastpackage = None # name of last package we looked at
@@ -1253,15 +1305,22 @@ class YumCliRPMCallBack(RPMBaseCallback):
# for a progress bar
self.mark = "#"
self.marks = 22
-
+ self.ayum = ayum
+
+ # Installing things have pkg objects passed to the events, so only need to
+ # lookup for erased/obsoleted.
+ def pkgname_ui(self, pkgname, ts_states=('e' 'o')):
+ """ Get more information on a simple pkgname, if we can. """
+ return _pkgname_ui(self.ayum, pkgname, ts_states)
+
def event(self, package, action, te_current, te_total, ts_current, ts_total):
# this is where a progress bar would be called
process = self.action[action]
if type(package) not in types.StringTypes:
- pkgname = package.name
+ pkgname = str(package)
else:
- pkgname = package
+ pkgname = self.pkgname_ui(package)
self.lastpackage = package
if te_total == 0:
commit 2c234225360902378c94ddc05ecc4a2597a99057
Author: James Antill <james at and.org>
Date: Thu Apr 23 13:34:20 2009 -0400
Minor speedups to tsInfo.matchNaevr
diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index f17e331..ee390c9 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -127,21 +127,20 @@ class TransactionData:
else:
return states[0]
-
-
def matchNaevr(self, name=None, arch=None, epoch=None, ver=None, rel=None):
"""returns the list of packages matching the args above"""
if name is None:
txmbrs = self.getMembers()
else:
txmbrs = self._namedict.get(name, [])
+ if arch is None and epoch is None and ver is None and rel is None:
+ return txmbrs[:]
result = []
for txmbr in txmbrs:
(n, a, e, v, r) = txmbr.pkgtup
- if name is not None and name != n:
- continue
+ # Name is done above
if arch is not None and arch != a:
continue
if epoch is not None and epoch != e:
More information about the Yum-commits
mailing list