aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2015-04-11 16:37:47 +0100
committerMike McQuaid2015-04-16 17:52:10 -0700
commit9b59aeceee58cf561e135c26fd29c0051b2821f7 (patch)
tree0ec892e64bbd3dffda8efd0f32fb59728262d056
parent41cb7ccecdaa0318d79d1d68fb6525611a72cef4 (diff)
downloadhomebrew-9b59aeceee58cf561e135c26fd29c0051b2821f7.tar.bz2
cleanup: add --prune to delete old cache files.
-rw-r--r--Library/Homebrew/cmd/cleanup.rb4
-rw-r--r--Library/Homebrew/manpages/brew.1.md4
-rw-r--r--share/man/man1/brew.17
3 files changed, 12 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index e0f31d797..786c08275 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -66,7 +66,11 @@ module Homebrew
def cleanup_cache
return unless HOMEBREW_CACHE.directory?
+ prune = ARGV.value "prune"
+ time = Time.now - 60 * 60 * 24 * prune.to_i
HOMEBREW_CACHE.children.select(&:file?).each do |file|
+ next cleanup_path(file) { file.unlink } if prune && file.mtime < time
+
next unless (version = file.version)
next unless (name = file.basename.to_s[/(.*)-(?:#{Regexp.escape(version)})/, 1])
diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md
index e155ac8b0..8f1f2b161 100644
--- a/Library/Homebrew/manpages/brew.1.md
+++ b/Library/Homebrew/manpages/brew.1.md
@@ -53,7 +53,7 @@ Note that these flags should only appear after a command.
* `cat` <formula>:
Display the source to <formula>.
- * `cleanup [--force] [-ns]` [<formulae>]:
+ * `cleanup [--force] [--prune=<days>] [-ns]` [<formulae>]:
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
@@ -61,6 +61,8 @@ Note that these flags should only appear after a command.
If `--force` is passed, remove out-of-date keg-only brews as well.
+ If `--prune=<days>` is specified, remove all cache files older than <days>.
+
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
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1
index 98f9a7161..8981bbdff 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" "March 2015" "Homebrew" "brew"
+.TH "BREW" "1" "April 2015" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The missing package manager for OS X
@@ -61,13 +61,16 @@ If \fB\-\-strict\fR is passed, additional checks are run\. This should be used w
Display the source to \fIformula\fR\.
.
.TP
-\fBcleanup [\-\-force] [\-ns]\fR [\fIformulae\fR]
+\fBcleanup [\-\-force] [\-\-prune=<days>] [\-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\.
.
.IP
+If \fB\-\-prune=<days>\fR is specified, remove all cache files older than \fIdays\fR\.
+.
+.IP
If \fB\-n\fR is passed, show what would be removed, but do not actually remove anything\.
.
.IP