aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/keg_relocate.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 11699433f..0490b05c6 100644
--- a/Library/Homebrew/keg_relocate.rb
+++ b/Library/Homebrew/keg_relocate.rb
@@ -130,7 +130,7 @@ class Keg
"@loader_path/#{bad_name}"
elsif file.mach_o_executable? && (lib + bad_name).exist?
"#{lib}/#{bad_name}"
- elsif (abs_name = find_dylib(Pathname.new(bad_name).basename)) && abs_name.exist?
+ elsif (abs_name = find_dylib(bad_name)) && abs_name.exist?
abs_name.to_s
else
opoo "Could not fix #{bad_name} in #{file}"
@@ -156,8 +156,22 @@ class Keg
opt_record.join(relative_dirname, basename).to_s
end
- def find_dylib(name)
- lib.find { |pn| break pn if pn.basename == name } if lib.directory?
+ # Matches framework references like `XXX.framework/Versions/YYY/XXX` and
+ # `XXX.framework/XXX`, both with or without a slash-delimited prefix.
+ FRAMEWORK_RX = %r{(?:^|/)(([^/]+)\.framework/(?:Versions/[^/]+/)?\2)$}.freeze
+
+ def find_dylib_suffix_from(bad_name)
+ if (framework = bad_name.match(FRAMEWORK_RX))
+ framework[1]
+ else
+ File.basename(bad_name)
+ end
+ end
+
+ def find_dylib(bad_name)
+ return unless lib.directory?
+ suffix = "/#{find_dylib_suffix_from(bad_name)}"
+ lib.find { |pn| break pn if pn.to_s.end_with?(suffix) }
end
def mach_o_files