Skip to content

Commit

Permalink
Dg.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 30, 2024
1 parent 1596e96 commit f2067a6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions brew-pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@

module Homebrew extend self
def elf_file?(file_path)
ohai "1 ELF? " + file_path

# Check if the file exists
return false unless File.exist?(file_path)

ohai "2 ELF? " + file_path

File.open(file_path, "rb") do |file|
# Read the first 4 bytes
header = file.read(4)

ohai "3 ELF? #{header == "\x7FELF"}"

# Check for ELF format
return header == "\x7FELF"
end
end

def patchelf(root_dir, prefix_path, binary)
ohai "1) AAAAAAAAAAAAAAAAAAAAAA"

# Get the full binary path and check if it's a valid ELF
binary_path = File.join(root_dir, prefix_path, binary)
return unless elf_file?(binary_path)

ohai "2) AAAAAAAAAAAAAAAAAAAAAA #{binary_path}"
# TODO:
# return unless elf_file?(binary_path)
return unless File.exist?(binary_path)

# Get the list of linked libraries with otool
stdout, status = Open3.capture2("otool -L #{binary_path}")
Expand Down

0 comments on commit f2067a6

Please sign in to comment.