[Title] feature for making sdk-imgae
authorjonghwan2.park <jonghwan2.park@samsung.com>
Wed, 3 Jul 2013 05:37:20 +0000 (14:37 +0900)
committerjonghwan2.park <jonghwan2.park@samsung.com>
Wed, 3 Jul 2013 05:37:20 +0000 (14:37 +0900)
[Desc.]

Change-Id: Ia26fd83112e7eccde8c9d018cdff2074082c18fb

pkg-cli
src/pkg_server/client.rb
src/pkg_server/clientOptParser.rb

diff --git a/pkg-cli b/pkg-cli
index 6c39e9071a9431bfa9e5265a9babe732d1325c50..14226ebfdcb29f070a9909abd98b50851f5398f3 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -82,6 +82,13 @@ when "download" then
                exit 1
        end                     
        file_loc = client.download( option[:pkg], option[:os], option[:t] )
+when "make-img" then
+       client = Client.create( option[:url], option[:loc], nil )
+       if client.nil? then
+               puts "Error: Cannot create package client!"
+               exit 1
+       end
+       client.make_img( option[:os] )
 when "install" then
        client = Client.create( option[:url], option[:loc], nil )
        if client.nil? then
index 58efd8b24815b4122980a9d446c65b6dc52baceb..2f18f62861b6f87b81ea5e110ce80f904c055eae 100644 (file)
@@ -368,6 +368,55 @@ class Client
                return file_local_path
        end
 
+       public
+       # make sdk image
+       def make_img(os)
+               # get package list
+               all_pkg_list = @pkg_hash_os[os].values
+
+               # select meta and install-type packages
+               img_pkg_list = []
+               all_pkg_list.each { |pkg|
+                       attr = get_attr_from_pkg(pkg.package_name, os, "attribute")
+                       if attr.nil? or attr.empty? then next end
+                       if attr[0].strip.upcase.eql? "ROOT" or attr[0].strip.upcase.eql? "INSTALL" then
+                               dependent_pkg_list = get_install_dependent_packages(pkg.package_name, os, true, true)
+                               img_pkg_list = img_pkg_list + dependent_pkg_list
+                       end
+               }
+               img_pkg_list.uniq!
+
+               # init workspace
+               workspace = @location+"/temp_for_tizen_sdk_imgs_#{os}"
+               if File.directory? workspace then FileUtils.remove_dir(workspace, true) end
+               
+               # download packages
+               img_pkg_list.each do |pkg| download(pkg, os, false, "#{workspace}/binary") end
+
+               # write pkg_list_os file
+               FileUtils.cp("#{get_pkglist_path}/pkg_list_#{os}", "#{workspace}")
+
+               # write os_info file
+               File.open("#{workspace}/#{OS_INFO_FILE}", 'w') do |f| f.puts os end
+
+               # compress files
+               snapshot = snapshot_path.split('/')[-1]
+               img_name = "TIZNE-SDK-IMG_#{snapshot}_#{os}.zip"
+               cmd = "cd #{workspace}; zip -q -r #{@location}/TIZNE-SDK-IMG_#{snapshot_path.split('/')[-1]}_#{os}.zip *;"
+               Utils.execute_shell_with_log(cmd, @log.path)
+
+               # clean workspace
+               FileUtils.remove_dir(workspace, true)
+               @log.info "<< SDK-Image Info. >>"
+               @log.info " - server addr : #{@server_addr}"
+               @log.info " - snapshot : #{snapshot}"
+               @log.info " - os : #{os}"
+               @log.info " - location : #{location}/"
+               @log.info " - name : #{img_name}"
+
+               return
+       end
+
        private
        def get_file_from_cache(filename, pkg_checksum, pkg_size, location)
                if not File.directory? location then return nil end
@@ -1697,7 +1746,7 @@ class Client
                if addr.nil? then addr = @server_addr end
                addr_arr = addr.split('/')
                if addr_arr[-2].eql? "snapshots" then
-                       return addr_arr[0..-3].join("/"), addr_arr[-2..-1].join("/")
+                       return addr_arr[0..-3].join("/"), "/"+addr_arr[-2..-1].join("/")
                else
                        return nil
                end
@@ -1876,7 +1925,7 @@ class Client
 
                attr = get_attr_from_pkg(pkg_name, os, "attribute")
                if attr.nil? or attr.empty? then return false end
-               if attr[0].strip.upcase.eql? "META" then return true
+               if attr[0].strip.upcase.eql? "ROOT" then return true
                else return false end
        end
 
index 10c2cc3bf27752c2331c1c5be57267da13f5905f..76b6e5185527e3e9eeb81e6c5e934d6c5f514ba5 100644 (file)
@@ -58,7 +58,10 @@ def option_error_check( options )
                                options[:url].nil? or options[:url].empty? then
                        raise ArgumentError, "Usage: pkg-cli download -P <package name> -u <package server url> [-o <os>] [-l <location>] [--trace]"
                end
-
+       when "make-img" then
+               if options[:url].nil? or options[:url].empty? then
+                       raise ArgumentError, "Usage: pkg-cli make-img -u <package server url> [-o <os>]"
+               end
        when "install" then
                if options[:pkg].nil? or options[:pkg].empty? or
                                options[:url].nil? or options[:url].empty? then
@@ -128,6 +131,7 @@ def option_parse
                + "\n" + "Subcommands:" + "\n" \
                + "\t" + "clean         Delete the package in your SDK environment." + "\n" \
                + "\t" + "download      Download the package in your SDK environment." + "\n" \
+               + "\t" + "make-img      Make SDK-Image." + "\n" \
                + "\t" + "install       Download the package from package-server and install the package in your SDK environment." + "\n" \
                + "\t" + "install-file  Install the package in your SDK environment." + "\n" \
                + "\t" + "uninstall     Uninstall the package in your SDK environment." + "\n" \
@@ -137,13 +141,14 @@ def option_parse
                + "\t" + "list-rpkg     Show the all packages in the package-server." + "\n" \
                + "\t" + "show-lpkg     Show the package in your SDK environment." + "\n" \
                + "\t" + "list-lpkg     Show the all packages in your SDK environment." + "\n" \
-  + "\t" + "snapshotlist  Show the snapshot list in your SDK environment." + "\n" \
-  + "\t" + "changelog     Show the change log in your SDK environment." + "\n" \
+               + "\t" + "snapshotlist  Show the snapshot list in your SDK environment." + "\n" \
+               + "\t" + "changelog     Show the change log in your SDK environment." + "\n" \
                + "\t" + "build-dep     Show build-dependency packages" + "\n" \
                + "\t" + "install-dep   Show install-dependency packages" + "\n" \
                + "\n" + "Subcommand usage:" + "\n" \
                + "\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>]" + "\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" \
@@ -153,8 +158,8 @@ def option_parse
                + "\t" + "pkg-cli list-rpkg -u <package server url> [-o <os>]" + "\n" \
                + "\t" + "pkg-cli show-lpkg -P <package name> [-l <location>]" + "\n"  \
                + "\t" + "pkg-cli list-lpkg [-l <location>]" + "\n" \
-  + "\t" + "pkg-cli snapshotlist -u <package server url> [--all]" + "\n"  \
-  + "\t" + "pkg-cli changelog -u <package server url> [-snapshot <snapshot name,snapshot name>]" + "\n"  \
+               + "\t" + "pkg-cli snapshotlist -u <package server url> [--all]" + "\n"  \
+               + "\t" + "pkg-cli changelog -u <package server url> [-snapshot <snapshot name,snapshot name>]" + "\n"  \
                + "\t" + "pkg-cli build-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
                + "\t" + "pkg-cli install-dep -P <package name> -u <package server url> [-o <os>]" + "\n" \
                + "\t" + "pkg-cli register -P <package file path> -a <server address> -d <distribution name> -w <password>" + "\n" \
@@ -225,7 +230,7 @@ def option_parse
        end
 
        cmd = ARGV[0]
-       if  cmd.eql? "download" or
+       if  cmd.eql? "download" or cmd.eql? "make-img" or
                cmd.eql? "install" or cmd.eql? "show-rpkg" or
                cmd.eql? "list-rpkg" or
                cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or