Move ::Cleanup check to extend/os
This commit is contained in:
parent
c7d53a2d9c
commit
d69326c8d0
@ -405,28 +405,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cleanup_portable_ruby
|
def cleanup_portable_ruby
|
||||||
rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact
|
|
||||||
system_ruby = Pathname.new("/usr/bin/ruby")
|
|
||||||
rubies << system_ruby if system_ruby.exist?
|
|
||||||
|
|
||||||
use_system_ruby = if Homebrew::EnvConfig.force_vendor_ruby?
|
|
||||||
false
|
|
||||||
elsif OS.mac?
|
|
||||||
ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present?
|
|
||||||
else
|
|
||||||
check_ruby_version = HOMEBREW_LIBRARY_PATH/"utils/ruby_check_version_script.rb"
|
|
||||||
rubies.uniq.any? do |ruby|
|
|
||||||
quiet_system ruby, "--enable-frozen-string-literal", "--disable=gems,did_you_mean,rubyopt",
|
|
||||||
check_ruby_version, HOMEBREW_REQUIRED_RUBY_VERSION
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vendor_dir = HOMEBREW_LIBRARY/"Homebrew/vendor"
|
vendor_dir = HOMEBREW_LIBRARY/"Homebrew/vendor"
|
||||||
portable_ruby_latest_version = (vendor_dir/"portable-ruby-version").read.chomp
|
portable_ruby_latest_version = (vendor_dir/"portable-ruby-version").read.chomp
|
||||||
|
|
||||||
portable_rubies_to_remove = []
|
portable_rubies_to_remove = []
|
||||||
Pathname.glob(vendor_dir/"portable-ruby/*.*").select(&:directory?).each do |path|
|
Pathname.glob(vendor_dir/"portable-ruby/*.*").select(&:directory?).each do |path|
|
||||||
next if !use_system_ruby && portable_ruby_latest_version == path.basename.to_s
|
next if !use_system_ruby? && portable_ruby_latest_version == path.basename.to_s
|
||||||
|
|
||||||
portable_rubies_to_remove << path
|
portable_rubies_to_remove << path
|
||||||
end
|
end
|
||||||
@ -445,6 +429,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def use_system_ruby?; end
|
||||||
|
|
||||||
def cleanup_bootsnap
|
def cleanup_bootsnap
|
||||||
bootsnap = cache/"bootsnap"
|
bootsnap = cache/"bootsnap"
|
||||||
return unless bootsnap.exist?
|
return unless bootsnap.exist?
|
||||||
@ -615,3 +601,5 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "extend/os/cleanup"
|
||||||
|
|||||||
8
Library/Homebrew/extend/os/cleanup.rb
Normal file
8
Library/Homebrew/extend/os/cleanup.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
if OS.mac?
|
||||||
|
require "extend/os/mac/cleanup"
|
||||||
|
elsif OS.linux?
|
||||||
|
require "extend/os/linux/cleanup"
|
||||||
|
end
|
||||||
22
Library/Homebrew/extend/os/linux/cleanup.rb
Normal file
22
Library/Homebrew/extend/os/linux/cleanup.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
class Cleanup
|
||||||
|
undef use_system_ruby?
|
||||||
|
|
||||||
|
def use_system_ruby?
|
||||||
|
return false if Homebrew::EnvConfig.force_vendor_ruby?
|
||||||
|
|
||||||
|
rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact
|
||||||
|
system_ruby = Pathname.new("/usr/bin/ruby")
|
||||||
|
rubies << system_ruby if system_ruby.exist?
|
||||||
|
|
||||||
|
check_ruby_version = HOMEBREW_LIBRARY_PATH/"utils/ruby_check_version_script.rb"
|
||||||
|
rubies.uniq.any? do |ruby|
|
||||||
|
quiet_system ruby, "--enable-frozen-string-literal", "--disable=gems,did_you_mean,rubyopt",
|
||||||
|
check_ruby_version, HOMEBREW_REQUIRED_RUBY_VERSION
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
14
Library/Homebrew/extend/os/mac/cleanup.rb
Normal file
14
Library/Homebrew/extend/os/mac/cleanup.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Homebrew
|
||||||
|
class Cleanup
|
||||||
|
undef use_system_ruby?
|
||||||
|
|
||||||
|
def use_system_ruby?
|
||||||
|
return false if Homebrew::EnvConfig.force_vendor_ruby?
|
||||||
|
|
||||||
|
ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user