diff options
| author | Elliot Saba | 2013-10-31 01:08:57 -0700 |
|---|---|---|
| committer | Jack Nagel | 2013-11-13 18:49:16 -0600 |
| commit | 0ece9135eb1b714d4348bdc052cf3a212177632e (patch) | |
| tree | 5fe9d70dda1a2d16ca5b63c661547775e654296c /Library | |
| parent | 2fb5ead38a7632ff6f941909474767883a9e0252 (diff) | |
| download | brew-0ece9135eb1b714d4348bdc052cf3a212177632e.tar.bz2 | |
Add support for relocating pkgconfig files for bottles
* Finds pkg-config files such as "lib/pkgconfig/libfoo.pc" and "bin/libfoo-config"
* Does inreplace on paths in such files to allow for better bottle relocation ability
Closes Homebrew/homebrew#23825.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/keg_fix_install_names.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Library/Homebrew/keg_fix_install_names.rb b/Library/Homebrew/keg_fix_install_names.rb index 9210e70e3..bff97842c 100644 --- a/Library/Homebrew/keg_fix_install_names.rb +++ b/Library/Homebrew/keg_fix_install_names.rb @@ -39,6 +39,28 @@ class Keg end end end + + # Search for pkgconfig .pc files and relocate references to the cellar + old_cellar = HOMEBREW_CELLAR if old_cellar == :any + old_prefix = HOMEBREW_PREFIX if old_prefix == :any + + old_cellar = Regexp.escape(old_cellar) + old_prefix = Regexp.escape(old_prefix) + + pkgconfig_files.each do |pcfile| + pcfile.ensure_writable do + pcfile.open('rb') do |f| + s = f.read + # These regexes match lines of the form: prefix=/usr/local/Cellar/foo/1.2.3/lib + # and (assuming new_cellar is "/tmp") transform them into: prefix="/tmp/foo/1.2.3/lib" + # If the original line did not have quotes, we add them in automatically + s.gsub!(%r[([\S]+)="?#{old_cellar}(.*?)"?$], "\\1=\"#{new_cellar}\\2\"") + s.gsub!(%r[([\S]+)="?#{old_prefix}(.*?)"?$], "\\1=\"#{new_prefix}\\2\"") + f.reopen(pcfile, 'wb') + f.write(s) + end + end + end end # Detects the C++ dynamic libraries in place, scanning the dynamic links @@ -143,4 +165,24 @@ class Keg mach_o_files end + + def pkgconfig_files + pkgconfig_files = [] + + # find .pc files, which are stored in lib/pkgconfig + pc_dir = self/'lib/pkgconfig' + if pc_dir.directory? + pc_dir.find do |pn| + next if pn.symlink? or pn.directory? or pn.extname.to_s != '.pc' + pkgconfig_files << pn + end + end + + # find name-config scripts, which can be all over the keg + Pathname.new(self).find do |pn| + next if pn.symlink? or pn.directory? + pkgconfig_files << pn if pn.text_executable? and pn.basename.to_s.end_with? '-config' + end + pkgconfig_files + end end |
