diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb index 733734adb5..7e44b606ba 100644 --- a/Library/Homebrew/cmd/bottle.rb +++ b/Library/Homebrew/cmd/bottle.rb @@ -42,33 +42,17 @@ module Homebrew extend self include Utils::Inreplace end - def uniq_by_ino(list) - h = {} - list.each do |e| - ino = e.stat.ino - h[ino] = e unless h.key? ino - end - h.values - end - def keg_contains string, keg if not ARGV.homebrew_developer? return quiet_system 'fgrep', '--recursive', '--quiet', '--max-count=1', string, keg end - # Find all files that still reference the keg via a string search - keg_ref_files = `/usr/bin/fgrep --files-with-matches --recursive "#{string}" "#{keg}" 2>/dev/null`.split("\n") - keg_ref_files.map! { |file| Pathname.new(file) }.reject!(&:symlink?) + result = false + index = 0 - # If files are hardlinked, only check one of them - keg_ref_files = uniq_by_ino(keg_ref_files) + keg.each_unique_file_matching(string) do |file| + opoo "String '#{string}' still exists in these files:" if index.zero? - # If there are no files with that string found, return immediately - return false if keg_ref_files.empty? - - # Start printing out each file and any extra information we can find - opoo "String '#{string}' still exists in these files:" - keg_ref_files.each do |file| puts "#{Tty.red}#{file}#{Tty.reset}" # Check dynamic library linkage. Importantly, do not run otool on static @@ -97,9 +81,12 @@ module Homebrew extend self puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}" end end + + index += 1 + result = true end - puts - true + + result end def bottle_output bottle @@ -162,6 +149,7 @@ module Homebrew extend self relocatable = !keg_contains(prefix_check, keg) relocatable = !keg_contains(HOMEBREW_CELLAR, keg) && relocatable + puts unless relocatable rescue Interrupt ignore_interrupts { bottle_path.unlink if bottle_path.exist? } raise diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index 2b97603799..4ef5438385 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -78,6 +78,18 @@ class Keg results.to_a end + def each_unique_file_matching string + IO.popen("/usr/bin/fgrep -lr '#{string}' '#{self}' 2>/dev/null") do |io| + hardlinks = Set.new + + until io.eof? + file = Pathname.new(io.readline.chomp) + next if file.symlink? + yield file if hardlinks.add? file.stat.ino + end + end + end + private def install_name_tool(*args)