aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorJack Nagel2013-12-17 20:46:42 -0600
committerJack Nagel2013-12-17 21:13:23 -0600
commit4c7cbdff73423ae0cba308009bcb05a1d1ecc63d (patch)
treebd732392b4684275d17ca5137180d3a5f5b6a986 /Library/Homebrew/cmd
parent917706e2913e5aad9974abbe2c10e7f9d31be00c (diff)
downloadhomebrew-4c7cbdff73423ae0cba308009bcb05a1d1ecc63d.tar.bz2
bottle: extract method for enumerating files that match a string
This brings a (small) performance improvement as we yield the files as they are output by fgrep rather than waiting until fgrep is done to do any work.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/bottle.rb32
1 files changed, 10 insertions, 22 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 733734adb..7e44b606b 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