Merge pull request #10327 from MikeMcQuaid/keg-fix-alias-handling
Keg: fix alias and versioned symlink handling.
This commit is contained in:
commit
e989a0fb01
@ -301,28 +301,16 @@ class Keg
|
||||
# versioned aliases are handled below
|
||||
next if a.match?(/.+@./)
|
||||
|
||||
alias_opt_symlink = opt/a
|
||||
if alias_opt_symlink.symlink? && alias_opt_symlink.exist?
|
||||
alias_opt_symlink.delete if alias_opt_symlink.realpath == opt_record.realpath
|
||||
elsif alias_opt_symlink.symlink? || alias_opt_symlink.exist?
|
||||
alias_opt_symlink.delete
|
||||
end
|
||||
|
||||
alias_linkedkegs_symlink = linkedkegs/a
|
||||
alias_linkedkegs_symlink.delete if alias_linkedkegs_symlink.symlink? || alias_linkedkegs_symlink.exist?
|
||||
remove_alias_symlink(opt/a, opt_record)
|
||||
remove_alias_symlink(linkedkegs/a, linked_keg_record)
|
||||
end
|
||||
|
||||
Pathname.glob("#{opt_record}@*").each do |a|
|
||||
a = a.basename.to_s
|
||||
next if aliases.include?(a)
|
||||
|
||||
alias_opt_symlink = opt/a
|
||||
if alias_opt_symlink.symlink? && alias_opt_symlink.exist? && rack == alias_opt_symlink.realpath.parent
|
||||
alias_opt_symlink.delete
|
||||
end
|
||||
|
||||
alias_linkedkegs_symlink = linkedkegs/a
|
||||
alias_linkedkegs_symlink.delete if alias_linkedkegs_symlink.symlink? || alias_linkedkegs_symlink.exist?
|
||||
remove_alias_symlink(opt/a, rack)
|
||||
remove_alias_symlink(linkedkegs/a, rack)
|
||||
end
|
||||
end
|
||||
|
||||
@ -341,6 +329,7 @@ class Keg
|
||||
path.rmtree
|
||||
path.parent.rmdir_if_possible
|
||||
remove_opt_record if optlinked?
|
||||
remove_linked_keg_record if linked?
|
||||
remove_old_aliases
|
||||
remove_oldname_opt_record
|
||||
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||
@ -377,12 +366,12 @@ class Keg
|
||||
|
||||
dst.uninstall_info if dst.to_s.match?(INFOFILE_RX)
|
||||
dst.unlink
|
||||
remove_old_aliases
|
||||
Find.prune if src.directory?
|
||||
end
|
||||
end
|
||||
|
||||
unless options[:dry_run]
|
||||
remove_old_aliases
|
||||
remove_linked_keg_record if linked?
|
||||
dirs.reverse_each(&:rmdir_if_possible)
|
||||
end
|
||||
@ -659,6 +648,14 @@ class Keg
|
||||
raise LinkError.new(self, src.relative_path_from(path), dst, e)
|
||||
end
|
||||
|
||||
def remove_alias_symlink(alias_symlink, alias_match_path)
|
||||
if alias_symlink.symlink? && alias_symlink.exist?
|
||||
alias_symlink.delete if alias_symlink.realpath == alias_match_path.realpath
|
||||
elsif alias_symlink.symlink? || alias_symlink.exist?
|
||||
alias_symlink.delete
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# symlinks the contents of path+relative_dir recursively into #{HOMEBREW_PREFIX}/relative_dir
|
||||
|
||||
@ -58,7 +58,12 @@ class Tab < OpenStruct
|
||||
# Returns the {Tab} for an install receipt at `path`.
|
||||
# Results are cached.
|
||||
def self.from_file(path)
|
||||
cache.fetch(path) { |p| cache[p] = from_file_content(File.read(p), p) }
|
||||
cache.fetch(path) do |p|
|
||||
content = File.read(p)
|
||||
return empty if content.blank?
|
||||
|
||||
cache[p] = from_file_content(content, p)
|
||||
end
|
||||
end
|
||||
|
||||
# Like {from_file}, but bypass the cache.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user