mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
update opt for renamed formula
After the formula gets renamed oldname opt is created and it points to the linked keg. However if we then upgrade newname oldname opt still points to the same keg it pointed before upgrade. The commit fixes this behaviour thus that oldname opt links at the same keg opt point.
This commit is contained in:
parent
9025719968
commit
d3037f7044
@ -18,15 +18,9 @@ module Homebrew
|
|||||||
# Remove every symlink that links to keg, because it can
|
# Remove every symlink that links to keg, because it can
|
||||||
# be left by migrator
|
# be left by migrator
|
||||||
links.each do |link|
|
links.each do |link|
|
||||||
old_opt = HOMEBREW_PREFIX/"opt/#{link.basename}"
|
|
||||||
if link.exist? && link.realpath == keg.rack.realpath
|
if link.exist? && link.realpath == keg.rack.realpath
|
||||||
old_cellars << link
|
old_cellars << link
|
||||||
end
|
end
|
||||||
|
|
||||||
if old_opt.symlink? && old_opt.realpath.to_s == keg.to_s
|
|
||||||
old_opt.unlink
|
|
||||||
old_opt.parent.rmdir_if_possible
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
keg.unlink
|
keg.unlink
|
||||||
@ -52,13 +46,6 @@ module Homebrew
|
|||||||
name = rack.basename
|
name = rack.basename
|
||||||
|
|
||||||
links.each do |link|
|
links.each do |link|
|
||||||
old_opt = HOMEBREW_PREFIX/"opt/#{link.basename}"
|
|
||||||
if old_opt.symlink? && old_opt.exist? \
|
|
||||||
&& old_opt.realpath.parent == rack.realpath
|
|
||||||
old_opt.unlink
|
|
||||||
old_opt.parent.rmdir_if_possible
|
|
||||||
end
|
|
||||||
|
|
||||||
link.unlink if link.exist? && link.realpath == rack.realpath
|
link.unlink if link.exist? && link.realpath == rack.realpath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -183,6 +183,7 @@ class Keg
|
|||||||
path.rmtree
|
path.rmtree
|
||||||
path.parent.rmdir_if_possible
|
path.parent.rmdir_if_possible
|
||||||
remove_opt_record if optlinked?
|
remove_opt_record if optlinked?
|
||||||
|
remove_oldname_opt_record
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink
|
def unlink
|
||||||
@ -256,6 +257,14 @@ class Keg
|
|||||||
path.find(*args, &block)
|
path.find(*args, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def oldname_opt_record
|
||||||
|
@oldname_opt_record ||= if (opt_dir = HOMEBREW_PREFIX/"opt").directory?
|
||||||
|
opt_dir.subdirs.detect do |dir|
|
||||||
|
dir.symlink? && dir != opt_record && path.parent == dir.resolved_path.parent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def link(mode = OpenStruct.new)
|
def link(mode = OpenStruct.new)
|
||||||
raise AlreadyLinkedError.new(self) if linked_keg_record.directory?
|
raise AlreadyLinkedError.new(self) if linked_keg_record.directory?
|
||||||
|
|
||||||
@ -330,9 +339,22 @@ class Keg
|
|||||||
ObserverPathnameExtension.total
|
ObserverPathnameExtension.total
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_oldname_opt_record
|
||||||
|
return unless oldname_opt_record
|
||||||
|
return unless oldname_opt_record.resolved_path == path
|
||||||
|
@oldname_opt_record.unlink
|
||||||
|
@oldname_opt_record.parent.rmdir_if_possible
|
||||||
|
@oldname_opt_record = nil
|
||||||
|
end
|
||||||
|
|
||||||
def optlink(mode = OpenStruct.new)
|
def optlink(mode = OpenStruct.new)
|
||||||
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
opt_record.delete if opt_record.symlink? || opt_record.exist?
|
||||||
make_relative_symlink(opt_record, path, mode)
|
make_relative_symlink(opt_record, path, mode)
|
||||||
|
|
||||||
|
if oldname_opt_record
|
||||||
|
oldname_opt_record.delete
|
||||||
|
make_relative_symlink(oldname_opt_record, path, mode)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_pyc_files!
|
def delete_pyc_files!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user