forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keg.rb
75 lines (67 loc) 路 1.84 KB
/
keg.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# typed: true
# frozen_string_literal: true
class Keg
def change_dylib_id(id, file)
return if file.dylib_id == id
@require_relocation = true
odebug "Changing dylib ID of #{file}\n from #{file.dylib_id}\n to #{id}"
file.change_dylib_id(id, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing dylib ID of #{file}
from #{file.dylib_id}
to #{id}
EOS
raise
end
def change_install_name(old, new, file)
return if old == new
@require_relocation = true
odebug "Changing install name in #{file}\n from #{old}\n to #{new}"
file.change_install_name(old, new, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing install name in #{file}
from #{old}
to #{new}
EOS
raise
end
def change_rpath(old, new, file)
return if old == new
@require_relocation = true
odebug "Changing rpath in #{file}\n from #{old}\n to #{new}"
file.change_rpath(old, new, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed changing rpath in #{file}
from #{old}
to #{new}
EOS
raise
end
def add_rpath(rpath, file)
@require_relocation = rpath.start_with?(HOMEBREW_PREFIX.to_s)
odebug "Adding rpath #{rpath} in #{file}"
file.add_rpath(rpath, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed adding rpath #{rpath} in #{file}
EOS
raise
end
def delete_rpath(rpath, file)
odebug "Deleting rpath #{rpath} in #{file}"
file.delete_rpath(rpath, strict: false)
codesign_patched_binary(file)
rescue MachO::MachOError
onoe <<~EOS
Failed deleting rpath #{rpath} in #{file}
EOS
raise
end
end