[yum-cvs] yum/yum sqlitesack.py,1.29,1.29.2.1

Seth Vidal skvidal at linux.duke.edu
Wed Apr 19 22:15:40 UTC 2006


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv7556/yum

Modified Files:
      Tag: yum-2_6_X
	sqlitesack.py 
Log Message:

hopeful fix for partial provide bug


Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.29
retrieving revision 1.29.2.1
diff -u -r1.29 -r1.29.2.1
--- sqlitesack.py	28 Feb 2006 06:53:03 -0000	1.29
+++ sqlitesack.py	19 Apr 2006 22:15:38 -0000	1.29.2.1
@@ -185,12 +185,15 @@
             
     # Search packages that either provide something containing name
     # or provide a file containing name 
-    def searchAll(self,name, query_type='like'):
-    
+    def searchAll(self, name, query_type='like'):
+        
         # This should never be called with a name containing a %
         assert(name.find('%') == -1)
         result = []
         quotename = name.replace("'","''")
+        (dirname,filename) = os.path.split(name)
+        
+        # check provides
         for (rep,cache) in self.primarydb.items():
             cur = cache.cursor()
             cur.execute("select DISTINCT packages.pkgId as pkgId from provides,packages where provides.name LIKE '%%%s%%' AND provides.pkgKey = packages.pkgKey" % quotename)
@@ -199,39 +202,65 @@
                     continue
                 pkg = self.getPackageDetails(ob['pkgId'])
                 result.append((self.pc(pkg,rep)))
-
+        
+        # check filelists/dirlists
         for (rep,cache) in self.filelistsdb.items():
-            cur = cache.cursor()
-            (dir,filename) = os.path.split(quotename)
-            # This query means:
-            # Either name is a substring of dirname or the directory part
-            # in name is a substring of dirname and the file part is part
-            # of filelist
-            cur.execute("select packages.pkgId as pkgId,\
+            querystrings = []
+            # dirnames
+            # just the dirname
+            if dirname != '':
+                tmp = "select packages.pkgId as pkgId,\
                 filelist.dirname as dirname,\
                 filelist.filetypes as filetypes,\
                 filelist.filenames as filenames \
                 from packages,filelist where \
-                (filelist.dirname LIKE '%%%s%%' \
-                OR (filelist.dirname LIKE '%%%s%%' AND\
-                filelist.filenames LIKE '%%%s%%'))\
-                AND (filelist.pkgKey = packages.pkgKey)" % (quotename,dir,filename))
-                    
-        # cull the results for false positives
-        for ob in cur.fetchall():
-            # Check if it is an actual match
-            # The query above can give false positives, when
-            # a package provides /foo/aaabar it will also match /foo/bar
-            if (self.excludes[rep].has_key(ob['pkgId'])):
-                continue
-            real = False
-            for filename in decodefilenamelist(ob['filenames']):
-                if (ob['dirname']+'/'+filename).find(name) != -1:
-                    real = True
-            if (not real):
-                continue
-            pkg = self.getPackageDetails(ob['pkgId'])
-            result.append((self.pc(pkg,rep)))
+                filelist.dirname LIKE '%%%s%%' \
+                AND (filelist.pkgKey = packages.pkgKey)" % (dirname)
+                querystrings.append(tmp)
+                
+            # look at full quotename
+            tmp = "select packages.pkgId as pkgId,\
+                filelist.dirname as dirname,\
+                filelist.filetypes as filetypes,\
+                filelist.filenames as filenames \
+                from packages,filelist where \
+                filelist.dirname LIKE '%%%s%%' \
+                AND (filelist.pkgKey = packages.pkgKey)" % (quotename)
+            querystrings.append(tmp)
+
+            # filenames
+            tmp = "select packages.pkgId as pkgId,\
+                filelist.dirname as dirname,\
+                filelist.filetypes as filetypes,\
+                filelist.filenames as filenames \
+                from packages,filelist where \
+                filelist.filenames LIKE '%%%s%%'\
+                AND (filelist.pkgKey = packages.pkgKey)" % (filename)
+            
+            querystrings.append(tmp)
+        
+            for querystring in querystrings:
+                cur = cache.cursor()
+                cur.execute("%s" % querystring)
+
+                # cull the results for false positives
+                for ob in cur.fetchall():
+                    # Check if it is an actual match
+                    # The query above can give false positives, when
+                    # a package provides /foo/aaabar it will also match /foo/bar
+                    if (self.excludes[rep].has_key(ob['pkgId'])):
+                        continue
+                    real = False
+        
+                    for filename in decodefilenamelist(ob['filenames']):
+                        if (ob['dirname'] + '/' + filename).find(name) != -1:
+                            real = True
+                    if (not real):
+                        continue
+
+                    pkg = self.getPackageDetails(ob['pkgId'])
+                    result.append((self.pc(pkg,rep)))
+
         return result     
     
     def returnObsoletes(self):




More information about the Yum-cvs-commits mailing list