[Blends-commit] [SCM] blends-gsoc branch, master, updated. daefa77d9ade83e0bbe95bed5c778571a1ac64c1

Emmanouil Kiagias e.kiagias at gmail.com
Fri Jul 12 16:04:16 UTC 2013


The following commit has been merged in the master branch:
commit 90f1505f9ffc9ce3e4c5c5a0b75df8af7100d1e5
Author: Emmanouil Kiagias <e.kiagias at gmail.com>
Date:   Fri Jul 12 17:59:08 2013 +0200

    Both {sec-}blend-gen-control handle virtual packages using the new '{contains-}provides' column of blends_dependencies{_alternatives}. We still have issue with some packages(in debian-edu) which do not appear in any of the tables: packages, new_packages, ubuntu_packages, blends_prospectivepackages where blends_metadata_gathener.py checks. Also note that sec-blend-gen-control handles differently packages which appear in both package and provides columns of packages UDD table(take the example of nfs-server,nfs-kernel-server of debian-edu for kfreebsd-amd64,testing release)

diff --git a/blend-gen-control b/blend-gen-control
index 9e7b401..3039be5 100755
--- a/blend-gen-control
+++ b/blend-gen-control
@@ -266,12 +266,14 @@ class UDD_connector:
 
         #initialize the tasks' info before getting the dependencies for the tasks
         blend_dependencies = self.__get_tasks_info(blend = blend, release = release, tasksprefix = kwargs["tasksprefix"])
+        virtual_packages = {}
+        single_virtual_packages = []
         available = []
         missing = []
         excluded = []
 
         query = """
-            SELECT b.task, b.package, b.dependency, b.distribution, b.component, pkg.architecture
+            SELECT b.task, b.package, b.dependency, b.distribution, b.component, pkg.architecture, b.provides
               FROM blends_dependencies b LEFT OUTER JOIN ( 
                  SELECT p.package, p.architecture 
                    FROM packages p JOIN releases r ON p.release = r.release 
@@ -282,14 +284,34 @@ class UDD_connector:
 
         self.__execute_query(query)
         
-        #indexes of row: task(0), package(1), dependency(2), distribution(3), component(4), architecture(5)
+        #indexes of row: task(0), package(1), dependency(2), distribution(3), component(4), architecture(5), provides(6)
         row = self.cursor.fetchone()
 
         while not row is None:
             increase_packages = True
-            #task, package, dependency, distribution, component, arch = (row[0], row[1], row[2], row[3], row[4], row[5])
-            task, package, dependency, distribution, component, arch = row
+            #task, package, dependency, distribution, component, arch, provides = (row[0], row[1], row[2], row[3], row[4], row[5], row[6])
+            task, package, dependency, distribution, component, arch, provides = row
             
+            if provides:
+                wanted_dependencies = []
+                if nodepends or taskdescription:
+                    #in this case we need both depends and recommends
+                    wanted_dependencies += ['d', 'r']
+                        
+                else:
+                    #in this case we only need depends
+                    wanted_dependencies.append('d')
+
+                if dependency in wanted_dependencies:
+                    if not task in virtual_packages:
+                            virtual_packages[task] = []
+
+                    virtual_packages[task].append(package)
+                    single_virtual_packages.append(package)
+
+                    row = self.cursor.fetchone()
+                    continue
+
             #TODO check again if: if else is with proper syntax
             if nodepends or taskdescription:
                 #in this case all the Depends go to Recommends and the recommend packages
@@ -331,6 +353,40 @@ class UDD_connector:
 
             row = self.cursor.fetchone()
 
+        #now we should handle the virtual packages if any:
+        if single_virtual_packages:
+            
+            available_virtual = []
+
+            query = """
+                SELECT distinct p.provides FROM packages p JOIN releases r ON p.release = r.release
+                WHERE r.role='{0}' AND p.distribution='debian' AND component='main' AND p.architecture='{1}'
+                  AND provides ~ ('((\s|,)'||'({2})'||'(\s+|,|$)|^'||'({2})'||'$)')
+                """.format(release, architecture, '|'.join(single_virtual_packages))
+
+            self.__execute_query(query)
+            row = self.cursor.fetchone()
+            while not row is None:
+                #row[0] : p.provides column
+                myprovides = row[0]
+                if ',' in myprovides:
+                    available_virtual += [ v.strip() for v in myprovides.split(',') ]
+                else:
+                    available_virtual.append(row[0])
+                row = self.cursor.fetchone()
+
+            for task in virtual_packages:
+                exist = []
+                miss = []
+                for pkg in virtual_packages[task]:
+                    if pkg in available_virtual:
+                        if nodepends or taskdescription:
+                            blend_dependencies[task]["Recommends"].append(pkg)
+                        else:
+                            blend_dependencies[task]["Depends"].append(pkg)
+                    else:
+                        blend_dependencies[task]["Suggests"].append(pkg)
+
         #once we have all the dependencies we will get the alternatives
         blend_alternatives = self.__get_blend_alternatives(blend = blend)
 
diff --git a/sec-blend-gen-control b/sec-blend-gen-control
index eafa783..5e5c8ce 100755
--- a/sec-blend-gen-control
+++ b/sec-blend-gen-control
@@ -187,6 +187,7 @@ class UDD_connector:
         architecture = kwargs["architecture"]
         nodepends = kwargs["nodepends"]
         taskdescription = kwargs['taskdescription']
+        virtual_packages = []
 
         #initialize the tasks' info before getting the dependencies for the tasks
         blend_dependencies = self.__get_tasks_info(blend = blend, release = release, tasksprefix = kwargs["tasksprefix"])
@@ -197,7 +198,7 @@ class UDD_connector:
         excluded = []
 
         query = """
-            SELECT b.task, b.alternatives, b.dependency, b.distribution, b.component, pkg.architecture
+            SELECT b.task, b.alternatives, b.dependency, b.distribution, b.component, pkg.architecture, b.contains_provides
               FROM blends_dependencies_alternatives b LEFT OUTER JOIN ( 
                  SELECT p.package, p.architecture 
                    FROM packages p JOIN releases r ON p.release = r.release 
@@ -208,27 +209,36 @@ class UDD_connector:
 
         self.__execute_query(query)
         
-        #indexes of row: task(0), package(1), dependency(2), distribution(3), component(4), architecture(5)
+        #indexes of row: task(0), package(1), dependency(2), distribution(3), component(4), architecture(5), p.contains_provides(6)
         row = self.cursor.fetchone()
 
         while not row is None:
             increase_packages = True
-            #task, package, dependency, distribution, component, arch = (row[0], row[1], row[2], row[3], row[4], row[5])
-            task, package, dependency, distribution, component, arch = row
-            
-            if '|' in package:
-                if not task in blend_alternatives:
-                    blend_alternatives[task] = []
-                    
-                alter_dict = { "alternatives" : package, "dependency" : dependency, 
-                                "distribution" : distribution, "component" : component }
-                blend_alternatives[task].append(alter_dict)
-                single_alternatives_list += [ myalt.strip() for myalt in package.split("|")]
+            #task, package, dependency, distribution, component, arch, provides = (row[0], row[1], row[2], row[3], row[4], row[5], row[6])
+            task, package, dependency, distribution, component, arch, contains_provides = row
 
-                row = self.cursor.fetchone()
-                continue
+            if '|' in package or contains_provides:
+                wanted_dependencies = []
+                if nodepends or taskdescription:
+                    wanted_dependencies += ['d', 'r']
+                else:
+                    wanted_dependencies.append('d')
+
+                if dependency in wanted_dependencies:
+                    if contains_provides:
+                        if '|' in package:
+                            virtual_packages += [ myalt.strip() for myalt in package.split("|") ]
+                        else:
+                            virtual_packages.append(package)
 
+                    if not task in blend_alternatives:
+                        blend_alternatives[task] = []
+                    
+                    blend_alternatives[task].append(package)
+                    single_alternatives_list += [ myalt.strip() for myalt in package.split("|")]
 
+                    row = self.cursor.fetchone()
+                    continue
 
             #TODO check again if: if else is with proper syntax
             if nodepends or taskdescription:
@@ -278,10 +288,19 @@ class UDD_connector:
             formatted_list = [  "'{0}'".format(mypkg) for mypkg in set(single_alternatives_list) ]
 
             query = """
-                SELECT p.package FROM packages p JOIN releases r ON p.release = r.release
+                SELECT distinct p.package FROM packages p JOIN releases r ON p.release = r.release
                 WHERE p.package in ( {0} ) AND p.architecture in ('{1}', 'all' ) AND p.distribution='debian' 
                  AND p.component='main' AND r.role='{2}'
                 """.format(','.join(formatted_list), architecture, release)
+
+            if virtual_packages:
+                query += """
+                    UNION
+                      SELECT distinct p.provides FROM packages p JOIN releases r ON p.release = r.release
+                      WHERE r.role='{0}' AND p.distribution='debian' AND component='main' AND p.architecture='{1}'
+                        AND provides ~ ('((\s|,)'||'({2})'||'(\s+|,|$)|^'||'({2})'||'$)')
+                    """.format(release, architecture, '|'.join(virtual_packages))
+
             self.__execute_query(query)
 
             available_packages = []
@@ -289,7 +308,11 @@ class UDD_connector:
             #row contain only package value in index 0
             row = self.cursor.fetchone()
             while not row is None:
-                available_packages.append(row[0])
+                if ',' in row[0]:
+                    available_packages += [ v.strip() for v in row[0].split(',') ]
+                else:
+                    available_packages.append(row[0])
+                
                 row = self.cursor.fetchone()
 
             for task in blend_alternatives:
@@ -297,12 +320,8 @@ class UDD_connector:
                 for alternative in alternatives_list:
                     single_alt_exist = []
                     single_alt_missing = []
-                    
-                    distribution = alternative["distribution"]
-                    component = alternative["component"]
-                    dependency = alternative["dependency"]
 
-                    alt_list = [ alt.strip() for alt in alternative["alternatives"].split('|') ]
+                    alt_list = [ alt.strip() for alt in alternative.split('|') ]
                     for single_alt in alt_list:
                         if single_alt in available_packages:
                             single_alt_exist.append(single_alt)
@@ -310,36 +329,17 @@ class UDD_connector:
                             single_alt_missing.append(single_alt)
 
                     if nodepends or taskdescription:
-                        #in this case all the Depends go to Recommends and the recommend packages
-                        #follow the same rules as the depends packages
-                        #dependency 'd'== depends and 'r' == recommends
-                        if dependency == 'd' or dependency == 'r':
-                            if single_alt_exist:
-                                blend_dependencies[task]["Recommends"].append(' | '.join(single_alt_exist))
-                            if single_alt_missing:
-                                blend_dependencies[task]["Suggests"].append(' | '.join(single_alt_missing))
+                        if single_alt_exist:
+                            blend_dependencies[task]["Recommends"].append(' | '.join(single_alt_exist))
+                        if single_alt_missing:
+                            blend_dependencies[task]["Suggests"].append(' | '.join(single_alt_missing))
                     else:
-                        if dependency == 'd':
-                            if single_alt_exist:
-                                blend_dependencies[task]["Depends"].append(' | '.join(single_alt_exist))
-                            if single_alt_missing:
-                                blend_dependencies[task]["Suggests"].append(' | '.join(single_alt_missing))
-                        elif dependency == 'r':
-                            blend_dependencies[task]["Recommends"].append(alternative["alternatives"])
-
-                    if dependency == 's':
-                        blend_dependencies[task]["Suggests"].append(alternative["alternatives"])
-                    if dependency == 'i':
-                        blend_dependencies[task]["Ignores"].append(alternative["alternatives"])
-                        missing += alt_list
-                        increase_packages = False
-                    if dependency == 'a':
-                        blend_dependencies[task]["Avoid"].append(alternative["alternatives"])
-                        excluded += alt_list
-                        increase_packages = False
-
-
-                    #not sure if i should add these packages into the missing
+                        if single_alt_exist:
+                            blend_dependencies[task]["Depends"].append(' | '.join(single_alt_exist))
+                        if single_alt_missing:
+                            blend_dependencies[task]["Suggests"].append(' | '.join(single_alt_missing))
+
+                    #TODO not sure if i should add these packages into the missing
                     if single_alt_missing:
                         missing+= single_alt_missing
                     if single_alt_exist:
diff --git a/tester b/tester
index 22eb0cf..fee6e31 100755
--- a/tester
+++ b/tester
@@ -13,7 +13,7 @@ dodiff() {
         if [ $filename != "readme" ]
         then
             if [ $DEBUG != 0 ] ; then
-                echo "Comparing $1/$filename with $1-sec/$filename"
+                echo "diff $1/$filename $1-sec/$filename"
             fi
             diff $1/$filename $1-sec/$filename
         fi
@@ -35,4 +35,8 @@ do
     dodiff "taskdesc"
     
     echo ""
+
+    #remove them so in next taskdesc/taskdesc-sec loop it won't diff them over again
+    rm taskdesc/*
+    rm taskdesc-sec/*
 done

-- 
Git repository for blends-gsoc code



More information about the Blends-commit mailing list