Skip to content

Commit e6ccc8d

Browse files
committed
Find shortest filename in dylib symlink collection
1 parent ba7f240 commit e6ccc8d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

share/brewkit/fix-machos.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,21 @@ def fix_install_names
186186
return if bad_names.empty?
187187

188188
def fix_tea_prefix s
189-
s = Pathname.new(s).relative_path_from(Pathname.new($tea_prefix))
189+
s = Pathname.new(s)
190+
s = s.realpath if s.symlink?
191+
192+
shortest = nil
193+
s.parent.each_child do |file|
194+
file = s.dirname.join(file)
195+
if file.symlink? and file.realpath == s and (shortest.nil? or file.basename.to_s.length < shortest.basename.to_s.length)
196+
shortest = file
197+
end
198+
end
199+
200+
s = shortest if shortest # if not then just try anyway
201+
202+
s = s.relative_path_from(Pathname.new($tea_prefix))
190203
s = s.sub(%r{/v(\d+)\.(\d+\.)+\d+[a-z]?/}, '/v\1/')
191-
s = s.sub(%r{[-.]\d+(\.\d+)*\.dylib$}, '.dylib')
192204

193205
abort "#{s} doesn’t exist!" unless File.exist?(File.join($tea_prefix, s))
194206

0 commit comments

Comments
 (0)