Class: Cleaner Private

Inherits:
Object show all
Includes:
Context, OS::Mac::Cleaner
Defined in:
extend/os/linux/cleaner.rb,
cleaner.rb

Overview

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

Cleans a newly installed keg. By default:

  • removes .la files
  • removes .tbd files
  • removes perllocal.pod files
  • removes .packlist files
  • removes empty directories
  • sets permissions on executables
  • removes unresolved symlinks

Instance Method Summary collapse

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(formula) ⇒ void

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.

Create a cleaner for the given formula.

Parameters:



19
20
21
# File 'cleaner.rb', line 19

def initialize(formula)
  @formula = formula
end

Instance Method Details

#cleanvoid

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.

Clean the keg of the formula.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'cleaner.rb', line 25

def clean
  ObserverPathnameExtension.reset_counts!

  # Many formulae include `lib/charset.alias`, but it is not strictly needed
  # and will conflict if more than one formula provides it.
  observe_file_removal @formula.lib/"charset.alias"

  [@formula.bin, @formula.sbin, @formula.lib].each { |dir| clean_dir(dir) if dir.exist? }

  # Get rid of any info `dir` files, so they don't conflict at the link stage.
  #
  # The `dir` files come in at least 3 locations:
  #
  # 1. `info/dir`
  # 2. `info/#{name}/dir`
  # 3. `info/#{arch}/dir`
  #
  # Of these 3 only `info/#{name}/dir` is safe to keep since the rest will
  # conflict with other formulae because they use a shared location.
  #
  # See
  # [cleaner: recursively delete info `dir`s][1],
  # [emacs 28.1 bottle does not contain `dir` file][2] and
  # [Keep `info/#{f.name}/dir` files in cleaner][3]
  # for more info.
  #
  # [1]: https://github.com/Homebrew/brew/pull/11597
  # [2]: https://github.com/Homebrew/homebrew-core/issues/100190
  # [3]: https://github.com/Homebrew/brew/pull/13215
  @formula.info.glob("**/dir").each do |info_dir_file|
    next unless info_dir_file.file?
    next if info_dir_file == @formula.info/@formula.name/"dir"
    next if @formula.skip_clean?(info_dir_file)

    observe_file_removal info_dir_file
  end

  rewrite_shebangs
  

  prune
end