aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-06-08 11:43:28 +0100
committerMax Howell2009-06-08 11:43:28 +0100
commit595938b69aa02e603367fa43114ebdaf95714c5b (patch)
tree97af62ce3fba06c618cfa2d71176b6289d7738f0 /Library
parent03f225acef70152bdf2de7a5f1c1ea31eef15246 (diff)
downloadhomebrew-595938b69aa02e603367fa43114ebdaf95714c5b.tar.bz2
Handle exceptions during install correctly
rm -rf the prefix and build dirs when appropriate.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/brewkit.rb24
1 files changed, 11 insertions, 13 deletions
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index a51c080f5..a0c4d9a12 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -178,32 +178,30 @@ public
# yields self with current working directory set to the uncompressed tarball
def brew
ohai "Downloading #{@url}"
-
Dir.chdir appsupport do
- tgz=Pathname.new(fetch()).realpath
- md5=`md5 -q "#{tgz}"`.strip
- raise "MD5 mismatch: #{md5}" unless @md5 and md5 == @md5.downcase
-
- # we make an additional subdirectory so know exactly what we are
- # recursively deleting later
- # we use mktemp rather than appsupport/blah because some build scripts
- # can't handle being built in a directory with spaces in it :P
- tmp=nil
+ tmp=tgz=nil
begin
+ tgz=Pathname.new(fetch()).realpath
+ md5=`md5 -q "#{tgz}"`.strip
+ raise "MD5 mismatch: #{md5}" unless @md5 and md5 == @md5.downcase
+
+ # we make an additional subdirectory so know exactly what we are
+ # recursively deleting later
+ # we use mktemp rather than appsupport/blah because some build scripts
+ # can't handle being built in a directory with spaces in it :P
tmp=`mktemp -dt #{File.basename @url}`.strip
Dir.chdir tmp do
Dir.chdir uncompress(tgz) do
yield self
end
end
- rescue => e
- if e.kind_of? Interrupt and ARGV.include? '--debug'
+ rescue Interrupt, RuntimeError
+ if ARGV.include? '--debug'
# debug mode allows the packager to intercept a failed build and
# investigate the problems
puts "Rescued build at: #{tmp}"
exit! 1
else
- FileUtils.rm_rf prefix
raise
end
ensure