Skip to content

Commit 6f3f56e

Browse files
committed
Fix eg. @rpath/libfoo.dylib
grpc.io has these, but we didn’t see it because LD_LIBRARY_PATH was set. The reason I saw it is because LD_LIBRARY_PATH is un-exported to children. So an easy test is to run grpc inside a Makefile for instance.
1 parent 6485735 commit 6f3f56e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

share/brewkit/fix-machos.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,15 @@ def bad_install_names
165165
if path.exist?
166166
lib
167167
else
168-
puts "warn:#{@file.filename}:#{lib}"
168+
file = Pathname.new($pkg_prefix).join('lib', lib.sub(%r{^@rpath/}, ''))
169+
if file.exist?
170+
lib
171+
else
172+
puts "::warning file=#{@file.filename} ::skipping #{lib}"
173+
end
169174
end
170175
elsif lib.start_with? '@'
171-
puts "warn:#{@file.filename}:#{lib}"
176+
puts "::warning file=#{@file.filename} ::skipping #{lib}"
172177
# noop
173178
else
174179
lib
@@ -213,8 +218,15 @@ def fix_pkgx_prefix s
213218
elsif old_name.start_with? '/'
214219
new_name = fix_pkgx_prefix old_name
215220
elsif old_name.start_with? '@rpath'
216-
# so far we only feed bad @rpaths that are relative to the pkgx-prefix
217-
new_name = fix_pkgx_prefix old_name.sub(%r{^@rpath}, $PKGX_DIR)
221+
# this code is now awful, we check in bad_install_names for this conditional and then cannot communicate that to here
222+
# a package we needed this for was grpc.io
223+
libname = old_name.sub(%r{^@rpath/}, '')
224+
if Pathname.new($pkg_prefix).join('lib', libname).exist?
225+
new_name = Pathname.new($pkg_prefix).join("lib").relative_path_from(Pathname.new(@file.filename).parent)
226+
new_name = "@loader_path/#{new_name}/#{libname}"
227+
else
228+
new_name = fix_pkgx_prefix old_name.sub(%r{^@rpath}, $PKGX_DIR)
229+
end
218230
else
219231
# assume they are meant to be relative to lib dir
220232
new_name = Pathname.new($pkg_prefix).join("lib").relative_path_from(Pathname.new(@file.filename).parent)

0 commit comments

Comments
 (0)