[yum-commits] Branch 'yum-3_2_X' - 5 commits - output.py rpmUtils/transaction.py yum/depsolve.py yum/packages.py yum/rpmsack.py
James Antill
james at osuosl.org
Thu Oct 29 17:19:05 UTC 2009
output.py | 59 ++++++++++++++++++++++++++++++++++++------------
rpmUtils/transaction.py | 4 +++
yum/depsolve.py | 33 ++++++++++++++++++--------
yum/packages.py | 14 ++++++-----
yum/rpmsack.py | 22 +++++++++++++++++
5 files changed, 102 insertions(+), 30 deletions(-)
New commits:
commit c7f70c88eaffb95c6a6f63b75fafb4a3efd90c00
Author: James Antill <james at and.org>
Date: Wed Oct 28 17:34:46 2009 -0400
Fix: Unicode unequal comparison failed to convert both arguments to Unicode
diff --git a/yum/packages.py b/yum/packages.py
index c1aa7cf..3c62f2a 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -410,7 +410,10 @@ class RpmBase(object):
# find the named entry in pkgobj, do the comparsion
result = []
for (n, f, (e, v, r)) in self.returnPrco(prcotype):
- if reqn != n:
+ if isinstance(reqn, unicode) == isinstance(n, unicode):
+ if reqn != n: # stupid python...
+ continue
+ elif misc.to_utf8(reqn) != misc.to_utf8(n):
continue
if f == '=':
commit 3fde1650bb3b86ed1856de55f78552bfdbac4414
Author: James Antill <james at and.org>
Date: Wed Oct 28 17:23:04 2009 -0400
A couple of minor opts for depsolving, in checkInstall and checkRemove
checkInstall: Don't filter out requires that we provide, as it's done
at createrepo time now.
checkRemove: If we have a req. we don't provide, check the things that
update/obsolete us for it first.
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 4d3d5ca..4c9ebd0 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -843,7 +843,6 @@ class Depsolve(object):
def _checkInstall(self, txmbr):
txmbr_reqs = txmbr.po.returnPrco('requires')
- txmbr_provs = set(txmbr.po.returnPrco('provides'))
# if this is an update, we should check what the old
# requires were to make things faster
@@ -856,8 +855,6 @@ class Depsolve(object):
for req in sorted(txmbr_reqs, key=self._sort_req_key):
if req[0].startswith('rpmlib('):
continue
- if req in txmbr_provs:
- continue
if req in oldreqs and self.rpmdb.getProvides(*req):
continue
@@ -884,7 +881,7 @@ class Depsolve(object):
# if this is an update, we should check what the new package
# provides to make things faster
newpoprovs = {}
- for newpo in txmbr.updated_by:
+ for newpo in txmbr.updated_by + txmbr.obsoleted_by:
for p in newpo.provides:
newpoprovs[p] = 1
ret = []
@@ -899,7 +896,22 @@ class Depsolve(object):
# FIXME: This is probably the best place to fix the postfix rename
# problem long term (post .21) ... see compare_providers.
for pkg, hits in self.tsInfo.getRequires(*prov).iteritems():
- for rn, rf, rv in hits:
+ for hit in hits:
+ # See if the update solves the problem...
+ found = False
+ for newpo in txmbr.updated_by:
+ if newpo.checkPrco('provides', hit):
+ found = True
+ break
+ if found: continue
+ for newpo in txmbr.obsoleted_by:
+ if newpo.checkPrco('provides', hit):
+ found = True
+ break
+ if found: continue
+
+ # It doesn't, so see what else might...
+ rn, rf, rv = hit
if not self.tsInfo.getProvides(rn, rf, rv):
ret.append( (pkg, self._prco_req_nfv2req(rn, rf, rv)) )
return ret
commit 8a25f351a4fc16ac6f16795981b2d04b7badf44f
Author: James Antill <james at and.org>
Date: Wed Oct 28 14:43:01 2009 -0400
Minor opt. for allowedMultipleInstalls() and pkg.*_names callers
diff --git a/yum/depsolve.py b/yum/depsolve.py
index e5b3a42..4d3d5ca 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -188,13 +188,14 @@ class Depsolve(object):
"""takes a packageObject, returns 1 or 0 depending on if the package
should/can be installed multiple times with different vers
like kernels and kernel modules, for example"""
-
- if po.name in self.conf.installonlypkgs:
+
+ iopkgs = set(self.conf.installonlypkgs)
+ if po.name in iopkgs:
return True
- provides = po.provides_names
- if filter (lambda prov: prov in self.conf.installonlypkgs, provides):
- return True
+ for prov in po.provides_names:
+ if prov in iopkgs:
+ return True
return False
diff --git a/yum/packages.py b/yum/packages.py
index c3a39c6..c1aa7cf 100644
--- a/yum/packages.py
+++ b/yum/packages.py
@@ -454,11 +454,10 @@ class RpmBase(object):
return self.files.keys()
def returnPrcoNames(self, prcotype):
- results = []
- lists = self.returnPrco(prcotype)
- for (name, flag, vertup) in lists:
- results.append(name)
- return results
+ if not hasattr(self, '_cache_prco_names_' + prcotype):
+ data = [n for (n, f, v) in self.returnPrco(prcotype)]
+ setattr(self, '_cache_prco_names_' + prcotype, data)
+ return getattr(self, '_cache_prco_names_' + prcotype)
def getProvidesNames(self):
warnings.warn('getProvidesNames() will go away in a future version of Yum.\n',
commit fe9b51182e6ebfa6ae5ff64d1a7290715ff5b134
Author: James Antill <james at and.org>
Date: Tue Oct 27 23:16:41 2009 -0400
Fix rpmdb.simpleVersion() to ignore gpg-pubkeys, dito. returnPackages()
Dito. searchPrco() etc.
Add a new rpmdb only method: rpmdb.returnGPGPubkeyPackages() ... so that
keys-remove can work.
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index 64a272f..df9bebb 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -122,6 +122,8 @@ class TransactionWrapper:
# prebuild the req dict
for h in mi:
+ if h['name'] == 'gpg-pubkey':
+ continue
if not h[rpm.RPMTAG_REQUIRENAME]:
continue
tup = miscutils.pkgTupleFromHeader(h)
@@ -144,6 +146,8 @@ class TransactionWrapper:
yield prov
for h in mi:
+ if h['name'] == 'gpg-pubkey':
+ continue
preq = 0
tup = miscutils.pkgTupleFromHeader(h)
for p in _return_all_provides(h):
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 743538d..9a542e5 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -106,6 +106,7 @@ class RPMDBPackageSack(PackageSackBase):
self._simple_pkgtup_list = []
self._get_pro_cache = {}
self._get_req_cache = {}
+ self._loaded_gpg_keys = False
self.ts = None
self.auto_close = False # this forces a self.ts.close() after
# most operations so it doesn't leave
@@ -180,6 +181,8 @@ class RPMDBPackageSack(PackageSackBase):
mi = ts.dbMatch()
mi.pattern(tag, rpm.RPMMIRE_GLOB, name)
for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey':
+ continue
pkg = self._makePackageObject(hdr, mi.instance())
if not result.has_key(pkg.pkgid):
result[pkg.pkgid] = pkg
@@ -203,6 +206,8 @@ class RPMDBPackageSack(PackageSackBase):
mi = ts.dbMatch('basenames', name)
for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey':
+ continue
pkg = self._makePackageObject(hdr, mi.instance())
if not result.has_key(pkg.pkgid):
result[pkg.pkgid] = pkg
@@ -226,6 +231,8 @@ class RPMDBPackageSack(PackageSackBase):
tag = self.DEP_TABLE[prcotype][0]
mi = ts.dbMatch(tag, misc.to_utf8(name))
for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey':
+ continue
po = self._makePackageObject(hdr, mi.instance())
result[po.pkgid] = po
del mi
@@ -334,11 +341,24 @@ class RPMDBPackageSack(PackageSackBase):
self._completely_loaded = patterns is None
pkgobjlist = self._idx2pkg.values()
+ # Remove gpg-pubkeys, as no sane callers expects/likes them...
+ if self._loaded_gpg_keys:
+ pkgobjlist = [pkg for pkg in pkgobjlist if pkg.name != 'gpg-pubkey']
if patterns:
pkgobjlist = parsePackages(pkgobjlist, patterns, not ignore_case)
pkgobjlist = pkgobjlist[0] + pkgobjlist[1]
return pkgobjlist
+ def returnGPGPubkeyPackages(self):
+ """ Return packages of the gpg-pubkeys ... hacky. """
+ ts = self.readOnlyTS()
+ mi = ts.dbMatch('name', 'gpg-pubkey')
+ ret = []
+ for hdr in mi:
+ self._loaded_gpg_keys = True
+ ret.append(self._makePackageObject(hdr, mi.instance()))
+ return ret
+
def simpleVersion(self, main_only=False, groups={}):
""" Return a simple version for all installed packages. """
def _up_revs(irepos, repoid, rev, pkg, csum):
@@ -492,6 +512,8 @@ class RPMDBPackageSack(PackageSackBase):
self._completely_loaded = True
for hdr in mi:
+ if hdr['name'] == 'gpg-pubkey':
+ continue
po = self._makePackageObject(hdr, mi.instance())
for tag in ('arch', 'rel', 'ver', 'epoch'):
if loc[tag] is not None and loc[tag] != getattr(po, tag):
commit 59d66777c378f4fd6b223636367b6d9c7593c3cb
Author: James Antill <james at and.org>
Date: Tue Oct 27 18:11:31 2009 -0400
Add utf8* calls for history, which is the minimum for real i18n there.
diff --git a/output.py b/output.py
index 9635473..46168aa 100755
--- a/output.py
+++ b/output.py
@@ -1195,7 +1195,14 @@ to exit.
count += 1
assert len(actions) <= 6
if len(actions) > 1:
- return count, ", ".join([x[0] for x in sorted(actions)])
+ large2small = {'Install' : _('I'),
+ 'Obsoleting' : _('O'),
+ 'Erase' : _('E'),
+ 'Reinstall' : _('R'),
+ 'Downgrade' : _('D'),
+ 'Update' : _('U'),
+ }
+ return count, ", ".join([large2small[x] for x in sorted(actions)])
# So empty transactions work, although that "shouldn't" really happen
return count, "".join(list(actions))
@@ -1251,10 +1258,14 @@ to exit.
if tids is None:
return 1, ['Failed history info']
- fmt = "%-6s | %-22s | %-16s | %-14s | %-7s"
- print fmt % ("ID", "Login user", "Date and time", "Action(s)","Altered")
+ fmt = "%s | %s | %s | %s | %s"
+ print fmt % (utf8_width_fill(_("ID"), 6, 6),
+ utf8_width_fill(_("Login user"), 22, 22),
+ utf8_width_fill(_("Date and time"), 16, 16),
+ utf8_width_fill(_("Action(s)"), 14, 14),
+ utf8_width_fill(_("Altered"), 7, 7))
print "-" * 79
- fmt = "%6u | %-22.22s | %-16s | %-14s | %4u"
+ fmt = "%6u | %s | %-16.16s | %s | %4u"
done = 0
limit = 20
if printall:
@@ -1268,6 +1279,8 @@ to exit.
tm = time.strftime("%Y-%m-%d %H:%M",
time.localtime(old.beg_timestamp))
num, uiacts = self._history_uiactions(old.trans_data)
+ name = utf8_width_fill(name, 22, 22)
+ uiacts = utf8_width_fill(uiacts, 14, 14)
if old.altered_lt_rpmdb and old.altered_gt_rpmdb:
print fmt % (old.tid, name, tm, uiacts, num), "><"
elif old.return_code is None:
@@ -1408,7 +1421,7 @@ to exit.
state = _('Downgraded')
else: # multiple versions installed, both older and newer
state = _('Weird')
- print "%s%-12s %s" % (prefix, state, hpkg)
+ print "%s%s %s" % (prefix, utf8_width_fill(state, 12), hpkg)
print _("Packages Altered:")
self.historyInfoCmdPkgsAltered(old, pats)
if old.output:
@@ -1445,29 +1458,44 @@ to exit.
cn = "%s-%s:%s-%s.%s" % (hpkg.name, hpkg.epoch,
hpkg.version, hpkg.release, hpkg.arch)
+ uistate = {'True-Install' : _('Install'),
+ 'Install' : _('Install'),
+ 'Dep-Install' : _('Dep-Install'),
+ 'Obsoleted' : _('Obsoleted'),
+ 'Obsoleting' : _('Obsoleting'),
+ 'Erase' : _('Erase'),
+ 'Reinstall' : _('Reinstall'),
+ 'Downgrade' : _('Downgrade'),
+ 'Downgraded' : _('Downgraded'),
+ 'Update' : _('Update'),
+ 'Updated' : _('Updated'),
+ }.get(hpkg.state, hpkg.state)
+ uistate = utf8_width_fill(uistate, 12, 12)
+ # Should probably use columns here...
if False: pass
elif hpkg.state == 'Update':
ln = len(hpkg.name) + 1
cn = (" " * ln) + cn[ln:]
- print "%s%s%-12s%s %s" % (prefix, hibeg, hpkg.state, hiend, cn)
+ print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
elif hpkg.state == 'Downgraded':
ln = len(hpkg.name) + 1
cn = (" " * ln) + cn[ln:]
- print "%s%s%-12s%s %s" % (prefix, hibeg, hpkg.state, hiend, cn)
- elif hpkg.state == 'True-Install':
- print "%s%s%-12s%s %s" % (prefix, hibeg, "Install", hiend, cn)
+ print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
else:
- print "%s%s%-12s%s %s" % (prefix, hibeg, hpkg.state, hiend, cn)
+ print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
def historySummaryCmd(self, extcmds):
tids, printall = self._history_list_transactions(extcmds)
if tids is None:
return 1, ['Failed history info']
- fmt = "%-26s | %-19s | %-16s | %-8s"
- print fmt % ("Login user", "Time", "Action(s)", "Altered")
+ fmt = "%s | %s | %s | %s"
+ print fmt % (utf8_width_fill(_("Login user"), 26, 26),
+ utf8_width_fill(_("Time"), 19, 19),
+ utf8_width_fill(_("Action(s)"), 16, 16),
+ utf8_width_fill(_("Altered"), 8, 8))
print "-" * 79
- fmt = "%-26.26s | %-19.19s | %-16s | %8u"
+ fmt = "%s | %s | %s | %8u"
data = {'day' : {}, 'week' : {},
'fortnight' : {}, 'quarter' : {}, 'half' : {},
'year' : {}, 'all' : {}}
@@ -1511,7 +1539,10 @@ to exit.
hpkgs.extend(old.trans_data)
count, uiacts = self._history_uiactions(hpkgs)
uperiod = _period2user[period]
- print fmt % (name, uperiod, uiacts, count)
+ # Should probably use columns here, esp. for uiacts?
+ print fmt % (utf8_width_fill(name, 22, 22),
+ utf8_width_fill(uperiod, 19, 19),
+ utf8_width_fill(uiacts, 16, 16), count)
class DepSolveProgressCallBack:
More information about the Yum-commits
mailing list