[Title] Fixed the size calculation on MAC
authordonghee yang <donghee.yang@samsung.com>
Mon, 11 Mar 2013 17:34:04 +0000 (02:34 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Mon, 11 Mar 2013 17:34:04 +0000 (02:34 +0900)
src/builder/Builder.rb
src/common/utils.rb

index c4855f5f780a45efc1ef55aae758274fe6c1c8a6..5774c31476e2726db109983a0be5a498607fbb5f 100644 (file)
@@ -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
 
index abae33ca89ae713594d5029ff49b9ab6646ff849..3785ad946e536c2789113e744b2f41498780360e 100644 (file)
@@ -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()