Skip to content

Commit

Permalink
Yeet.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Sep 3, 2024
1 parent 42d2a73 commit 9d5b2da
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions brew-pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 9d5b2da

Please sign in to comment.