Skip to content

Commit

Permalink
Revert "PoC: Use a factory rather than dynamically redefine methods"
Browse files Browse the repository at this point in the history
This reverts commit c4f9e5e.
  • Loading branch information
dduugg committed Aug 15, 2024
1 parent c4f9e5e commit a486b1d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 31 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: strict
# typed: true # rubocop:todo Sorbet/StrictSigil
# frozen_string_literal: true

# Cleans a newly installed keg.
Expand Down Expand Up @@ -104,7 +104,7 @@ def prune
end
end

sig { overridable.params(path: Pathname).returns(T::Boolean) }
sig { params(path: Pathname).returns(T::Boolean) }
def executable_path?(path)
path.text_executable? || path.executable?
end
Expand All @@ -113,7 +113,7 @@ def executable_path?(path)
# pointless conflicts with other formulae. They are removed by Debian,
# Arch & MacPorts amongst other packagers as well. The files are
# created as part of installing any Perl module.
PERL_BASENAMES = T.let(Set.new(%w[perllocal.pod .packlist]).freeze, T::Set[String])
PERL_BASENAMES = Set.new(%w[perllocal.pod .packlist]).freeze

# Clean a top-level (`bin`, `sbin`, `lib`) directory, recursively, by fixing file
# permissions and removing .la files, unless the files (or parent
Expand Down Expand Up @@ -201,3 +201,5 @@ def clean_python_metadata
end
end
end

require "extend/os/cleaner"
22 changes: 0 additions & 22 deletions Library/Homebrew/cleaner_factory.rb

This file was deleted.

8 changes: 8 additions & 0 deletions Library/Homebrew/extend/os/cleaner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# typed: strict
# frozen_string_literal: true

if OS.mac?
require "extend/os/mac/cleaner"
elsif OS.linux?
require "extend/os/linux/cleaner"
end
4 changes: 2 additions & 2 deletions Library/Homebrew/extend/os/linux/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# typed: strict
# frozen_string_literal: true

class CleanerLinux < Cleaner
class Cleaner
private

sig { override.params(path: Pathname).returns(T::Boolean) }
sig { params(path: Pathname).returns(T::Boolean) }
def executable_path?(path)
path.elf? || path.text_executable?
end
Expand Down
6 changes: 4 additions & 2 deletions Library/Homebrew/extend/os/mac/cleaner.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# typed: strict
# frozen_string_literal: true

class CleanerMac < Cleaner
class Cleaner
private

sig { override.params(path: Pathname).returns(T::Boolean) }
undef executable_path?

sig { params(path: Pathname).returns(T::Boolean) }
def executable_path?(path)
path.mach_o_executable? || path.text_executable?
end
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require "tab"
require "utils/bottles"
require "caveats"
require "cleaner_factory"
require "cleaner"
require "formula_cellar_checks"
require "install_renamed"
require "sandbox"
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def fix_dynamic_linkage(keg)
sig { void }
def clean
ohai "Cleaning" if verbose?
CleanerFactory.create(formula).clean
Cleaner.new(formula).clean
rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix."
Expand Down

0 comments on commit a486b1d

Please sign in to comment.