From 659a0db126bd984a83c36b1cafd4aaf545e114f0 Mon Sep 17 00:00:00 2001 From: SupeChicken666 Date: Mon, 18 Aug 2025 03:41:03 +0800 Subject: [PATCH] crew; Include file size in file list (#12515) * crew; Include file size in file list Signed-off-by: SupeChicken666 * Bump version Signed-off-by: SupeChicken666 * Use `.grep` instead of `.reject` Signed-off-by: SupeChicken666 * Bump version Signed-off-by: SupeChicken666 --------- Signed-off-by: SupeChicken666 Co-authored-by: Satadru Pramanik, DO, MPH, MEng --- bin/crew | 9 +++++++-- commands/files.rb | 2 +- commands/remove.rb | 2 +- lib/const.rb | 2 +- lib/convenience_functions.rb | 2 +- packages/gcc_dev.rb | 2 +- packages/gcc_lib.rb | 2 +- packages/glibc_build233.rb | 2 +- packages/glibc_build235.rb | 2 +- packages/glibc_dev235.rb | 2 +- packages/glibc_dev237.rb | 2 +- packages/glibc_lib235.rb | 2 +- packages/glibc_lib237.rb | 2 +- packages/llvm16_dev.rb | 2 +- packages/llvm16_lib.rb | 2 +- packages/llvm17_dev.rb | 2 +- packages/llvm17_lib.rb | 2 +- packages/llvm18_dev.rb | 2 +- packages/llvm18_lib.rb | 2 +- packages/llvm19_dev.rb | 2 +- packages/llvm19_lib.rb | 2 +- packages/llvm20_dev.rb | 2 +- packages/llvm20_lib.rb | 2 +- 23 files changed, 29 insertions(+), 24 deletions(-) diff --git a/bin/crew b/bin/crew index c1befbb89..271d871e1 100755 --- a/bin/crew +++ b/bin/crew @@ -833,8 +833,13 @@ def prepare_package(destdir) @pkg.postbuild # create file list - filelist = Dir[".{#{CREW_PREFIX},#{HOME}}/**/{*,.?*}"].filter_map { |e| File.file?(e) || File.symlink?(e) ? e[1..] : nil }.sort - File.write('filelist', "#{filelist.join("\n")}\n") + 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) ? File.size(file) : 0 } + + File.write 'filelist', <<~EOF + # Total size: #{total_size} + #{filelist.join("\n")} + EOF if Dir.exist?("#{CREW_LOCAL_REPO_ROOT}/manifest") && File.writable?("#{CREW_LOCAL_REPO_ROOT}/manifest") FileUtils.mkdir_p "#{CREW_LOCAL_REPO_ROOT}/manifest/#{ARCH}/#{@pkg.name.chr.downcase}" diff --git a/commands/files.rb b/commands/files.rb index 62df58ae8..4b1573992 100644 --- a/commands/files.rb +++ b/commands/files.rb @@ -26,7 +26,7 @@ class Command puts pkg.name.lightgreen + ": #{pkg.description}".lightblue # Read the file into memory as an array of lines. - filelist = File.readlines(filelist_path, chomp: true) + filelist = File.readlines(filelist_path, chomp: true).grep(/^(?!#)/) size = 0 filelist.each do |filename| diff --git a/commands/remove.rb b/commands/remove.rb index 9283bdf32..3f7de8c58 100644 --- a/commands/remove.rb +++ b/commands/remove.rb @@ -76,7 +76,7 @@ class Command # 1. The file exists in another installed package. filelist_path = File.join(CREW_META_PATH, "#{pkg.name}.filelist") if File.file?(filelist_path) - filelist = File.readlines(filelist_path, chomp: true) + filelist = File.readlines(filelist_path, chomp: true).grep(/^(?!#)/) overlap_files = ConvenienceFunctions.determine_conflicts(pkg.name, filelist_path, verbose: verbose) # essential_files should only contain filelists for packages already installed. essential_files = CREW_ESSENTIAL_PACKAGES.flat_map { |f| File.readlines(File.join(CREW_META_PATH, "#{f}.filelist"), chomp: true) if File.file?(File.join(CREW_META_PATH, "#{f}.filelist")) } diff --git a/lib/const.rb b/lib/const.rb index 6f2776803..ecedf1f0d 100644 --- a/lib/const.rb +++ b/lib/const.rb @@ -4,7 +4,7 @@ require 'etc' require 'open3' OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0' -CREW_VERSION ||= '1.64.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION +CREW_VERSION ||= '1.64.10' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION # Kernel architecture. KERN_ARCH ||= Etc.uname[:machine] diff --git a/lib/convenience_functions.rb b/lib/convenience_functions.rb index 29262b520..d6e6b29c8 100644 --- a/lib/convenience_functions.rb +++ b/lib/convenience_functions.rb @@ -18,7 +18,7 @@ class String; def blank? = strip.empty?; end class ConvenienceFunctions def self.determine_conflicts(pkg_name, filelist = File.join(CREW_META_PATH, "#{pkg_name}.filelist"), exclude_suffix = nil, verbose: false) conflicts = {} - target_filelist = File.readlines(filelist, chomp: true) + target_filelist = File.readlines(filelist, chomp: true).grep(/^(?!#)/) puts 'Checking for conflicts with files from installed packages...'.orange if verbose diff --git a/packages/gcc_dev.rb b/packages/gcc_dev.rb index 3429c591d..90c94fb1f 100644 --- a/packages/gcc_dev.rb +++ b/packages/gcc_dev.rb @@ -38,7 +38,7 @@ class Gcc_dev < Package puts 'Installing Gcc_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'gcc_build.filelist') abort 'File list for Gcc_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && !filename.include?('libgccjit') diff --git a/packages/gcc_lib.rb b/packages/gcc_lib.rb index 7bfa70d6c..5a36e5676 100644 --- a/packages/gcc_lib.rb +++ b/packages/gcc_lib.rb @@ -30,7 +30,7 @@ class Gcc_lib < Package puts 'Installing Gcc_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'gcc_build.filelist') abort 'File list for Gcc_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless filename.include?('.so') && !filename.include?('libgccjit') diff --git a/packages/glibc_build233.rb b/packages/glibc_build233.rb index edf9b1a31..e2f81402d 100644 --- a/packages/glibc_build233.rb +++ b/packages/glibc_build233.rb @@ -283,7 +283,7 @@ class Glibc_build233 < Package # This is the array of locales to save: @locales = %w[C cs_CZ de_DE en es_MX fa_IR fr_FR it_IT ja_JP ru_RU tr_TR zh] @localedirs = %W[#{CREW_PREFIX}/share/locale #{CREW_PREFIX}/share/i18n/locales] - @filelist = File.readlines("#{CREW_META_PATH}/glibc_build233.filelist") + @filelist = File.readlines("#{CREW_META_PATH}/glibc_build233.filelist").grep(/^(?!#)/) @localedirs.each do |localedir| Dir.chdir localedir do Dir['*'].each do |f| diff --git a/packages/glibc_build235.rb b/packages/glibc_build235.rb index 826a6a61e..8e22a8bea 100644 --- a/packages/glibc_build235.rb +++ b/packages/glibc_build235.rb @@ -278,7 +278,7 @@ class Glibc_build235 < Package # This is the array of locales to save: @locales = %w[C cs_CZ de_DE en es_MX fa_IR fr_FR it_IT ja_JP ru_RU tr_TR zh] @localedirs = %W[#{CREW_PREFIX}/share/locale #{CREW_PREFIX}/share/i18n/locales] - @filelist = File.readlines("#{CREW_META_PATH}/glibc_build235.filelist") + @filelist = File.readlines("#{CREW_META_PATH}/glibc_build235.filelist").grep(/^(?!#)/) @localedirs.each do |localedir| Dir.chdir localedir do Dir['*'].each do |f| diff --git a/packages/glibc_dev235.rb b/packages/glibc_dev235.rb index 17c60b746..24b40704b 100644 --- a/packages/glibc_dev235.rb +++ b/packages/glibc_dev235.rb @@ -27,7 +27,7 @@ class Glibc_dev235 < Package puts 'Installing Glibc_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'glibc_build235.filelist') abort 'File list for Glibc_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') || filename.include?('bin/') diff --git a/packages/glibc_dev237.rb b/packages/glibc_dev237.rb index 3f5373773..141ad2e5d 100644 --- a/packages/glibc_dev237.rb +++ b/packages/glibc_dev237.rb @@ -31,7 +31,7 @@ class Glibc_dev237 < Package puts 'Installing Glibc_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'glibc_build237.filelist') abort 'File list for Glibc_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') || filename.include?('bin/') diff --git a/packages/glibc_lib235.rb b/packages/glibc_lib235.rb index 4dc8a9c63..9460b6b3a 100644 --- a/packages/glibc_lib235.rb +++ b/packages/glibc_lib235.rb @@ -27,7 +27,7 @@ class Glibc_lib235 < Package puts 'Installing Glibc_build235 to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'glibc_build235.filelist') abort 'File list for Glibc_build235 does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless filename.include?('.so') || filename.include?('bin/') diff --git a/packages/glibc_lib237.rb b/packages/glibc_lib237.rb index 9b620a5ca..872cf93f0 100644 --- a/packages/glibc_lib237.rb +++ b/packages/glibc_lib237.rb @@ -30,7 +30,7 @@ class Glibc_lib237 < Package puts 'Installing Glibc_build237 to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'glibc_build237.filelist') abort 'File list for Glibc_build237 does not exist! Please run: crew reinstall glibc_build237'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') || filename.include?('bin/')) && File.file?(filename) diff --git a/packages/llvm16_dev.rb b/packages/llvm16_dev.rb index f93569e27..a4e22457a 100644 --- a/packages/llvm16_dev.rb +++ b/packages/llvm16_dev.rb @@ -36,7 +36,7 @@ class Llvm16_dev < Package puts 'Installing llvm16_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm16_build.filelist') abort 'File list for llvm16_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && filename.include?('libLLVM') diff --git a/packages/llvm16_lib.rb b/packages/llvm16_lib.rb index e5cd5ab26..00c504f17 100644 --- a/packages/llvm16_lib.rb +++ b/packages/llvm16_lib.rb @@ -33,7 +33,7 @@ class Llvm16_lib < Package puts 'Installing llvm16_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm16_build.filelist') abort 'File list for llvm16_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') && filename.include?('libLLVM')) || filename.include?('llvm-strip') diff --git a/packages/llvm17_dev.rb b/packages/llvm17_dev.rb index 0bfcb298e..b6310f8ae 100644 --- a/packages/llvm17_dev.rb +++ b/packages/llvm17_dev.rb @@ -39,7 +39,7 @@ class Llvm17_dev < Package puts 'Installing llvm17_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm17_build.filelist') abort 'File list for llvm17_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && filename.include?('libLLVM') diff --git a/packages/llvm17_lib.rb b/packages/llvm17_lib.rb index e7704053d..1de64994a 100644 --- a/packages/llvm17_lib.rb +++ b/packages/llvm17_lib.rb @@ -36,7 +36,7 @@ class Llvm17_lib < Package puts 'Installing llvm17_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm17_build.filelist') abort 'File list for llvm17_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') && filename.include?('libLLVM')) || filename.include?('llvm-strip') diff --git a/packages/llvm18_dev.rb b/packages/llvm18_dev.rb index 109830c1d..1dde8ec6d 100644 --- a/packages/llvm18_dev.rb +++ b/packages/llvm18_dev.rb @@ -40,7 +40,7 @@ class Llvm18_dev < Package puts 'Installing llvm18_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm18_build.filelist') abort 'File list for llvm18_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && filename.include?('libLLVM') diff --git a/packages/llvm18_lib.rb b/packages/llvm18_lib.rb index 83e2a2807..065e843de 100644 --- a/packages/llvm18_lib.rb +++ b/packages/llvm18_lib.rb @@ -37,7 +37,7 @@ class Llvm18_lib < Package puts 'Installing llvm18_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm18_build.filelist') abort 'File list for llvm18_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') && filename.include?('libLLVM')) || filename.include?('llvm-strip') diff --git a/packages/llvm19_dev.rb b/packages/llvm19_dev.rb index 585eccd72..e3aee2009 100644 --- a/packages/llvm19_dev.rb +++ b/packages/llvm19_dev.rb @@ -38,7 +38,7 @@ class Llvm19_dev < Package puts 'Installing llvm19_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm19_build.filelist') abort 'File list for llvm19_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && filename.include?('libLLVM') diff --git a/packages/llvm19_lib.rb b/packages/llvm19_lib.rb index c8dbfc04d..57ee602ee 100644 --- a/packages/llvm19_lib.rb +++ b/packages/llvm19_lib.rb @@ -37,7 +37,7 @@ class Llvm19_lib < Package puts 'Installing llvm19_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm19_build.filelist') abort 'File list for llvm19_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') && filename.include?('libLLVM')) || filename.include?('llvm-strip') diff --git a/packages/llvm20_dev.rb b/packages/llvm20_dev.rb index cdab40371..25065a3e0 100644 --- a/packages/llvm20_dev.rb +++ b/packages/llvm20_dev.rb @@ -38,7 +38,7 @@ class Llvm20_dev < Package puts 'Installing llvm20_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm20_build.filelist') abort 'File list for llvm20_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next if filename.include?('.so') && filename.include?('libLLVM') diff --git a/packages/llvm20_lib.rb b/packages/llvm20_lib.rb index a71c2b415..b9e2414cf 100644 --- a/packages/llvm20_lib.rb +++ b/packages/llvm20_lib.rb @@ -37,7 +37,7 @@ class Llvm20_lib < Package puts 'Installing llvm20_build to pull files for build...'.lightblue @filelist_path = File.join(CREW_META_PATH, 'llvm20_build.filelist') abort 'File list for llvm20_build does not exist!'.lightred unless File.file?(@filelist_path) - @filelist = File.readlines(@filelist_path, chomp: true).sort + @filelist = File.readlines(@filelist_path, chomp: true).grep(/^(?!#)/) @filelist.each do |filename| next unless (filename.include?('.so') && filename.include?('libLLVM')) || filename.include?('llvm-strip')