diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb index e0f31d7973..786c082753 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 e155ac8b08..8f1f2b1618 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` : Display the source to . - * `cleanup [--force] [-ns]` []: + * `cleanup [--force] [--prune=] [-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. 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=` is specified, remove all cache files older than . + 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 98f9a71612..8981bbdfff 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=] [\-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=\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