mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
cleanup: cleanup portable ruby, old linkage cache.
- Cleanup portable ruby if you haven't specifically requested it and you don't need it. This will be useful when e.g. upgrading OS versions - Cleanup the old DBM linkage cache. These will not be used again.
This commit is contained in:
parent
8f03ea7ca9
commit
d2b5c704e1
@ -162,8 +162,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
cleanup_cache
|
cleanup_cache
|
||||||
cleanup_logs
|
cleanup_logs
|
||||||
|
cleanup_portable_ruby
|
||||||
return if dry_run?
|
return if dry_run?
|
||||||
|
|
||||||
|
cleanup_linkage_db
|
||||||
rm_ds_store
|
rm_ds_store
|
||||||
else
|
else
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
@ -290,6 +292,45 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cleanup_portable_ruby
|
||||||
|
system_ruby_version =
|
||||||
|
Utils.popen_read("/usr/bin/ruby", "-e", "puts RUBY_VERSION")
|
||||||
|
.chomp
|
||||||
|
use_system_ruby = (
|
||||||
|
Gem::Version.new(system_ruby_version) >= Gem::Version.new(RUBY_VERSION)
|
||||||
|
) && ENV["HOMEBREW_FORCE_VENDOR_RUBY"].nil?
|
||||||
|
vendor_path = HOMEBREW_LIBRARY/"Homebrew/vendor"
|
||||||
|
portable_ruby_version_file = vendor_path/"portable-ruby-version"
|
||||||
|
portable_ruby_version = if portable_ruby_version_file.exist?
|
||||||
|
portable_ruby_version_file.read
|
||||||
|
.chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
portable_ruby_path = vendor_path/"portable-ruby"
|
||||||
|
portable_ruby_glob = "#{portable_ruby_path}/*.*"
|
||||||
|
Pathname.glob(portable_ruby_glob).each do |path|
|
||||||
|
next if !use_system_ruby && portable_ruby_version == path.basename.to_s
|
||||||
|
if dry_run?
|
||||||
|
puts "Would remove: #{path} (#{path.abv})"
|
||||||
|
else
|
||||||
|
FileUtils.rm_rf path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return unless Dir.glob(portable_ruby_glob).empty?
|
||||||
|
return unless portable_ruby_path.exist?
|
||||||
|
|
||||||
|
if dry_run?
|
||||||
|
puts "Would remove: #{portable_ruby_path} (#{portable_ruby_path.abv})"
|
||||||
|
else
|
||||||
|
FileUtils.rm_rf portable_ruby_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def cleanup_linkage_db
|
||||||
|
FileUtils.rm_rf [cache/"linkage.db", cache/"linkage.db.db"]
|
||||||
|
end
|
||||||
|
|
||||||
def rm_ds_store(dirs = nil)
|
def rm_ds_store(dirs = nil)
|
||||||
dirs ||= begin
|
dirs ||= begin
|
||||||
Keg::MUST_EXIST_DIRECTORIES + [
|
Keg::MUST_EXIST_DIRECTORIES + [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user