Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninstall: show etc/var files from poured bottle #18570

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Library/Homebrew/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def self.uninstall_kegs(kegs_by_rack, casks: [], force: false, ignore_dependenci
nil
end

etc_var_files = if !keg.tab.poured_from_bottle || f.nil?
nil
elsif f.bottle_prefix.exist?
f.bottle_prefix.find.filter_map { |path| path.sub(f.bottle_prefix.to_s, HOMEBREW_PREFIX) if path.file? }
else
[]
end

keg.lock do
puts "Uninstalling #{keg}... (#{keg.abv})"
keg.unlink
Expand All @@ -57,22 +65,30 @@ def self.uninstall_kegs(kegs_by_rack, casks: [], force: false, ignore_dependenci
next unless f

paths = f.pkgetc.find.map(&:to_s) if f.pkgetc.exist?
if etc_var_files
paths ||= []
paths += etc_var_files.filter_map { |file| file.to_s if file.exist? }
paths += etc_var_files.filter_map { |file| "#{file}.default" if File.exist?("#{file}.default") }
end
if paths.present?
puts
opoo <<~EOS
The following #{f.name} configuration files have not been removed!
The following #{f.name} configuration/data files have not been removed!
If desired, remove them manually with `rm -rf`:
#{paths.sort.uniq.join("\n ")}
EOS
end

next unless etc_var_files.nil?

unversioned_name = f.name.gsub(/@.+$/, "")
maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*")
maybe_paths -= paths if paths.present?
if maybe_paths.present?
puts
opoo <<~EOS
The following may be #{f.name} configuration files and have not been removed!
The following MAY be #{f.name} configuration files and have not been removed.
Do not remove these unless you are confident that they are related to #{f.name}.
If desired, remove them manually with `rm -rf`:
#{maybe_paths.sort.uniq.join("\n ")}
EOS
Expand Down
Loading