diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bae2e3314f..0c19805a3d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -553,6 +553,28 @@ class Formula Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}") end + # Is the formula linked? + def linked? + linked_keg.symlink? + end + + # Is the formula linked to opt? + def optlinked? + opt_prefix.symlink? + end + + # Is formula's linked keg points to the prefix. + def prefix_linked?(v = pkg_version) + return false unless linked? + linked_keg.resolved_path == prefix(v) + end + + # {PkgVersion} of the linked keg for the formula. + def linked_version + return unless linked? + Keg.for(linked_keg).version + end + # The parent of the prefix; the named directory in the cellar containing all # installed versions of this software # @private