Commit cf479759 authored by Michał Siwek's avatar Michał Siwek

Merge pull request #54 from dmcaulay/install_errors

Discuss: Installation errors can leave chromebrew in an inconsistent state
parents 6d5ecfc6 74409915
......@@ -148,18 +148,22 @@ def download
end
def resolveDependenciesAndInstall
origin = @pkg.name
begin
origin = @pkg.name
resolveDependencies
resolveDependencies
search origin
install
#cleanup
unless ARGV[2] == 'keep'
Dir.chdir CREW_BREW_DIR do
system "rm -rf *"
system "mkdir dest" #this is a little ugly, feel free to find a better way
search origin
install
rescue InstallError => e
puts "#{@pkg.name} failed to install: #{e.to_s}"
ensure
#cleanup
unless ARGV[2] == 'keep'
Dir.chdir CREW_BREW_DIR do
system "rm -rf *"
system "mkdir dest" #this is a little ugly, feel free to find a better way
end
end
end
end
......@@ -183,7 +187,7 @@ def resolveDependencies
return if @dependencies.empty?
puts "Following packages also need to be installed: "
@dependencies.flatten!.each do |dep|
@dependencies.flatten!.uniq!.each do |dep|
print dep + " "
end
puts ""
......
......@@ -26,4 +26,10 @@ class Package
def self.build
end
def self.system(*args)
Kernel.system(*args)
exitstatus = $?.exitstatus
raise InstallError.new("`#{args.join(" ")}` exited with #{exitstatus}") unless exitstatus == 0
end
end
class InstallError < RuntimeError; end
def property(*properties)
properties.each do |prop|
self.class_eval("def self.#{prop}(#{prop} = nil); @#{prop} = #{prop} if #{prop}; @#{prop}; end")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment