blob: 46c74a30582d20c98b589129364a29b88b5d8c98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|
require 'keg'
require 'cmd/tap'
module Homebrew extend self
# $n and $d are used by the ObserverPathnameExtension to keep track of
# certain filesystem actions.
def prune
$n = 0
$d = 0
dirs = []
Keg::PRUNEABLE_DIRECTORIES.select(&:directory?).each do |dir|
dir.find do |path|
path.extend(ObserverPathnameExtension)
if path.symlink?
unless path.resolved_path_exists?
if ENV['HOMEBREW_KEEP_INFO'] and path.to_s =~ Keg::INFOFILE_RX
path.uninstall_info unless ARGV.dry_run?
end
if ARGV.dry_run?
puts "Would remove (broken link): #{path}"
else
path.unlink
end
end
elsif path.directory?
dirs << path
end
end
end
dirs.sort.reverse_each do |d|
if ARGV.dry_run? && d.children.empty?
puts "Would remove (empty directory): #{d}"
else
d.rmdir_if_possible
end
end
repair_taps unless ARGV.dry_run?
if $n == 0 && $d == 0
puts "Nothing pruned" if ARGV.verbose?
else
print "Pruned #{$n} symbolic links "
print "and #{$d} directories " if $d > 0
puts "from #{HOMEBREW_PREFIX}"
end unless ARGV.dry_run?
end
end
|