From: jonghwan2.park Date: Wed, 3 Jul 2013 05:37:20 +0000 (+0900) Subject: [Title] feature for making sdk-imgae X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec00b113db34cc512dc46f74c08713f91221c14d;p=sdk%2Ftools%2Fsdk-build.git [Title] feature for making sdk-imgae [Desc.] Change-Id: Ia26fd83112e7eccde8c9d018cdff2074082c18fb --- diff --git a/pkg-cli b/pkg-cli index 6c39e90..14226eb 100755 --- 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 diff --git a/src/pkg_server/client.rb b/src/pkg_server/client.rb index 58efd8b..2f18f62 100644 --- a/src/pkg_server/client.rb +++ b/src/pkg_server/client.rb @@ -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 diff --git a/src/pkg_server/clientOptParser.rb b/src/pkg_server/clientOptParser.rb index 10c2cc3..76b6e51 100644 --- a/src/pkg_server/clientOptParser.rb +++ b/src/pkg_server/clientOptParser.rb @@ -58,7 +58,10 @@ def option_error_check( options ) options[:url].nil? or options[:url].empty? then raise ArgumentError, "Usage: pkg-cli download -P -u [-o ] [-l ] [--trace]" end - + when "make-img" then + if options[:url].nil? or options[:url].empty? then + raise ArgumentError, "Usage: pkg-cli make-img -u [-o ]" + 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 ] [--force]" + "\n" \ + "\t" + "pkg-cli download -P -u [-o ] [-l ] [--trace]" + "\n" \ + + "\t" + "pkg-cli make-img -u [-o ]" + "\n" \ + "\t" + "pkg-cli install -P -u [-o ] [-l ] [--trace] [--force]" + "\n" \ + "\t" + "pkg-cli install-file -P [-l ] [-u ] [--trace] [--force]" + "\n" \ + "\t" + "pkg-cli uninstall -P [-l ] [--trace]" + "\n" \ @@ -153,8 +158,8 @@ def option_parse + "\t" + "pkg-cli list-rpkg -u [-o ]" + "\n" \ + "\t" + "pkg-cli show-lpkg -P [-l ]" + "\n" \ + "\t" + "pkg-cli list-lpkg [-l ]" + "\n" \ - + "\t" + "pkg-cli snapshotlist -u [--all]" + "\n" \ - + "\t" + "pkg-cli changelog -u [-snapshot ]" + "\n" \ + + "\t" + "pkg-cli snapshotlist -u [--all]" + "\n" \ + + "\t" + "pkg-cli changelog -u [-snapshot ]" + "\n" \ + "\t" + "pkg-cli build-dep -P -u [-o ]" + "\n" \ + "\t" + "pkg-cli install-dep -P -u [-o ]" + "\n" \ + "\t" + "pkg-cli register -P -a -d -w " + "\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