From: donghee yang Date: Mon, 11 Mar 2013 17:34:04 +0000 (+0900) Subject: [Title] Fixed the size calculation on MAC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f907555420cf901cd82f3cfb7fe422377764b0f6;p=sdk%2Ftools%2Fsdk-build.git [Title] Fixed the size calculation on MAC --- diff --git a/src/builder/Builder.rb b/src/builder/Builder.rb index c4855f5..5774c31 100644 --- a/src/builder/Builder.rb +++ b/src/builder/Builder.rb @@ -752,8 +752,6 @@ VERSION=\"#{version}\" " end def check_uncompressed_size(pkginfo, os, src_path) - # get category - os_category = Utils.get_os_category( os ) pkginfo.packages.each do |pkg| # skip if not support the target os @@ -761,12 +759,9 @@ VERSION=\"#{version}\" " next end - cmd = "du --block-size=1 -s #{src_path}/package/#{pkg.package_name}.package.#{os}" - - ret = Utils.execute_shell_return_ret(cmd) - if not ret.nil? then - uncompressed_size = ret.split(" ")[0] - pkg.uncompressed_size = uncompressed_size + size = Utils.get_directory_size("#{src_path}/package/#{pkg.package_name}.package.#{os}") + if not size.nil? then + pkg.uncompressed_size = "#{size}" end end diff --git a/src/common/utils.rb b/src/common/utils.rb index abae33c..3785ad9 100644 --- a/src/common/utils.rb +++ b/src/common/utils.rb @@ -624,6 +624,26 @@ class Utils end + def Utils.get_directory_size(path) + + os_category = get_os_category(HOST_OS) + if os_category == "macos" then + cmd = "du -sk \"#{path}\"" + ret = Utils.execute_shell_return(cmd); + if not ret.nil? and not ret[0].nil? then + return ret[0].split(" ")[0].to_i * 1024 + end + else + cmd = "du --block-size=1 -s \"#{path}\"" + ret = Utils.execute_shell_return(cmd); + if not ret.nil? and not ret[0].nil? then + return ret[0].split(" ")[0].to_i + end + end + + return nil + end + if defined?(HOST_OS).nil? then HOST_OS = Utils.identify_current_OS()