From 0c1f07cf63e89d35c2bab7606f18bc17e3ce9d4e Mon Sep 17 00:00:00 2001 From: hataejun Date: Wed, 27 Feb 2013 14:33:33 +0900 Subject: [PATCH] [Title] add package server register command apply zip size [Type] [Module] [Priority] [Jira#] [Redmine#] 8548 [Problem] [Cause] [Solution] [TestCase] --- src/common/package.rb | 4 +++- src/common/parser.rb | 3 +++ src/pkg_server/distribution.rb | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/package.rb b/src/common/package.rb index c8ae197..b05b3c8 100644 --- a/src/common/package.rb +++ b/src/common/package.rb @@ -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 diff --git a/src/common/parser.rb b/src/common/parser.rb index 7d25f44..58f4b4a 100644 --- a/src/common/parser.rb +++ b/src/common/parser.rb @@ -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" diff --git a/src/pkg_server/distribution.rb b/src/pkg_server/distribution.rb index 5aa613b..54771d0 100644 --- a/src/pkg_server/distribution.rb +++ b/src/pkg_server/distribution.rb @@ -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 -- 2.34.1