aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorØyvind Ingebrigtsen Øvergaard2015-12-20 23:13:58 +0100
committerMike McQuaid2015-12-21 07:54:30 +0000
commitcf2bf08ec97847069ce22745476b4b2987b035e5 (patch)
tree615faab218e207717a11e2172249fa69354e7842 /Library/Homebrew/cmd
parent28776ee1c342c4be755a597812d47d547238a08b (diff)
downloadbrew-cf2bf08ec97847069ce22745476b4b2987b035e5.tar.bz2
bottle: don't read mtime from nonexistant files
If the source contains a broken symlink, `brew bottle` would fail for no good reason when trying to determine the most recently modified file. To avoid this, we ignore any files for which stat(2) fails. Closes Homebrew/homebrew#47111. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/bottle.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index fe2829c19..4c629cdbb 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -140,6 +140,10 @@ module Homebrew
erb.result(bottle.instance_eval { binding }).gsub(/^\s*$\n/, "")
end
+ def most_recent_mtime(pathname)
+ pathname.to_enum(:find).select(&:exist?).map(&:mtime).max
+ end
+
def bottle_formula(f)
unless f.installed?
return ofail "Formula not installed or up-to-date: #{f.full_name}"
@@ -187,7 +191,7 @@ module Homebrew
skip_relocation = false
formula_source_time = f.stable.stage do
- Pathname.pwd.to_enum(:find).map(&:mtime).max
+ most_recent_mtime(Pathname.pwd)
end
keg.lock do