From b9cdfe21fc7c1dbfa2f6ce7a087a47556dfff5df Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 14 Jul 2015 11:56:34 -0700 Subject: [PATCH] keg_relocate: relocate all text files. Work out what's text and what's not using `file`. Also, rename `keg_fix_install_names` to `keg_relocate` because that's a more accurate description of what it does now. Closes Homebrew/homebrew#41663. Signed-off-by: Mike McQuaid --- Library/Homebrew/keg.rb | 2 +- ...g_fix_install_names.rb => keg_relocate.rb} | 58 +++---------------- 2 files changed, 8 insertions(+), 52 deletions(-) rename Library/Homebrew/{keg_fix_install_names.rb => keg_relocate.rb} (82%) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 20e24d1ec5..cf4be6cc05 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -1,5 +1,5 @@ require "extend/pathname" -require "keg_fix_install_names" +require "keg_relocate" require "formula_lock" require "ostruct" diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_relocate.rb similarity index 82% rename from Library/Homebrew/keg_fix_install_names.rb rename to Library/Homebrew/keg_relocate.rb index a6ddb970fd..a666702735 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -38,10 +38,7 @@ class Keg end end - files = pkgconfig_files | libtool_files | script_files | plist_files - files << tab_file if tab_file.file? - - files.group_by { |f| f.stat.ino }.each_value do |first, *rest| + text_files.group_by { |f| f.stat.ino }.each_value do |first, *rest| s = first.open("rb", &:read) changed = s.gsub!(old_cellar, new_cellar) changed = s.gsub!(old_prefix, new_prefix) || changed @@ -161,55 +158,14 @@ class Keg mach_o_files end - def script_files - script_files = [] - - # find all files with shebangs - find do |pn| + def text_files + text_files = [] + path.find do |pn| next if pn.symlink? or pn.directory? - script_files << pn if pn.text_executable? + next if Metafiles::EXTENSIONS.include? pn.extname + text_files << pn if Utils.popen_read("/usr/bin/file", pn).include?("text") end - script_files - end - - def pkgconfig_files - pkgconfig_files = [] - - %w[lib share].each do |dir| - pcdir = path.join(dir, "pkgconfig") - - pcdir.find do |pn| - next if pn.symlink? or pn.directory? or pn.extname != '.pc' - pkgconfig_files << pn - end if pcdir.directory? - end - - pkgconfig_files - end - - def libtool_files - libtool_files = [] - - # find .la files, which are stored in lib/ - lib.find do |pn| - next if pn.symlink? or pn.directory? or pn.extname != '.la' - libtool_files << pn - end if lib.directory? - libtool_files - end - - def plist_files - plist_files = [] - - self.find do |pn| - next if pn.symlink? or pn.directory? or pn.extname != '.plist' - plist_files << pn - end - plist_files - end - - def tab_file - join(Tab::FILENAME) + text_files end end