Class: ELFShim::Metadata

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/os/linux/elf.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Metadata

Returns a new instance of Metadata



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'brew/Library/Homebrew/os/linux/elf.rb', line 86

def initialize(path)
  @path = path
  @dylibs = []
  @dylib_id, needed = needed_libraries path
  return if needed.empty?

  ldd = DevelopmentTools.locate "ldd"
  ldd_output = Utils.popen_read(ldd, path.expand_path.to_s).split("\n")
  return unless $CHILD_STATUS.success?

  ldd_paths = ldd_output.map do |line|
    match = line.match(/\t.+ => (.+) \(.+\)|\t(.+) => not found/)
    next unless match

    match.captures.compact.first
  end.compact
  @dylibs = ldd_paths.select do |ldd_path|
    next true unless ldd_path.start_with? "/"

    needed.include? File.basename(ldd_path)
  end
end

Instance Attribute Details

#dylib_idObject (readonly)

Returns the value of attribute dylib_id



84
85
86
# File 'brew/Library/Homebrew/os/linux/elf.rb', line 84

def dylib_id
  @dylib_id
end

#dylibsObject (readonly)

Returns the value of attribute dylibs



84
85
86
# File 'brew/Library/Homebrew/os/linux/elf.rb', line 84

def dylibs
  @dylibs
end

#pathObject (readonly)

Returns the value of attribute path



84
85
86
# File 'brew/Library/Homebrew/os/linux/elf.rb', line 84

def path
  @path
end