diff --git a/bin/rbpkg b/bin/rbpkg
index 273b88b..f6c2b7e 100755
--- a/bin/rbpkg
+++ b/bin/rbpkg
@@ -33,6 +33,7 @@ Package commands :
clean-package remove package file
install install package
uninstall uninstall package
+ upgrade upgrade package
Misc commands :
clean-all clean all files
@@ -93,6 +94,8 @@ def rbpkg
Rbpkg.uninstall($ARGS)
when "clean-all"
Rbpkg.clean_all($ARGS)
+ when "upgrade"
+ Rbpkg.upgrade($ARGS)
when "info"
Rbpkg.info($ARGS)
else
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index fa021dc..2ad9c45 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -1,5 +1,5 @@
require 'time'
-require __FILE__ + '/../rbpkg/repos'
+load "#{File.dirname(__FILE__)}/rbpkg/repos.rb"
module Rbpkg
@@ -292,6 +292,18 @@ module Rbpkg
Repos.repo(name).uninstall()
end
end
+
+ def self.upgrade(repos)
+ upgrade_self
+ repos.each do |name|
+ Repos.repo(name).upgrade()
+ end
+ end
+
+ def self.upgrade_self
+ cmd! "cd #{sh_quote(dir)} && git pull"
+ load "#{dir}/lib/rbpkg.rb"
+ end
end
def cmd(string)
diff --git a/lib/rbpkg/repo.rb b/lib/rbpkg/repo.rb
index 83d10c5..5c71f25 100644
--- a/lib/rbpkg/repo.rb
+++ b/lib/rbpkg/repo.rb
@@ -6,15 +6,11 @@ class Rbpkg::Repo
@@branch_default = "master"
def autogen()
- r = if File.executable?("#{src_dir}/autogen")
- cmd! "cd #{sh_quote(src_dir)} && ./autogen"
- elsif File.exists?("#{src_dir}/autogen.sh")
- cmd! "cd #{sh_quote(src_dir)} && ./autogen"
- else
- true
- end
- raise "autogen failed" unless r
- true
+ if File.executable?("#{src_dir}/autogen")
+ cmd! "cd #{sh_quote(src_dir)} && ./autogen"
+ elsif File.exists?("#{src_dir}/autogen.sh")
+ cmd! "cd #{sh_quote(src_dir)} && ./autogen"
+ end
end
def branch
diff --git a/lib/rbpkg/repos.rb b/lib/rbpkg/repos.rb
index e03f558..e3a96eb 100644
--- a/lib/rbpkg/repos.rb
+++ b/lib/rbpkg/repos.rb
@@ -23,6 +23,8 @@ module Rbpkg
end
end
+load "#{File.dirname(__FILE__)}/repo.rb"
+
Dir.glob("*.rb", base: "#{File.dirname(__FILE__)}/repos").each do |r|
- require "#{File.dirname(__FILE__)}/repos/#{r}"
+ load "#{File.dirname(__FILE__)}/repos/#{r}"
end
diff --git a/lib/rbpkg/repos/c3.rb b/lib/rbpkg/repos/c3.rb
index 90bfb3b..f135215 100644
--- a/lib/rbpkg/repos/c3.rb
+++ b/lib/rbpkg/repos/c3.rb
@@ -1,5 +1,3 @@
-require "#{__FILE__}/../../repo"
-
class Rbpkg::Repos::C3 < Rbpkg::Repo
def_name "c3"
diff --git a/lib/rbpkg/repos/libbsd.rb b/lib/rbpkg/repos/libbsd.rb
index 4b8f771..4142f9f 100644
--- a/lib/rbpkg/repos/libbsd.rb
+++ b/lib/rbpkg/repos/libbsd.rb
@@ -1,5 +1,3 @@
-require "#{__FILE__}/../../repo"
-
class Rbpkg::Repos::Libbsd < Rbpkg::Repo
def_name("libbsd")
diff --git a/lib/rbpkg/repos/libmd.rb b/lib/rbpkg/repos/libmd.rb
index f54ed77..927ad98 100644
--- a/lib/rbpkg/repos/libmd.rb
+++ b/lib/rbpkg/repos/libmd.rb
@@ -1,5 +1,3 @@
-require "#{__FILE__}/../../repo"
-
class Rbpkg::Repos::Libmd < Rbpkg::Repo
def_name("libmd")