[Title] add package server register command apply zip size
authorhataejun <taejun.ha@samsung.com>
Wed, 27 Feb 2013 05:33:33 +0000 (14:33 +0900)
committerhataejun <taejun.ha@samsung.com>
Wed, 27 Feb 2013 05:33:33 +0000 (14:33 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#] 8548
[Problem]
[Cause]
[Solution]
[TestCase]

src/common/package.rb
src/common/parser.rb
src/pkg_server/distribution.rb

index c8ae1973608113e97ac4c30a91a448d911a9d9c4..b05b3c83728e1a0463c48c3fc2824f070899ecb3 100644 (file)
@@ -27,7 +27,7 @@ Contributors:
 =end
 
 class Package
-       attr_accessor :package_name, :label, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
+       attr_accessor :package_name, :label, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :uncompressed_size, :description, :os_list, :custom, :change_log
        def initialize (package_name)
                @package_name = package_name
                @label = ""
@@ -47,6 +47,7 @@ class Package
                @origin = ""
                @checksum = ""
                @size = ""
+               @uncompressed_size = ""
                @description = ""
                @custom = ""
                @change_log = {}
@@ -90,6 +91,7 @@ class Package
                if not @origin.empty? then string = string + "\n" + "Origin : " + @origin end
                if not @checksum.empty? then string = string + "\n" + "SHA256 : " + @checksum end
                if not @size.empty? then string = string + "\n" + "Size : " + @size end
+               if not @uncompressed_size.empty? then string = string + "\n" + "Uncompressed-size : " + @uncompressed_size end
                if not @custom.empty? then string = string + "\n" + @custom end
                if not @description.empty? then string = string + "\n" + "Description : " + @description end
                return string
index 7d25f44a78580b7e84651ca039434d1391f65b98..58f4b4aeaa52915ea1c40edddc48dadd310b479a 100644 (file)
@@ -193,6 +193,9 @@ class Parser
                                        when /^Size$/i then
                                                package.size = l.sub(/^[ \t]*Size[ \t]*:[ \t]*/i,"").strip
                                                multi_line = nil
+                                       when /^Uncompressed-size$/i then
+                                               package.uncompressed_size = l.sub(/^[ \t]*Uncompressed-size[ \t]*:[ \t]*/i,"").strip
+                                               multi_line = nil
                                        when /^Description$/i then
                                                package.description = l.sub(/^[ \t]*Description[ \t]*:[ \t]*/i,"").strip
                                                multi_line = "Description"
index 5aa613b129fb992961d473044546ec4d328cb014..54771d092df4e2a26df97e2f26c06bf2a988f874 100644 (file)
@@ -95,6 +95,14 @@ class Distribution
                        pkg.size = `du -b #{file_path}`.split[0].strip
                end
 
+               if pkg.uncompressed_size.empty? then
+                       if File.extname( file_path ).eql? ".zip" then
+                               output = `zipinfo -t #{file_path}`
+
+                               pkg.uncompressed_size = output.scan(/\d+/)[1]
+                       end
+               end
+
                @pkg_hash_os[pkg.os][pkg.package_name] = pkg
 
                return pkg