add generate dependency graph tool in pkg-cli 45/15245/1
authorHyoun Jiil <jiil.hyoun@samsung.com>
Fri, 17 Jan 2014 08:23:31 +0000 (17:23 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Fri, 17 Jan 2014 08:23:31 +0000 (17:23 +0900)
[Description] add generate dependency graph tool in pkg-cli

Change-Id: I3280a29e42633e05ebcc9cae408552b890d21fa8
Signed-off-by: Hyoun Jiil <jiil.hyoun@samsung.com>
package/changelog
package/pkginfo.manifest
pkg-cli
src/build_server/RemoteBuilder.rb
src/pkg_server/client.rb
src/pkg_server/clientOptParser.rb

index bd75eee..75725d9 100644 (file)
@@ -1,3 +1,6 @@
+* 2.1.56
+- add gen dependency graph tool in pkg-cli
+== hyoun jiil <jiil.hyoun@samsung.com> 2014-01-17
 * 2.1.55
 - added uselatest option in build-cli 
 -- it support fullbuild using commit id
index f402b5d..066bb83 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :2.1.55
+Version :2.1.56
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
 
 Package : tizen-dibs-test
diff --git a/pkg-cli b/pkg-cli
index a3c10ae..b524f30 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -89,6 +89,13 @@ when "make-img" then
                exit 1
        end
        client.make_img( option[:os], option[:info] )
+when "dep-graph" then
+       client = Client.create( option[:url], option[:loc], nil )
+       if client.nil? then
+               puts "Error: Cannot create package client!"
+               exit 1
+       end
+       client.gen_dep_graph( option[:os], option[:type] )
 when "install" then
        client = Client.create( option[:url], option[:loc], nil )
        if client.nil? then
index 337ac6f..d6b017f 100644 (file)
@@ -521,13 +521,17 @@ class RemoteBuilder
                        if @log.path.nil? then
                                io.each do |l|
                                        if l.start_with?("=TRANSFER_END") then
+                        @log.info("transfered")
+                        @log.info(l)
                                                break
                                        else 
                                                puts l
                                        end
                                end
                        end
-                       result = Marshal.load(io.read)
+            ioread = io.read
+            @log.info("marshal load : [#{ioread}]")
+                       result = Marshal.load(ioread)
                end
 
                return result
index 2622512..0007fa5 100644 (file)
@@ -366,6 +366,58 @@ class Client
 
                return file_local_path
        end
+    public
+    def gen_dep_graph(os, type)
+               if (os == "all") then
+            puts "==graph explain=="
+            puts "  box : package name"
+            puts "  red arrow : install dependency"
+            puts "  blue arrow : build dependency"
+            puts "execute below graph generate command on your shell\n"
+                       @support_os_list.each do |os| make_dep_graph(os, type) end
+               else
+            if(@support_os_list.include? os)
+                puts "execute below command on your shell\n"
+                           make_dep_graph(os, type)
+            else
+                @log.error "not support os name : #{os}\n server supports #{@support_os_list.join(',')}"
+            end
+               end
+    end
+
+    def dot_ident(string)
+        return string.gsub(/[^a-zA-z0-9_]/,'')
+    end
+
+    def make_dep_graph(os,type)
+        all_pkg_list = @pkg_hash_os[os].values
+        string = "digraph #{type}_dependency {\nranksep=1.5\n"
+        all_pkg_list.each { |pkg|
+            id_pkg = dot_ident(pkg.package_name)
+            string += "#{id_pkg} [label=\"#{pkg.package_name}\",shape=box];\n"
+            if(type.eql? 'install' or type.eql? 'all') then
+                pkg.install_dep_list.each { |dep|
+                    if(dep.target_os_list.include? os or dep.target_os_list.empty?) then
+                        string += "#{id_pkg} -> #{dot_ident(dep.package_name)} [color=red];\n"
+                    else
+                        string += "#{id_pkg} -> #{dot_ident(dep.package_name)} [color=red,label=\"#{dep.target_os_list[0]}\",fontcolor=red,style=bold];\n"
+                    end
+                }
+            end
+            if(type.eql? 'build' or type.eql? 'all') then
+                pkg.build_dep_list.each { |dep|
+                    if(dep.target_os_list.include? os or dep.target_os_list.empty?) then
+                        string += "#{id_pkg} -> #{dot_ident(dep.package_name)} [color=blue];\n"
+                    else
+                        string += "#{id_pkg} -> #{dot_ident(dep.package_name)} [color=blue,label=\"#{dep.target_os_list[0]}\",fontcolor=blue,style=bold];\n"
+                    end
+                }
+            end
+        }
+        string += "}"
+        File.open("#{type}_dep_#{os}.dot","w"){|file| file.write(string)}
+        puts "dot -Tpng -o #{type}_dep_#{os}.png #{type}_dep_#{os}.dot"
+    end
 
        public
        def make_img(os, img_info)
index 7ca31fe..3b2ccfe 100644 (file)
@@ -32,6 +32,7 @@ require "utils"
 
 def set_default( options )
        if options[:t].nil? then options[:t] = false end
+       if options[:type].nil? then options[:type] = 'all' end
        if options[:f].nil? then options[:f] = false end
        if options[:v].nil? then options[:v] = false end
  if options[:all].nil? then options[:all] = false end
@@ -62,6 +63,10 @@ def option_error_check( options )
                if options[:url].nil? or options[:url].empty? then
                        raise ArgumentError, "Usage: pkg-cli make-img -u <package server url> [-o <os>] [-m <image info>]"
                end
+       when "dep-graph" then
+               if options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli dep-graph -u <package server url> [-o <os>] [--dep_type <dependency type>]"
+               end
        when "install" then
                if options[:pkg].nil? or options[:pkg].empty? or
                                options[:url].nil? or options[:url].empty? then
@@ -149,6 +154,7 @@ def option_parse
                + "\t" + "pkg-cli clean [-l <location>] [--force]" + "\n" \
                + "\t" + "pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]" + "\n" \
                + "\t" + "pkg-cli make-img -u <package server url> [-o <os>] [-i <image info>]" + "\n" \
+               + "\t" + "pkg-cli dep-graph -u <package server url> [-o <os>] [--dep_type <dependency type>]" + "\n" \
                + "\t" + "pkg-cli install -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace] [--force]" + "\n" \
                + "\t" + "pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
                + "\t" + "pkg-cli uninstall -P <package name> [-l <location>] [--trace]" + "\n" \
@@ -208,6 +214,10 @@ def option_parse
                        options[:f] = true
                end
 
+               opts.on( '--dep_type <dependency type>', 'all/build/install' ) do |type|
+                       options[:type] = type
+               end
+
         opts.on( '-i', '--info <image info>', 'sdk image information : http://download.tizen.org/sdk/packages/official' ) do |image_info|
                        options[:info] = image_info
                end
@@ -238,7 +248,7 @@ def option_parse
                cmd.eql? "install" or cmd.eql? "show-rpkg" or
                cmd.eql? "list-rpkg" or
                cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or
-               cmd.eql? "list-lpkg" or
+               cmd.eql? "list-lpkg" or cmd.eql? "dep-graph" or
                cmd.eql? "install-file" or cmd.eql? "clean" or
                cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
                cmd.eql? "build-dep" or cmd.eql? "install-dep" or