diff --git a/bin/crew b/bin/crew index 7ed77d877..20f1ed2bb 100755 --- a/bin/crew +++ b/bin/crew @@ -868,13 +868,17 @@ def prepare_package(destdir) # Allow postbuild to override the filelist contents @pkg.postbuild - # create file list - filelist = Dir[".{#{CREW_PREFIX},#{HOME}}/**/{*,.?*}"].filter_map { |e| File.file?(e) || File.symlink?(e) ? e[1..] : nil }.sort - total_size = filelist.sum { |file| File.file?(File.join(CREW_DEST_DIR, file)) ? File.size(File.join(CREW_DEST_DIR, file)) : 0 } + # Create file list and calculate file size + filelist = Dir[".{#{CREW_PREFIX},#{HOME}}/**/{*,.?*}"].select do |e| + File.file?(e) || File.symlink?(e) + end.to_h do |e| + # Ignore symlinks to prevent duplicating calculation. + [e[1..], File.symlink?(e) ? 0 : File.size(e)] + end File.write 'filelist', <<~EOF - # Total size: #{total_size} - #{filelist.join("\n")} + # Total size: #{filelist.values.sum} + #{filelist.keys.sort.join("\n")} EOF if Dir.exist?("#{CREW_LOCAL_REPO_ROOT}/manifest") && File.writable?("#{CREW_LOCAL_REPO_ROOT}/manifest")