Commit 8f48b5f41ed4a845c27fb41b91ffeb627e8b6e8e

Thomas de Grivel 2023-02-23T13:40:58

fix log after upgrade

diff --git a/bin/rbpkg b/bin/rbpkg
index f6c2b7e..2557c13 100755
--- a/bin/rbpkg
+++ b/bin/rbpkg
@@ -1,13 +1,8 @@
 #!/usr/bin/env ruby
-require __FILE__ + '/../../lib/rbpkg'
+load "#{File.dirname(File.dirname(__FILE__))}/lib/rbpkg/log.rb"
+load "#{File.dirname(File.dirname(__FILE__))}/lib/rbpkg.rb"
 
-log_path = Rbpkg.log_path("rbpkg")
-FileUtils.mkdir_p(File.dirname(log_path))
-$log = File.open(log_path, "w")
-#verbose 2, "Logging to #{log_path}"
-
-Rbpkg.init()
-Rbpkg.lock("rbpkg")
+Rbpkg.init("rbpkg")
 
 def usage()
   STDERR.puts """Usage: #{File.basename($0)} COMMAND REPO ...
@@ -54,9 +49,9 @@ end
 def rbpkg
   case shift
   when "-h"
-    usage()
+    usage
   when "--help"
-    usage()
+    usage
   when "clone"
     Rbpkg.git_clone($ARGS)
   when "clean-sources"
diff --git a/lib/rbpkg.rb b/lib/rbpkg.rb
index 2ad9c45..e16a422 100644
--- a/lib/rbpkg.rb
+++ b/lib/rbpkg.rb
@@ -122,13 +122,16 @@ module Rbpkg
     end
   end
 
-  def self.init
+  def self.init(name)
     [dir,
      lock_dir,
      log_dir
     ].each do |d|
       ensure_dir(d)
     end
+    Rbpkg::Log.init(name)
+    $log = Rbpkg::Log
+    Rbpkg.lock(name)
   end
 
   def self.inspect