- add generateBuildStatus to spec2yocto.
authorRonan Le Martret <ronan@fridu.net>
Tue, 23 Jul 2013 15:22:14 +0000 (17:22 +0200)
committerRonan Le Martret <ronan@fridu.net>
Tue, 23 Jul 2013 15:22:14 +0000 (17:22 +0200)
proto-meta-Tizen_ivi_3.0/specfile-patch/libgcrypt.spec.patch
tools/spec2yocto.py

index 236423c..778434b 100644 (file)
@@ -1,13 +1,22 @@
 diff --git a/packaging/libgcrypt.spec b/packaging/libgcrypt.spec
-index 36a1ec3..2de3e25 100644
+index 36a1ec3..d82c5b6 100644
 --- a/packaging/libgcrypt.spec
 +++ b/packaging/libgcrypt.spec
 @@ -50,6 +50,8 @@ autoreconf -fi
                --enable-digests="$ENABLE_DIGEST"
  make %{?_smp_mflags}
  
-+if [ -f %{buildroot}%{_infodir}/gcrypt.info-1 ]; then gzip %{buildroot}%{_infodir}/gcrypt.info-1 ; fi
++
 +
  %check
  # Nice idea. however this uses /dev/random, which hangs
  # on hardware without random feeds.
+@@ -58,6 +60,8 @@ make %{?_smp_mflags}
+ %install
+ %make_install
++if [ -f %{buildroot}%{_infodir}/gcrypt.info-1 ]; then gzip %{buildroot}%{_infodir}/gcrypt.info-1 ; fi
++
+ %post  -p /sbin/ldconfig
+ %postun -p /sbin/ldconfig
index 42fe9d7..546c9f3 100755 (executable)
@@ -1278,7 +1278,6 @@ Group: devel
                     depends_res[self.__base_name] = build_requires_list
                 else:
                     depends_res[package_name] = build_requires_list
-
         return depends_res
 
     def __clean_package_line( self, package_line ):
@@ -2175,74 +2174,6 @@ class manifestCollection:
 
             MetaSpec.mExtraRProvidesDico[k_package].extend( raw_list )
 
-
-# def main2():
-#     '''
-#     main fonction of spec2yocto
-#     '''
-#     command_list = ["prep", "compile", "install", "createRecipes", "generatePseudoSpecfile"]
-#
-#     if len( sys.argv ) < 2 :
-#         print "%s take on parameter \"%s\"." % ( sys.argv[0], ", ".join( command_list ) )
-#         sys.exit( 1 )
-#
-#     exec_command = sys.argv[1]
-#     if len( sys.argv ) > 2:
-#         spec_path = sys.argv[2]
-#         spec_path = spec_path.replace( "\n", "" )
-#
-#     if len( sys.argv ) > 3:
-#         package_pn = sys.argv[3]
-#     else:
-#         package_pn = None
-#
-#     if exec_command == "prep":
-#         print SpecParser( spec_path, package_pn = package_pn ).get_prep_section()
-#         res = 0
-#
-#     elif exec_command == "compile":
-#         res = SpecParser( spec_path, package_pn = package_pn ).get_build_section()
-#         if res != 1:
-#             print res
-#             res = 0
-#
-#     elif exec_command == "install":
-#         res = SpecParser( spec_path, package_pn = package_pn ).get_install_section()
-#         print res
-#
-#     elif exec_command == "generatePseudoSpecfile" :
-#         a_spec_parser = SpecParser( spec_path )
-#         a_spec_parser.parse_raw_spec_file()
-#         res = a_spec_parser.get_clean_raw()
-#         if res != 1:
-#             print res
-#             res = 0
-#
-#     elif exec_command == "have_macro_configure":
-#         a_spec_parser = SpecParser( spec_path )
-#         a_spec_parser.parse_raw_spec_file()
-#         print a_spec_parser.have_macro_configure()
-#         res = 0
-#
-#     elif exec_command == "have_macro_reconfigure":
-#         a_spec_parser = SpecParser( spec_path )
-#         a_spec_parser.parse_raw_spec_file()
-#         print a_spec_parser.have_macro_reconfigure()
-#         res = 0
-#
-#     elif exec_command == "createRecipes":
-#         pkg_co = PackagesCollection()
-#         pkg_co.save_package_provided_file()
-#
-#     elif exec_command == "manifestToList":
-#         pkg_co = manifestCollection()
-#         pkg_co.print_list()
-#
-#     else:
-#         print exec_command, " is not a valid exec_command. \"", " ".join( command_list ), "\""
-#
-#     sys.exit( 0 )
-
 TERMINAL_COLORS = {"black": "\033[30;1m",
                    "red": "\033[31;1m",
                    "green": "\033[32;1m",
@@ -2324,6 +2255,100 @@ def dump_group(project,group_dico):
             for pkg in group_dico[group]:
                 group_file.write( "RDEPENDS_${PN} += \"%s\"\n" % pkg )
 
+def generateBuildStatus( project_path ):
+    res_native = {}
+    res = {}
+    if not os.path.isdir( project_path ):
+            msg = "The path \"%s\" is not a directory."
+            msg = msg % ( project_path )
+            print >> sys.stderr, colorize( msg, "red" )
+            sys.exit( 1 )
+
+    for package_path in os.listdir( project_path ):
+        project_full_path = os.path.join( project_path, package_path )
+        if  ( package_path == "build_stats" ) and os.path.isfile( project_full_path )  :
+            pass
+
+        elif os.path.isdir( project_full_path ):
+            BN, PV, PR = cleanPackageName( package_path )
+            res_status = check_package_status( project_full_path )
+
+            if BN.endswith("-native"):
+                res_native[BN] = [PV ] + res_status
+            else:
+                res[BN] = [PV ] + res_status
+
+        # ignorefiles
+        elif package_path in ["."]:
+            pass
+
+        else:
+            msg = "This directory should not contain the file \"%s\"."
+            msg = msg % ( package_path )
+            print >> sys.stderr, colorize( msg, "red" )
+            sys.exit( 1 )
+
+    return res_native, res
+        
+def cleanPackageName( package_path ):
+    if  package_path.count( "-" ) < 2:
+        msg = "unknow format for package \"%s\"."
+        msg = msg % ( package_path )
+        print >> sys.stderr, colorize( msg, "red" )
+        sys.exit( 1 )
+    
+    PR=package_path[package_path.rindex("-")+1:]
+    package_path=package_path[:package_path.rindex("-")]
+    PV=package_path[package_path.rindex("-")+1:]
+    BN=package_path[:package_path.rindex("-")]
+    
+    return BN, PV, PR
+
+
+def check_package_status( project_full_path ):
+    tasks_order = ["do_fetch",
+                   "do_unpack",
+                   "do_patch",
+                   "do_populate_lic",
+                   "do_configure",
+                   "do_compile",
+                   "do_install",
+                   "do_populate_sysroot",
+                   "do_package",
+                   "do_packagedata",
+                   "do_package_write_rpm"]
+    
+    max_index=-1
+    for package_task in os.listdir( project_full_path ):
+        if package_task in tasks_order:
+            task_index = tasks_order.index( package_task )
+
+            if task_index > max_index:
+                max_index = task_index
+
+    if max_index == -1:
+        msg = "No log task in \"%s\"."
+        msg = msg % ( project_full_path )
+        print >> sys.stderr, colorize( msg, "red" )
+        sys.exit( 1 )
+
+    last_task = tasks_order[max_index][3:]
+
+    task_status = ""
+    status = "unknow"
+    with open( os.path.join( project_full_path, tasks_order[max_index] ) ) as status_file:
+        for line in status_file:
+            if line.startswith( "Status: " ):
+                status = line[len( "Status: " ):].replace( "\n", "" ).replace( " ", "" )
+                break
+    if last_task == "package_write_rpm" and status == "PASSED":
+        status = "OK"
+
+    return [last_task, status]
+
+
+
+
 def clean_Packagegroup( project,group_dico ):
     group_dico_tmp = {}
 
@@ -2537,6 +2562,37 @@ class spec2yoctoCommandline( cmdln.Cmdln ):
                   action = "store",
                   default = None,
                   help = "run the in debug mode.[yes/no]" )
+    def do_generateBuildStatus( self, subcmd, opts, project_path ):
+        """${cmd_name}: print the list of package in projects.
+
+        ${cmd_usage}--
+        ${cmd_option_list}
+        """
+        global DEBUG_RUN
+        if opts.debug == "no":
+            DEBUG_RUN = False
+        elif opts.debug == "yes":
+            DEBUG_RUN = True
+
+        res_native, res = generateBuildStatus( project_path )
+
+        res_native_keys = res_native.keys()
+        res_keys = res.keys()
+
+        res_native_keys.sort()
+        res_keys.sort()
+
+        for r in res_native_keys:
+            print r + "\t" + "\t".join( res_native[r] )
+        print
+        for r in res_keys:
+            print r + "\t" + "\t".join( res[r] )
+
+
+    @cmdln.option( "--debug",
+                  action = "store",
+                  default = None,
+                  help = "run the in debug mode.[yes/no]" )
     def do_generatePseudoSpecfile( self, subcmd, opts, spec_path ):
         """${cmd_name}: print the list of package in projects.