Skip to content

Commit 76996a1

Browse files
committed
Fix rpath fixing (again)
Also fixes any rpaths the tool sets itself to be relative to loader_path
1 parent 51506b0 commit 76996a1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

share/brewkit/fix-machos.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ def fix_rpaths
132132
rel_path = Pathname.new($tea_prefix).relative_path_from(Pathname.new(@file.filename).parent)
133133
rpath = "@loader_path/#{rel_path}"
134134

135+
# rewrite any rpaths the tool itself set to be relative
136+
@file.rpaths.each do |rpath|
137+
if rpath.start_with? $tea_prefix
138+
diff = Pathname.new(rpath).relative_path_from(Pathname.new(@file.filename).parent)
139+
@file.change_rpath rpath, "@loader_path/#{diff}"
140+
dirty = true
141+
end
142+
end
143+
135144
if not @file.rpaths.include? rpath and links_to_other_tea_libs?
136145
@file.add_rpath rpath
137146
dirty = true
@@ -174,12 +183,12 @@ def fix_install_names
174183
def fix_tea_prefix s
175184
s = Pathname.new(s).relative_path_from(Pathname.new($tea_prefix))
176185
s = s.sub(%r{/v(\d+)\.(\d+\.)+\d+[a-z]?/}, '/v\1/')
186+
s = s.sub(%r{[-.]\d+(\.\d+)*\.dylib$}, '.dylib')
177187

178-
#FIXME we need to figure this out by resolving links and shit
179-
ss = s.sub(%r{[-.]\d+(\.\d+)*\.dylib$}, '.dylib')
180-
s = ss if File.exist? ss
188+
abort "#{s} doesn’t exist!" unless File.exist?(File.join($tea_prefix, s))
181189

182190
s = "@rpath/#{s}"
191+
183192
return s
184193
end
185194

0 commit comments

Comments
 (0)