[yum-git] Branch 'yum-3_2_X' - 2 commits - yum/update_md.py
James Antill
james at linux.duke.edu
Fri Aug 1 21:19:14 UTC 2008
yum/update_md.py | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
New commits:
commit f8244e1c3b169d08cf982c575465eb019fac3e3e
Author: James Antill <james at and.org>
Date: Fri Aug 1 17:19:07 2008 -0400
Fix bad format string in UpdateNotice.__str__
diff --git a/yum/update_md.py b/yum/update_md.py
index 0df2de1..06c8c96 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -85,7 +85,7 @@ class UpdateNotice(object):
""" % self._md
if self._md['updated'] and self._md['updated'] != self._md['issued']:
- head += " Updated : %(updated)s" % self._md['updated']
+ head += " Updated : %s" % self._md['updated']
# Add our bugzilla references
bzs = filter(lambda r: r['type'] == 'bugzilla', self._md['references'])
commit 953228dcd3152afd711a347b96ac96dfdc5e28b6
Author: James Antill <james at and.org>
Date: Fri Aug 1 17:18:35 2008 -0400
Add get_applicable_notices() call to UpdateMetadata class
diff --git a/yum/update_md.py b/yum/update_md.py
index 98fe01a..0df2de1 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -27,6 +27,8 @@ import gzip
from textwrap import wrap
from yum.yumRepo import YumRepository
+import rpmUtils.miscutils
+
try:
from xml.etree import cElementTree
except ImportError:
@@ -227,6 +229,11 @@ class UpdateNotice(object):
return package
+def _rpm_tup_vercmp(tup1, tup2):
+ """ Compare two "std." tuples, (n, a, e, v, r). """
+ return rpmUtils.miscutils.compareEVR((tup1[2], tup1[3], tup1[4]),
+ (tup2[2], tup2[3], tup2[4]))
+
class UpdateMetadata(object):
"""
@@ -256,6 +263,36 @@ class UpdateMetadata(object):
nvr = '-'.join(nvr)
return self._cache.has_key(nvr) and self._cache[nvr] or None
+ # The problem with the above "get_notice" is that not everyone updates
+ # daily. So if you are at pkg-1, pkg-2 has a security notice, and pkg-3
+ # has a BZ fix notice. All you can see is the BZ notice for the new "pkg-3"
+ # with the above.
+ # So now instead you lookup based on the _installed_ pkg.pkgtup, and get
+ # two notices, in order: [(pkg-3, notice), (pkg-2, notice)]
+ # the reason for the sorting order is that the first match will give you
+ # the minimum pkg you need to move to.
+ def get_applicable_notices(self, pkgtup):
+ """
+ Retrieve any update notices which are newer than a
+ given std. pkgtup (name, arch, epoch, version, release) tuple.
+ """
+ oldpkgtup = pkgtup
+ name = oldpkgtup[0]
+ arch = oldpkgtup[1]
+ ret = []
+ for notice in self.get_notices(name):
+ for upkg in notice['pkglist']:
+ for pkg in upkg['packages']:
+ if pkg['name'] != name or pkg['arch'] != arch:
+ continue
+ pkgtup = (pkg['name'], pkg['arch'], pkg['epoch'] or '0',
+ pkg['version'], pkg['release'])
+ if _rpm_tup_vercmp(pkgtup, oldpkgtup) <= 0:
+ continue
+ ret.append((pkgtup, notice))
+ ret.sort(cmp=_rpm_tup_vercmp, key=lambda x: x[0])
+ return ret
+
def add(self, obj, mdtype='updateinfo'):
""" Parse a metadata from a given YumRepository, file, or filename. """
if not obj:
More information about the Yum-cvs-commits
mailing list