Relocate libtool (.la) files as well as pkgconfig (.pc)

Ignore quotes, just do a global substitution on cellar and prefix.

Closes Homebrew/homebrew#24894.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Elliot Saba 2013-12-04 22:37:58 -06:00 committed by Jack Nagel
parent 0daa33668b
commit 3d76a2c8df

View File

@ -40,13 +40,13 @@ class Keg
end
end
pkgconfig_files.each do |pcfile|
pcfile.ensure_writable do
pcfile.open('rb') do |f|
(pkgconfig_files | libtool_files).each do |file|
file.ensure_writable do
file.open('rb') do |f|
s = f.read
replace_pkgconfig_file_path(s, old_cellar, new_cellar)
replace_pkgconfig_file_path(s, old_prefix, new_prefix)
f.reopen(pcfile, 'wb')
s.gsub!(old_cellar, new_cellar)
s.gsub!(old_prefix, new_prefix)
f.reopen(file, 'wb')
f.write(s)
end
end
@ -61,17 +61,6 @@ class Keg
install_name_tool("-change", old, new, file)
end
# Given old == "/usr/local/Cellar" and new == "/opt/homebrew/Cellar",
# then update lines of the form
# some_variable=/usr/local/Cellar/foo/1.0/lib
# to
# some_variable="/opt/homebrew/Cellar/foo/1.0/lib"
# and add quotes to protect against paths containing spaces.
def replace_pkgconfig_file_path(s, old, new)
return if old == new
s.gsub!(%r[([\S]+)="?#{Regexp.escape(old)}(.*?)"?$], "\\1=\"#{new}\\2\"")
end
# Detects the C++ dynamic libraries in place, scanning the dynamic links
# of the files within the keg. This searches only libs contained within
# lib/, and ignores binaries and other mach-o objects
@ -198,4 +187,16 @@ class Keg
end
pkgconfig_files
end
def libtool_files
libtool_files = []
# find .la files, which are stored in lib/
la_dir = self/'lib'
la_dir.find do |pn|
next if pn.symlink? or pn.directory? or pn.extname.to_s != '.la'
libtool_files << pn
end
libtool_files
end
end