diff --git a/bin/rbpkg b/bin/rbpkg
index e01bf99..260ff70 100755
--- a/bin/rbpkg
+++ b/bin/rbpkg
@@ -110,6 +110,11 @@ def rbpkg
end
end
-rbpkg
-
-Rbpkg::Log.ok_all
+begin
+ rbpkg
+ Rbpkg::Log.ok_all
+rescue => error
+ verbose(-1, "#{error.class.name}: #{error.message}")
+ verbose(-1, error.backtrace.reverse.join("\n"))
+ Rbpkg::Log.ko_all
+end
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index 6a0968a..332daaa 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -341,6 +341,10 @@ end
def verbose(level, msg)
colored = case level
+ when -1
+ "\33[0;35m#{msg}\33[0m\n"
+ when 0
+ msg
when 1
"\33[0;34m#{msg}\33[0m\n"
when 3
diff --git a/lib/rbpkg/log.rb b/lib/rbpkg/log.rb
index 12712e9..81c7895 100644
--- a/lib/rbpkg/log.rb
+++ b/lib/rbpkg/log.rb
@@ -25,31 +25,32 @@ module Rbpkg
end
def self.init(name)
+ @@name = name
@@logs = []
add(name)
at_exit { ko_all }
end
def self.ko(name)
- puts_by_name(name, "KO")
+ puts_by_name(name, status_message_ko)
remove(name)
end
def self.ko_all
if @@logs != []
- verbose(3, "KO")
+ verbose(-1, status_message_ko)
@@logs = []
end
end
def self.ok(name)
- puts_by_name(name, "OK")
+ puts_by_name(name, status_message_ok)
remove(name)
end
def self.ok_all
if @@logs != []
- verbose(3, "OK")
+ verbose(3, status_message_ok)
@@logs = []
end
end
@@ -81,5 +82,17 @@ module Rbpkg
raise "not logging to #{name.inspect}" unless @@logs.include?(name)
@@logs.delete(name)
end
- end
+
+ def self.status_message(status)
+ "Status: #{@@name} -> #{status}"
+ end
+
+ def self.status_message_ko
+ status_message("KO")
+ end
+
+ def self.status_message_ok
+ status_message("OK")
+ end
+end
end
diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index e5b59d7..ddcd125 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -6,7 +6,7 @@ class Rbpkg::Repo
@@branch_default = "master"
def autogen()
- verbose 3, "repo(#{name}).autogen"
+ verbose 3, "repo(#{name.inspect}).autogen"
if File.executable?("#{src_dir}/autogen")
cmd! "cd #{sh_quote(src_dir)} && ./autogen"
elsif File.exists?("#{src_dir}/autogen.sh")
@@ -19,7 +19,7 @@ class Rbpkg::Repo
end
def build
- verbose 3, "repo(#{name}).build"
+ verbose 3, "repo(#{name.inspect}).build"
if ! tag_present?("build-done")
configure()
if File.file?("#{src_dir}/Makefile")
@@ -32,13 +32,13 @@ class Rbpkg::Repo
end
def checkout(branch)
- verbose 3, "repo(#{name}).checkout"
+ verbose 3, "repo(#{name.inspect}).checkout"
sh_branch=sh_quote(branch)
- cmd! "cd #{sh_quote(src_dir!)} && git fetch #{sh_quote(remote)} #{sh_branch} && git checkout #{sh_branch} && git submodule update"
+ cmd! "cd #{sh_quote(src_dir!)} && git fetch #{sh_quote(remote)} #{sh_branch} && git checkout #{sh_branch} -- && git submodule update"
end
def clean_all
- verbose 3, "repo(#{name}).clean_all"
+ verbose 3, "repo(#{name.inspect}).clean_all"
clean_fake
clean_build
clean_configure
@@ -46,7 +46,7 @@ class Rbpkg::Repo
end
def clean_build
- verbose 3, "repo(#{name}).clean_build"
+ verbose 3, "repo(#{name.inspect}).clean_build"
if File.file?("#{src_dir}/Makefile")
cmd! "cd #{sh_quote(src_dir)} && make clean"
end
@@ -57,19 +57,19 @@ class Rbpkg::Repo
end
def clean_configure
- verbose 3, "repo(#{name}).clean_configure"
+ verbose 3, "repo(#{name.inspect}).clean_configure"
tag_remove("configure-done")
end
def clean_fake
- verbose 3, "repo(#{name}).clean_fake"
+ verbose 3, "repo(#{name.inspect}).clean_fake"
if File.directory?(fake_dir)
cmd! "rm -rf #{sh_quote(fake_dir)}"
end
end
def clean_package
- verbose 3, "repo(#{name}).clean_package"
+ verbose 3, "repo(#{name.inspect}).clean_package"
if File.file?(package_checksum)
cmd! "rm #{sh_quote(package_checksum)}"
end
@@ -88,7 +88,7 @@ class Rbpkg::Repo
end
def clean_sources
- verbose 3, "repo(#{name}).clean_sources"
+ verbose 3, "repo(#{name.inspect}).clean_sources"
tag_remove("build-done") if tag_present?("build-done")
tag_remove("configure-done") if tag_present?("configure-done")
if File.directory?(src_dir)
@@ -100,7 +100,7 @@ class Rbpkg::Repo
end
def configure
- verbose 3, "repo(#{name}).configure"
+ verbose 3, "repo(#{name.inspect}).configure"
if ! File.directory?(src_dir)
git_clone()
end
@@ -131,7 +131,7 @@ class Rbpkg::Repo
end
def fake
- verbose 3, "repo(#{name}).fake"
+ verbose 3, "repo(#{name.inspect}).fake"
build()
if File.directory?(fake_dir)
cmd! "rm -rf #{sh_quote(fake_dir)}"
@@ -149,12 +149,12 @@ class Rbpkg::Repo
end
def fetch
- verbose 3, "repo(#{name}).fetch"
+ verbose 3, "repo(#{name.inspect}).fetch"
cmd! "cd #{sh_quote(src_dir!)} && git fetch"
end
def git_clone
- verbose 3, "repo(#{name}).git_clone"
+ verbose 3, "repo(#{name.inspect}).git_clone"
if File.directory?(src_dir)
false
else
@@ -207,7 +207,7 @@ class Rbpkg::Repo
end
def install
- verbose 3, "repo(#{name}).install"
+ verbose 3, "repo(#{name.inspect}).install"
return if system_package?
return if installed?
install_dependencies
@@ -229,7 +229,7 @@ class Rbpkg::Repo
end
def install_dependencies
- verbose 3, "repo(#{name}).install_dependencies"
+ verbose 3, "repo(#{name.inspect}).install_dependencies"
if dependencies
Rbpkg.install(dependencies)
end
@@ -268,7 +268,7 @@ class Rbpkg::Repo
end
def package
- verbose 3, "repo(#{name}).package"
+ verbose 3, "repo(#{name.inspect}).package"
return if File.file?(package_tar_bz2) &&
File.file?(package_tar_gz) &&
File.file?(package_tar_xz)
@@ -327,7 +327,7 @@ class Rbpkg::Repo
end
def pull
- verbose 3, "repo(#{name}).pull"
+ verbose 3, "repo(#{name.inspect}).pull"
cmd! "cd #{sh_quote(src_dir!)} && git pull && git submodule update"
end
@@ -381,14 +381,14 @@ class Rbpkg::Repo
end
def tag_set(tag)
- verbose 3, "repo(#{name}).tag_set(#{tag})"
+ verbose 3, "repo(#{name.inspect}).tag_set(#{tag})"
raise "tag already set" if tag_present?(tag)
FileUtils.mkdir_p tag_dir unless File.directory?(tag_dir)
File.write(tag_path(tag), "#{Rbpkg.date}\n")
end
def test
- verbose 3, "repo(#{name}).test"
+ verbose 3, "repo(#{name.inspect}).test"
build()
if File.file?("#{src_dir}/Makefile")
cmd! "cd #{sh_quote(src_dir)} && make #{sh_quote(test_make_rule)}"
@@ -400,7 +400,7 @@ class Rbpkg::Repo
end
def uninstall
- verbose 3, "repo(#{name}).uninstall"
+ verbose 3, "repo(#{name.inspect}).uninstall"
if installed?
uninstall_required_by
File.open(installed, "r") do |input|
@@ -422,14 +422,14 @@ class Rbpkg::Repo
end
def uninstall_required_by
- verbose 3, "repo(#{name}).uninstall_required_by"
+ verbose 3, "repo(#{name.inspect}).uninstall_required_by"
required_by.each do |req|
Rbpkg::Repos.repo(req).uninstall
end
end
def upgrade
- verbose 3, "repo(#{name}).upgrade"
+ verbose 3, "repo(#{name.inspect}).upgrade"
pull
return if installed_version == version
package