75 lines
1.9 KiB
Ruby
Raw Normal View History

# typed: strict
# frozen_string_literal: true
class Keg
sig { params(path: Pathname).void }
def initialize(path)
super
@require_relocation = T.let(false, T::Boolean)
end
sig { params(id: String, file: Pathname).returns(T::Boolean) }
def change_dylib_id(id, file)
return false if file.dylib_id == id
2018-09-17 02:45:00 +02:00
@require_relocation = true
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
file.change_dylib_id(id, strict: false)
true
rescue MachO::MachOError
2017-10-15 02:28:32 +02:00
onoe <<~EOS
Failed changing dylib ID of #{file}
from #{file.dylib_id}
to #{id}
EOS
raise
end
sig { params(old: String, new: String, file: Pathname).returns(T::Boolean) }
def change_install_name(old, new, file)
return false if old == new
2018-09-17 02:45:00 +02:00
@require_relocation = true
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
file.change_install_name(old, new, strict: false)
true
rescue MachO::MachOError
2017-10-15 02:28:32 +02:00
onoe <<~EOS
Failed changing install name in #{file}
from #{old}
to #{new}
EOS
raise
end
2020-11-10 23:52:33 +01:00
sig { params(old: String, new: String, file: Pathname).returns(T::Boolean) }
2021-05-05 21:37:02 +01:00
def change_rpath(old, new, file)
return false if old == new
2021-05-05 21:37:02 +01:00
@require_relocation = true
2021-05-05 21:37:02 +01:00
odebug "Changing rpath in #{file}\n from #{old}\n to #{new}"
file.change_rpath(old, new, strict: false)
true
2021-05-05 21:37:02 +01:00
rescue MachO::MachOError
onoe <<~EOS
Failed changing rpath in #{file}
from #{old}
to #{new}
EOS
raise
end
sig { params(rpath: String, file: MachOShim).returns(T::Boolean) }
def delete_rpath(rpath, file)
odebug "Deleting rpath #{rpath} in #{file}"
file.delete_rpath(rpath, strict: false)
true
rescue MachO::MachOError
onoe <<~EOS
Failed deleting rpath #{rpath} in #{file}
EOS
raise
end
end