[Yum-devel] [PATCH 1/2] Test the first char of a pattern match, if we can

James Antill james at and.org
Tue Nov 3 17:02:42 UTC 2009


---
 yum/rpmsack.py |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 9a542e5..9647936 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -300,17 +300,27 @@ class RPMDBPackageSack(PackageSackBase):
             return None
         ret = []
         for pat in patterns:
+            qpat = pat[0]
+            if qpat in ('?', '*'):
+                qpat = None
             if ignore_case:
-                ret.append(re.compile(fnmatch.translate(pat), re.I))
+                ret.append((qpat, re.compile(fnmatch.translate(pat), re.I)))
             else:
-                ret.append(re.compile(fnmatch.translate(pat)))
+                ret.append((qpat, re.compile(fnmatch.translate(pat))))
         return ret
     @staticmethod
     def _match_repattern(repatterns, hdr):
         if repatterns is None:
             return True
 
-        for repat in repatterns:
+        for qpat, repat in repatterns:
+            epoch = hdr['epoch']
+            if epoch is None:
+                epoch = '0'
+            else:
+                epoch = str(epoch)
+            if qpat is not None and qpat != hdr['name'][0] and qpat != epoch[0]:
+                continue
             if repat.match(hdr['name']):
                 return True
             if repat.match("%(name)s-%(version)s-%(release)s.%(arch)s" % hdr):
-- 
1.6.2.5



More information about the Yum-devel mailing list