diff options
| author | Mike McQuaid | 2016-09-17 18:50:25 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-09-17 18:50:25 +0100 |
| commit | 241d7b991bd9e830748e35f81b8738e1b069e43d (patch) | |
| tree | 1bd84960be95d6d7e49784b8e8acda0d38b1f2cb /Library | |
| parent | 299dffd903182bd4ab65828ae2347d415de7b259 (diff) | |
| download | brew-241d7b991bd9e830748e35f81b8738e1b069e43d.tar.bz2 | |
Improve legacy symlink migration.
Read the old symlinks and migrate them across rather than assuming a
unlink/link will work fine (as users have conflicts.)
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/utils.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index b3520a7ec..0c36da2e1 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -625,22 +625,30 @@ def migrate_legacy_keg_symlinks_if_necessary legacy_linked_kegs = HOMEBREW_LIBRARY/"LinkedKegs" return unless legacy_linked_kegs.directory? - legacy_linked_kegs.children.each do |f| - keg = Keg.new(f.realpath) - keg.unlink - keg.link + legacy_linked_kegs.children.each do |link| + name = link.basename + src = begin + link.realpath + rescue Errno::ENOENT + begin + (HOMEBREW_PREFIX/"opt/#{name}").realpath + rescue Errno::ENOENT + Formulary.factory(name).installed_prefix + end + end + dst = HOMEBREW_LINKED_KEGS/name + FileUtils.ln_sf(src.relative_path_from(dst.parent), dst) end FileUtils.rm_rf legacy_linked_kegs legacy_pinned_kegs = HOMEBREW_LIBRARY/"PinnedKegs" return unless legacy_pinned_kegs.directory? - legacy_pinned_kegs.children.each do |f| - pin_version = Keg.new(f.realpath).version - formula = Formulary.factory(f.basename.to_s) - pin = FormulaPin.new(formula) - pin.unpin - pin.pin_at(pin_version) + legacy_pinned_kegs.children.each do |link| + name = link.basename + src = link.realpath + dst = HOMEBREW_PINNED_KEGS/name + FileUtils.ln_sf(src.relative_path_from(dst.parent), dst) end FileUtils.rm_rf legacy_pinned_kegs end |
