Permalink
Browse files

follows soap4r's install.rb. you can run install.rb from another work…

…ing directory.
  • Loading branch information...
1 parent 8163bae commit 60f45a44b7ddfc6ca89aa3d2a8c49cc7a6d83ae6 nahi committed Jan 9, 2005
Showing with 26 additions and 14 deletions.
  1. +26 −14 install.rb
View
@@ -1,32 +1,44 @@
#!/usr/bin/env ruby
#
# Installer for http-access2
-# Copyright (C) 2001 Michael Neumann and NAKAMURA, Hiroshi.
require "rbconfig"
require "ftools"
+
include Config
RV = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
-DSTPATH = CONFIG["sitedir"] + "/" + RV
+SITELIBDIR = CONFIG["sitedir"] + "/" + RV
+SRCPATH = File.join(File.dirname($0), 'lib')
-begin
- unless FileTest.directory?("lib/http-access2")
- raise RuntimeError.new("'lib/http-access2' not found.")
+def install_file(from, to)
+ to_path = File.catname(from, to)
+ unless FileTest.exist?(to_path) and File.compare(from, to_path)
+ File.install(from, to_path, 0644, true)
end
+end
- File.mkpath DSTPATH + "/http-access2", true
- Dir["lib/http-access2/*.rb"].each do |name|
- File.install name, "#{DSTPATH}/http-access2/#{File.basename name}", 0644, true
+def install(*path)
+ from_path = File.join(SRCPATH, *path)
+ if FileTest.directory?(from_path)
+ to_path_sitelib = File.join(SITELIBDIR, *path)
+ Dir[File.join(from_path, '*.rb')].each do |name|
+ File.mkpath(to_path_sitelib, true)
+ install_file(name, to_path_sitelib)
+ end
+ else
+ install_file(from_path, SITELIBDIR)
end
+end
- Dir["lib/*.rb"].each do |name|
- File.install name, "#{DSTPATH}/#{File.basename name}", 0644, true
- end
+begin
+ install('http-access2.rb')
+ install('http-access2')
+
+ puts "install succeed!"
rescue
puts "install failed!"
- puts $!
-else
- puts "install succeed!"
+ raise
+
end

0 comments on commit 60f45a4

Please sign in to comment.