Module: Homebrew::Unlink Private

Defined in:
unlink.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Provides helper methods for unlinking formulae and kegs with consistent output.

Class Method Summary collapse

Class Method Details

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • keg (Keg)
  • dry_run (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • lock (Boolean) (defaults to: true)


21
22
23
24
25
26
27
# File 'unlink.rb', line 21

def self.unlink(keg, dry_run: false, verbose: false, lock: true)
  return keg.lock { unlink(keg, dry_run:, verbose:, lock: false) } if lock

  print "Unlinking #{keg}... "
  puts if verbose
  puts "#{keg.unlink(dry_run:, verbose:)} symlinks removed."
end

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • formula (Formula)
  • locked_formulae (Array<Formula>) (defaults to: [])
  • verbose (Boolean) (defaults to: false)


8
9
10
11
12
13
14
15
16
17
18
# File 'unlink.rb', line 8

def self.unlink_link_overwrite_formulae(formula, locked_formulae: [], verbose: false)
  overwrite_formulae = formula.link_overwrite_formulae.select(&:linked?)
  overwrite_formulae.select!(&:keg_only?) unless formula.keg_only?

  overwrite_formulae.filter_map(&:any_installed_keg)
                    .select(&:directory?)
                    .each do |keg|
    lock = locked_formulae.none? { |locked_formula| locked_formula.name == keg.name }
    unlink(keg, verbose:, lock:)
  end
end