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

Emmanouil Kiagias e.kiagias at gmail.com
Fri Jul 26 13:50:33 UTC 2013


The following commit has been merged in the master branch:
commit 017c653f3b15236a2623ba42b887603f7b1bd925
Author: Emmanouil Kiagias <e.kiagias at gmail.com>
Date:   Fri Jul 26 15:39:45 2013 +0200

    now single/{sec-}blend-gen-control generated a task-description template, also added a test_taskdesc script which compares the (single)taskdesc.template for each taskdesc.<arch> files. There is a small bug in taskdesc.template regarding the alternatives packages, I will find another way to *convert* the template to a single-arch file

diff --git a/blend-gen-control b/blend-gen-control
index 2b45a24..c0f0e89 100755
--- a/blend-gen-control
+++ b/blend-gen-control
@@ -576,7 +576,7 @@ def gen_task_desc(**kwargs):
             fout.write("Packages: list\n ")
             for header in ["Depends", "Recommends"]:
                 if not blend_dependencies[task][header]:
-                    continue
+                    continue            
                 #Tasksel doesn't allow boolean(eg OR : |) comparisons in dependencies such as package1 | package2.
                 #so we include in the list the first of the alternative packages
                 alternatives_resolved = []
@@ -585,10 +585,11 @@ def gen_task_desc(**kwargs):
                         alternatives_resolved.append(pkg.split('|')[0])
                     else:
                         alternatives_resolved.append(pkg)
-
+                
                 fout.write("{0}".format("\n ".join(sorted(alternatives_resolved))))
-
-            fout.write("\n\n")
+                fout.write("\n")
+                
+            fout.write("\n")
 
 def main():
     default_release = "testing"
diff --git a/sec-blend-gen-control b/sec-blend-gen-control
index 15d72b2..aa823e8 100755
--- a/sec-blend-gen-control
+++ b/sec-blend-gen-control
@@ -526,8 +526,9 @@ def gen_task_desc(**kwargs):
                         alternatives_resolved.append(pkg)
 
                 fout.write("{0}".format("\n ".join(sorted(alternatives_resolved))))
+                fout.write("\n")
 
-            fout.write("\n\n")
+            fout.write("\n")
 
 def main():
     default_release = "testing"
diff --git a/single/blend-gen-control b/single/blend-gen-control
index d2796ee..da2439d 100755
--- a/single/blend-gen-control
+++ b/single/blend-gen-control
@@ -608,6 +608,69 @@ def gen_control(**kwargs):
 
             fout.write("\n")
 
+def gen_task_desc(**kwargs):
+    """
+    This method generates the task description file for tasksel
+    """
+    logger = logging.getLogger(__name__)
+
+    suppressempty = kwargs["suppressempty"]
+    blend = kwargs["blend_info"]["blend"]
+    tasksprefix = kwargs["blend_info"]["tasksprefix"]
+    blend_dependencies = kwargs["blend_dependencies"]
+
+
+    #TODO this is used for testing for the moment, will be changed
+    task_desc_path = "taskdesc.template"
+    logger.debug("Opening file {0} to write".format(task_desc_path))
+    with open(task_desc_path,'w') as fout:
+
+        for task in sorted(blend_dependencies.keys()):    
+
+            if blend_dependencies[task]['Leaf'] == 'false':
+                continue
+
+            if suppressempty and blend_dependencies[task]["haspackages"] == 0:
+                if blend_dependencies[task]['test_always_lang']:
+                    logger.debug("Print empty task {0} because Test-always-lang is set\n".format(task))
+                else:
+                    logger.debug("The metapackage {2} will not be created because {0} dependant are in the pool and suppressempty was set {1}\n".format(blend_dependencies[task]["haspackages"], suppressempty, task))
+                    continue
+
+            fout.write("Task: {0}-{1}\n".format(tasksprefix, task))
+            fout.write("Section: {0}\n".format(blend));
+            fout.write("Description: {0}\n".format(blend_dependencies[task]["description"]))
+            fout.write("{0}".format(blend_dependencies[task]["long_description"])) #Already contains a newline
+            fout.write("Relevance: 10\n")
+
+            if blend_dependencies[task]["Enhances"]:
+                fout.write("Enhances: {0}\n".format(blend_dependencies[task]["Enhances"]))
+
+            if blend_dependencies[task]["metapackage"]:
+                #No use listing a metapackage as a key package, if no metapackage exist.
+                fout.write("Key: \n");
+                fout.write(" {0}-{1}\n".format(tasksprefix, task))
+
+            fout.write("Packages: list\n ")
+            for header in ["Depends", "Recommends"]:
+                if not blend_dependencies[task][header]:
+                    continue 
+                #Tasksel doesn't allow boolean(eg OR : |) comparisons in dependencies such as package1 | package2.
+                #so we include in the list the first of the alternative packages
+                alternatives_resolved = []
+                for pkg in blend_dependencies[task][header]:
+                    if '|' in pkg:
+                        alternatives_resolved.append(pkg.split('|')[0])
+                    else:
+                        alternatives_resolved.append(pkg)
+
+                fout.write("{0}".format("\n ".join(sorted(alternatives_resolved))))
+                fout.write("\n")
+                #fout.write("{0}".format("\n ".join(sorted(blend_dependencies[task][header]))))
+
+            fout.write("\n")
+
+
 def main():
     default_release = "testing"
 
@@ -623,6 +686,8 @@ def main():
                         help="suppress tasks without any recommended package")
     parser.add_argument("-c", dest="gencontrol", action="store_true", default=False,
                         help="Create new debian/control file.")
+    parser.add_argument("-t", dest="taskdesc", action="store_true", default=False,
+                        help="Print task descriptions and package list for task")
 
     parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False,
                         help="Print debug information")
@@ -637,8 +702,8 @@ def main():
     #----------------------------end of argparse and setup logging--------------------------------------#
 
     #at least a -c or -t argument must be provided
-    if not args.gencontrol:
-        logger.error("Argument -c(generate control file) is required.")
+    if not args.gencontrol and not args.taskdesc:
+        logger.error("Argument -c(generate control file) or -t(generate taskdescription file) is required.")
         sys.exit(-1)
 
     hasconfig = False
@@ -676,6 +741,15 @@ def main():
         gen_control(blend_info = blend_info, blend_dependencies = blend_dependencies,
             suppressempty = suppressempty, nodepends = nodepends, hasconfig = hasconfig)
 
+    elif args.taskdesc:
+        #we reuse the same code as above here BUT we need the blend_dependencies here without nodepends so we make sure we call it
+        #with nodepends = False no matter the command line argument, no need to descrease depends to recommends in any way for task description
+        blend_dependencies, available, missing, excluded = myudd.get_blend_dependecies(blend = blend_info["blend"], release = release, 
+            tasksprefix = blend_info["tasksprefix"], nodepends = False, taskdescription = True)
+        
+        gen_task_desc(blend_info = blend_info, blend_dependencies = blend_dependencies,
+            suppressempty = suppressempty)
+
     return 0
 
 if __name__ == '__main__':
diff --git a/single/sec-blend-gen-control b/single/sec-blend-gen-control
index 5d323a8..331619c 100755
--- a/single/sec-blend-gen-control
+++ b/single/sec-blend-gen-control
@@ -586,6 +586,68 @@ def gen_control(**kwargs):
 
             fout.write("\n")
 
+def gen_task_desc(**kwargs):
+    """
+    This method generates the task description file for tasksel
+    """
+    logger = logging.getLogger(__name__)
+
+    suppressempty = kwargs["suppressempty"]
+    blend = kwargs["blend_info"]["blend"]
+    tasksprefix = kwargs["blend_info"]["tasksprefix"]
+    blend_dependencies = kwargs["blend_dependencies"]
+
+
+    #TODO this is used for testing for the moment, will be changed
+    task_desc_path = "taskdesc-sec.template"
+    logger.debug("Opening file {0} to write".format(task_desc_path))
+    with open(task_desc_path,'w') as fout:
+
+        for task in sorted(blend_dependencies.keys()):    
+
+            if blend_dependencies[task]['Leaf'] == 'false':
+                continue
+
+            if suppressempty and blend_dependencies[task]["haspackages"] == 0:
+                if blend_dependencies[task]['test_always_lang']:
+                    logger.debug("Print empty task {0} because Test-always-lang is set\n".format(task))
+                else:
+                    logger.debug("The metapackage {2} will not be created because {0} dependant are in the pool and suppressempty was set {1}\n".format(blend_dependencies[task]["haspackages"], suppressempty, task))
+                    continue
+
+            fout.write("Task: {0}-{1}\n".format(tasksprefix, task))
+            fout.write("Section: {0}\n".format(blend));
+            fout.write("Description: {0}\n".format(blend_dependencies[task]["description"]))
+            fout.write("{0}".format(blend_dependencies[task]["long_description"])) #Already contains a newline
+            fout.write("Relevance: 10\n")
+
+            if blend_dependencies[task]["Enhances"]:
+                fout.write("Enhances: {0}\n".format(blend_dependencies[task]["Enhances"]))
+
+            if blend_dependencies[task]["metapackage"]:
+                #No use listing a metapackage as a key package, if no metapackage exist.
+                fout.write("Key: \n");
+                fout.write(" {0}-{1}\n".format(tasksprefix, task))
+
+            fout.write("Packages: list\n ")
+            for header in ["Depends", "Recommends"]:
+                if not blend_dependencies[task][header]:
+                    continue     
+                #Tasksel doesn't allow boolean(eg OR : |) comparisons in dependencies such as package1 | package2.
+                #so we include in the list the first of the alternative packages
+                alternatives_resolved = []
+                for pkg in blend_dependencies[task][header]:
+                    if '|' in pkg:
+                        alternatives_resolved.append(pkg.split('|')[0])
+                    else:
+                        alternatives_resolved.append(pkg)
+
+                fout.write("{0}".format("\n ".join(sorted(alternatives_resolved))))
+                fout.write("\n")
+                #fout.write("{0}".format("\n ".join(sorted(blend_dependencies[task][header]))))
+
+            fout.write("\n")
+
 def main():
     default_release = "testing"
 
@@ -601,6 +663,8 @@ def main():
                         help="suppress tasks without any recommended package")
     parser.add_argument("-c", dest="gencontrol", action="store_true", default=False,
                         help="Create new debian/control file.")
+    parser.add_argument("-t", dest="taskdesc", action="store_true", default=False,
+                        help="Print task descriptions and package list for task")
 
     parser.add_argument("-d", "--debug", dest="debug", action="store_true", default=False,
                         help="Print debug information")
@@ -615,8 +679,8 @@ def main():
     #----------------------------end of argparse and setup logging--------------------------------------#
 
     #at least a -c or -t argument must be provided
-    if not args.gencontrol:
-        logger.error("Argument -c(generate control file) is required.")
+    if not args.gencontrol and not args.taskdesc:
+        logger.error("Argument -c(generate control file) or -t(generate taskdescription file) is required.")
         sys.exit(-1)
 
     hasconfig = False
@@ -653,6 +717,15 @@ def main():
         gen_control(blend_info = blend_info, blend_dependencies = blend_dependencies,
             suppressempty = suppressempty, nodepends = nodepends, hasconfig = hasconfig)
 
+    elif args.taskdesc:
+        #we reuse the same code as above here BUT we need the blend_dependencies here without nodepends so we make sure we call it
+        #with nodepends = False no matter the command line argument, no need to descrease depends to recommends in any way for task description
+        blend_dependencies, available, missing, excluded = myudd.get_blend_dependecies(blend = blend_info["blend"], release = release, 
+            tasksprefix = blend_info["tasksprefix"], nodepends = False, taskdescription = True)
+        
+        gen_task_desc(blend_info = blend_info, blend_dependencies = blend_dependencies,
+            suppressempty = suppressempty)
+
 
     return 0
 
diff --git a/single/tester b/single/tester
index 979d17c..7e6439c 100755
--- a/single/tester
+++ b/single/tester
@@ -11,4 +11,12 @@ do
     ./sec-blend-gen-control -S -D -c -b $blend 
     
     diff control control-sec
+
+    #no need to generate and compare task-description files(they have exact the same data
+    #with the control files)
+    #echo "Generating task-description files for $blend."
+    #./blend-gen-control -S -t -b $blend 
+    #./sec-blend-gen-control -S -t -b $blend 
+
+    #diff taskdesc.template taskdesc-sec.template
 done
diff --git a/test_taskdesc b/test_taskdesc
new file mode 100755
index 0000000..82d7440
--- /dev/null
+++ b/test_taskdesc
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# simple script that generates task-description files with all available scripts we have
+# then it compares the taskdesc{-sec}.<arch> files with the taskdesc{-sec}.template files
+#for each available architecture
+
+DEBUG=1
+
+architectures=`psql -t udd -c "SELECT DISTINCT architecture FROM packages WHERE architecture != 'all';"`
+
+for blend in `psql -t udd -c 'SELECT blend FROM blends_metadata ORDER BY blend;'`
+do      
+    echo "Generating taskdesc files for $blend"
+    ./sec-blend-gen-control -S -t -b $blend
+
+    echo "Generating taskdesc.template files for $blend"
+    single/sec-blend-gen-control -S -t -b $blend
+
+    for arch in $architectures
+    do
+        #for example match only !s390 and not !s390x and in sed also remove the trailing spaces of the end of each line to avoid trailing spaces diffs 
+        grep -vE "\[\!$arch\]|\[\!$arch | \!$arch | \!$arch\]" taskdesc-sec.template | sed -e 's/\[.*\]//;s/[ \t]*$//' > taskdesc-sec.temp
+        #also remove trailing spaces from this file to make sure we avoid trailing spaces diffs
+        sed 's/[ \t]*$//' taskdesc-sec/${blend}-tasks.desc.$arch > taskdesc-sec.temp2
+        if [ $DEBUG != 0 ] ; then
+            echo "diff taskdesc-sec.temp taskdesc-sec/${blend}-tasks.desc.$arch"
+        fi
+        diff taskdesc-sec.temp taskdesc-sec.temp2
+    done
+done
+
+rm taskdesc-sec.temp taskdesc-sec.temp2
\ No newline at end of file
diff --git a/tester b/tester
index d4c1046..3753ebb 100755
--- a/tester
+++ b/tester
@@ -27,8 +27,8 @@ do
     ./sec-blend-gen-control -S -D -c -b $blend
     
     echo "Generating task-description files for $blend"
-    ./blend-gen-control -S -D -t -b $blend
-    ./sec-blend-gen-control -S -D -t -b $blend
+    ./blend-gen-control -S -t -b $blend
+    ./sec-blend-gen-control -S -t -b $blend
 
     dodiff "control"
     echo ""

-- 
Git repository for blends-gsoc code



More information about the Blends-commit mailing list