From 5241932b45d8d0897cb1af0f9c6dccf6c2250d29 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Fri, 11 Sep 2015 16:32:14 +0800 Subject: [PATCH] keg_relocate: fix absolute symlink --- Library/Homebrew/keg_relocate.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index f0d6abefed..963f219ba8 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -16,6 +16,15 @@ class Keg end end end + + symlink_files.each do |file| + link = file.readlink + # Don't fix relative symlinks + next unless link.absolute? + if link.to_s.start_with?(HOMEBREW_CELLAR.to_s) || link.to_s.start_with?(HOMEBREW_PREFIX.to_s) + FileUtils.ln_sf(link.relative_path_from(file.parent), file) + end + end end def relocate_install_names(old_prefix, new_prefix, old_cellar, new_cellar, options = {}) @@ -184,4 +193,13 @@ class Keg end if lib.directory? libtool_files end + + def symlink_files + symlink_files = [] + path.find do |pn| + symlink_files << pn if pn.symlink? + end + + symlink_files + end end