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
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
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()