[yum-cvs] yum/yum packageSack.py, 1.18.2.9, 1.18.2.10 sqlitesack.py, 1.47.2.2, 1.47.2.3
James Bowes
jbowes at linux.duke.edu
Sat Feb 3 21:33:42 UTC 2007
- Previous message: [yum-cvs] yum/yum Errors.py, 1.14, 1.15 __init__.py, 1.272, 1.273 config.py, 1.111, 1.112 yumRepo.py, 1.29, 1.30
- Next message: [yum-cvs] yum cli.py,1.241.2.12,1.241.2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv21632/yum
Modified Files:
Tag: yum-3_0_X
packageSack.py sqlitesack.py
Log Message:
Apply patch from David Lutterkort for speedup of yum install
Index: packageSack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/packageSack.py,v
retrieving revision 1.18.2.9
retrieving revision 1.18.2.10
diff -u -r1.18.2.9 -r1.18.2.10
--- packageSack.py 4 Jan 2007 22:24:30 -0000 1.18.2.9
+++ packageSack.py 3 Feb 2007 21:33:40 -0000 1.18.2.10
@@ -18,6 +18,7 @@
import warnings
import re
import fnmatch
+import misc
class PackageSackBase(object):
"""Base class that provides the interface for PackageSacks."""
@@ -335,6 +336,30 @@
def searchAll(self, arg, query_type):
return self._computeAggregateListResult("searchAll", arg, query_type)
+ def matchPackageNames(self, pkgspecs):
+ matched = []
+ exactmatch = []
+ unmatched = None
+ for sack in self.sacks.values():
+ if hasattr(sack, "matchPackageNames"):
+ e, m, u = [], [], []
+ try:
+ e, m, u = sack.matchPackageNames(pkgspecs)
+ except PackageSackError:
+ continue
+
+ exactmatch.extend(e)
+ matched.extend(m)
+ if unmatched is None:
+ unmatched = set(u)
+ else:
+ unmatched = unmatched.intersection(set(u))
+
+ matched = misc.unique(matched)
+ exactmatch = misc.unique(exactmatch)
+ unmatched = list(unmatched)
+ return exactmatch, matched, unmatched
+
def _computeAggregateListResult(self, methodName, *args):
result = []
for sack in self.sacks.values():
Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.47.2.2
retrieving revision 1.47.2.3
diff -u -r1.47.2.2 -r1.47.2.3
--- sqlitesack.py 14 Nov 2006 21:14:09 -0000 1.47.2.2
+++ sqlitesack.py 3 Feb 2007 21:33:40 -0000 1.47.2.3
@@ -309,7 +309,7 @@
prcos = cur.fetchall()
for res in prcos:
cur.execute("select * from packages where pkgKey = %s" , (res['pkgKey']))
- for x in cur.fetchall():
+ for x in cur:
pkg = self.db2class(x)
if (self.excludes[rep].has_key(pkg.pkgId)):
continue
@@ -500,6 +500,33 @@
raise Errors.PackageSackError, 'No Package Matching %s' % name
return misc.newestInList(allpkg)
+ # Do what packages.matchPackageNames does, but query the DB directly
+ def matchPackageNames(self, pkgspecs):
+ matched = []
+ exactmatch = []
+ unmatched = list(pkgspecs)
+ for p in pkgspecs:
+ if re.match('[\*\?\[\]]', p):
+ query = PARSE_QUERY % ({ "op": "glob", "q": p })
+ matchres = matched
+ else:
+ query = PARSE_QUERY % ({ "op": "=", "q": p })
+ matchres = exactmatch
+
+ for (rep, db) in self.primarydb.items():
+ cur = db.cursor()
+ cur.execute(query)
+ res = cur.fetchall()
+ if len(res) > 0:
+ unmatched.remove(p)
+ pos = map(lambda x: self.pc(rep,self.db2class(x,True)), res)
+ matchres.extend(pos)
+
+ exactmatch = misc.unique(exactmatch)
+ matched = misc.unique(matched)
+ unmatched = misc.unique(unmatched)
+ return exactmatch, matched, unmatched
+
def returnPackages(self, repoid=None):
"""Returns a list of packages, only containing nevra information """
returnList = []
@@ -586,3 +613,18 @@
string2ft = {'f':'file','d': 'dir','g': 'ghost'}
return [string2ft[x] for x in filetypestring]
+
+# Query used by matchPackageNames
+# op is either '=' or 'like', q is the search term
+# Check against name, nameArch, nameVerRelArch, nameVer, nameVerRel,
+# envra, nevra
+PARSE_QUERY = """
+select pkgId, name, arch, epoch, version, release from packages
+where name %(op)s '%(q)s'
+ or name || '.' || arch %(op)s '%(q)s'
+ or name || '-' || version %(op)s '%(q)s'
+ or name || '-' || version || '-' || release %(op)s '%(q)s'
+ or name || '-' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+ or epoch || ':' || name || '-' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+ or name || '-' || epoch || ':' || version || '-' || release || '.' || arch %(op)s '%(q)s'
+"""
- Previous message: [yum-cvs] yum/yum Errors.py, 1.14, 1.15 __init__.py, 1.272, 1.273 config.py, 1.111, 1.112 yumRepo.py, 1.29, 1.30
- Next message: [yum-cvs] yum cli.py,1.241.2.12,1.241.2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Yum-cvs-commits
mailing list