diff --git a/brew-pkg.rb b/brew-pkg.rb index 80d65e8..5356ced 100755 --- a/brew-pkg.rb +++ b/brew-pkg.rb @@ -46,19 +46,16 @@ def patchelf(root_dir, prefix_path, binary, format='@executable_path') next end - # If the library is linked to itself, skip the recursive call to patchelf - self_referencing = false - # Define new library relative path if lib_path == binary_path opoo "The link '#{File.join(root_dir, lib)}' refers to itself: '#{binary_path}'" - # Skip recursive call - self_referencing = true - # Obtain the relative path from the library relative_path = Pathname.new(lib).relative_path_from(Pathname.new(File.dirname(File.join(prefix_path, binary)))) else + # Recursively iterate through libraries + patchelf(root_dir, prefix_path, lib.delete_prefix(prefix_path), '@loader_path') + # Obtain the relative path from the executable lib_relative_path = lib_path.delete_prefix(full_prefix_path) binary_relative_path = File.dirname(binary_path).delete_prefix(full_prefix_path) @@ -76,11 +73,6 @@ def patchelf(root_dir, prefix_path, binary, format='@executable_path') ohai "After patching:" ohai "#{stdout}" ohai "patchelf(#{root_dir}, #{prefix_path}, #{lib.delete_prefix(prefix_path)})" - - # Recursively iterate through libraries - unless self_referencing - patchelf(root_dir, prefix_path, lib.delete_prefix(prefix_path), '@loader_path') - end end end