diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 022705ba2e..0dd115f325 100644 --- a/Library/Contributions/manpages/brew.1.md +++ b/Library/Contributions/manpages/brew.1.md @@ -51,15 +51,20 @@ For the full command list, see the COMMANDS section. * `cat` : Display the source to . - * `cleanup [--force] [-n]` []: + * `cleanup [--force] [-ns]` []: For all installed or specific formulae, remove any older versions from the cellar. By default, does not remove out-of-date keg-only brews, as other - software may link directly to specific versions. + software may link directly to specific versions. In addition old downloads from + the Homebrew download-cache are deleted. If `--force` is passed, remove out-of-date keg-only brews as well. If `-n` is passed, show what would be removed, but do not actually remove anything. + If `-s` is passed, scrubs the cache, removing downloads for even the latest + versions of formula. Note downloads for any installed formula will still not be + deleted. If you want to delete those too: `rm -rf $(brew --cache)` + * `create [--autotools|--cmake] [--no-fetch]` : Generate a formula for the downloadable file at and open it in `EDITOR`. Homebrew will attempt to automatically derive the formula name diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index 0aec10f564..0f2a1875d3 100644 --- a/Library/Homebrew/cmd/cleanup.rb +++ b/Library/Homebrew/cmd/cleanup.rb @@ -2,6 +2,7 @@ require 'formula' require 'cmd/prune' module Homebrew extend self + def cleanup if ARGV.named.empty? HOMEBREW_CELLAR.children.each do |rack| @@ -12,8 +13,9 @@ module Homebrew extend self # instead of core formulae. end end + clean_cache # seems like a good time to do some additional cleanup - Homebrew.prune unless ARGV.include? '-n' + Homebrew.prune unless ARGV.switch? 'n' else ARGV.formulae.each do |f| cleanup_formula f @@ -35,9 +37,8 @@ module Homebrew extend self if f.installed? and f.rack.directory? f.rack.children.each do |keg| if f.installed_prefix != keg - print "Removing #{keg}..." - rm_rf keg unless ARGV.include? '-n' - puts + puts "Removing #{keg}..." + rm_rf keg unless ARGV.switch? 'n' end end elsif f.rack.children.length > 1 @@ -47,4 +48,17 @@ module Homebrew extend self end end + def clean_cache + HOMEBREW_CACHE.children.each do |pn| + pn.stem =~ /^(.+)-(.+)$/ # greedy so works even if formula-name has hyphens in it + if $1 and $2 + f = Formula.factory($1) rescue nil + if not f or (f.version != $2 or ARGV.switch? "s" and not f.installed?) + puts "Removing #{pn}..." + rm pn unless ARGV.switch? 'n' + end + end + end + end + end diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index 2b3b2cea33..ea060c289d 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "February 2012" "Homebrew" "brew" +.TH "BREW" "1" "March 2012" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for OS X @@ -61,8 +61,8 @@ If no \fIformulae\fR are provided, all of them are checked\. Display the source to \fIformula\fR\. . .TP -\fBcleanup [\-\-force] [\-n]\fR [\fIformulae\fR] -For all installed or specific formulae, remove any older versions from the cellar\. By default, does not remove out\-of\-date keg\-only brews, as other software may link directly to specific versions\. +\fBcleanup [\-\-force] [\-ns]\fR [\fIformulae\fR] +For all installed or specific formulae, remove any older versions from the cellar\. By default, does not remove out\-of\-date keg\-only brews, as other software may link directly to specific versions\. In addition old downloads from the Homebrew download\-cache are deleted\. . .IP If \fB\-\-force\fR is passed, remove out\-of\-date keg\-only brews as well\. @@ -70,6 +70,9 @@ If \fB\-\-force\fR is passed, remove out\-of\-date keg\-only brews as well\. .IP If \fB\-n\fR is passed, show what would be removed, but do not actually remove anything\. . +.IP +If \fB\-s\fR is passed, scrubs the cache, removing downloads for even the latest versions of formula\. Note downloads for any installed formula will still not be deleted\. If you want to delete those too: \fBrm \-rf $(brew \-\-cache)\fR +. .TP \fBcreate [\-\-autotools|\-\-cmake] [\-\-no\-fetch]\fR \fIURL\fR Generate a formula for the downloadable file at \fIURL\fR and open it in \fBEDITOR\fR\. Homebrew will attempt to automatically derive the formula name and version, but if it fails, you\'ll have to make your own template\. The wget formula serves as a simple example\.