From 451a07cc4e655b34f07d50f1dd45552d6c6d14b5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 11 Apr 2015 16:37:47 +0100 Subject: cleanup: add --prune to delete old cache files. --- Library/Homebrew/cmd/cleanup.rb | 4 ++++ Library/Homebrew/manpages/brew.1.md | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'Library') 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` : 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 -- cgit v1.2.3