From f4618f014741698550c4c61b82ae4fc6c96fc824 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 14 Dec 2013 09:35:57 -0600 Subject: [PATCH] keg: factor out dylib id calculation --- Library/Homebrew/keg_fix_install_names.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index 1eb2e5737b..0b17547c73 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -127,23 +127,26 @@ class Keg install_names.shift # first line is fluff install_names.map!{ |s| OTOOL_RX =~ s && $1 } - # Bundles and executables do not have an ID - id = install_names.shift if file.dylib? + # For dylibs, the next line is the ID + install_names.shift if file.dylib? install_names.compact! install_names.reject!{ |fn| fn =~ /^@(loader_|executable_|r)path/ } install_names.reject!{ |fn| reject_proc.call(fn) } + yield dylib_id_for(file, options), install_names + end + + def dylib_id_for file, options={} # the shortpath ensures that library upgrades don’t break installed tools relative_path = Pathname.new(file).relative_path_from(self) shortpath = HOMEBREW_PREFIX.join(relative_path) - id = if shortpath.exist? and not options[:keg_only] + + if shortpath.exist? and not options[:keg_only] shortpath else "#{HOMEBREW_PREFIX}/opt/#{fname}/#{relative_path}" end - - yield id, install_names end def find_dylib name