Keg#link: run optlink first

This prevents a link conflict during `brew upgrade` causing opt link
stuck to old version. At this point, users will have to run `brew switch`
to fix it.

Closes #533.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2016-07-17 01:59:54 +08:00
parent 177d988917
commit 1eaa95b805
No known key found for this signature in database
GPG Key ID: C2A3860FA0B459CE

View File

@ -304,6 +304,8 @@ class Keg
ObserverPathnameExtension.reset_counts!
optlink(mode) unless mode.dry_run
# yeah indeed, you have to force anything you need in the main tree into
# these dirs REMEMBER that *NOT* everything needs to be in the main tree
link_dir("etc", mode) { :mkpath }
@ -366,10 +368,7 @@ class Keg
end
end
unless mode.dry_run
make_relative_symlink(linked_keg_record, path, mode)
optlink(mode)
end
make_relative_symlink(linked_keg_record, path, mode) unless mode.dry_run
rescue LinkError
unlink
raise