Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/tags/RELEASE_1_5_7/install.rb

Revision 1879, 2.4 kB (checked in by nahi, 1 year ago)
  • use File.exist? instead of obsolete File.exists?
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to author date id revision
Line 
1 #!/usr/bin/env ruby
2
3 require 'getoptlong'
4 require 'rbconfig'
5 require 'ftools'
6
7 OptSet = [
8   ['--prefix','-p', GetoptLong::REQUIRED_ARGUMENT],
9 ]
10 prefix = nil
11 GetoptLong.new(*OptSet).each do |name, arg|
12   case name
13   when "--prefix"
14     prefix = arg
15   else
16     raise ArgumentError.new("Unknown type #{ arg }")
17   end
18 end
19
20 include Config
21 RV = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
22 ORG_PREFIX = CONFIG["prefix"]
23 SRCPATH = File.join(File.dirname($0), 'lib')
24
25 RUBYLIBDIR = CONFIG["rubylibdir"]
26 SITELIBDIR = CONFIG["sitedir"] + "/" +  RV
27
28 if prefix
29   RUBYLIBDIR.sub!(/^#{Regexp.quote(ORG_PREFIX)}/, prefix)
30   SITELIBDIR.sub!(/^#{Regexp.quote(ORG_PREFIX)}/, prefix)
31 end
32
33 def install(from, to)
34   to_path = File.catname(from, to)
35   unless FileTest.exist?(to_path) and File.compare(from, to_path)
36     File.install(from, to_path, 0644, true)
37   end
38 end
39
40 def install_dir(srcbase, *path)
41   from_path = File.join(srcbase, *path)
42   unless FileTest.directory?(from_path)
43     raise RuntimeError.new("'#{ from_path }' not found.")
44   end
45   to_path_rubylib = File.join(RUBYLIBDIR, *path)
46   to_path_sitelib = File.join(SITELIBDIR, *path)
47   Dir[File.join(from_path, '*.rb')].each do |from_file|
48     basename = File.basename(from_file)
49     to_file_rubylib = File.join(to_path_rubylib, basename)
50     to_file_sitelib = File.join(to_path_sitelib, basename)
51     if File.exist?(to_file_rubylib)
52       if File.exist?(to_file_sitelib)
53         raise RuntimeError.new(
54           "trying to install '#{ to_file_rubylib }' but '#{ to_file_sitelib }' exists.  please remove '#{ to_file_sitelib }' first to avoid versioning problem and run installer again.")
55       end
56       install(from_file, to_path_rubylib)
57     else
58       File.mkpath(to_path_sitelib, true)
59       install(from_file, to_path_sitelib)
60     end
61   end
62 end
63
64 begin
65   install_dir(SRCPATH, 'soap')
66   install_dir(SRCPATH, 'soap', 'rpc')
67   install_dir(SRCPATH, 'soap', 'mapping')
68   install_dir(SRCPATH, 'soap', 'encodingstyle')
69   install_dir(SRCPATH, 'soap', 'header')
70   install_dir(SRCPATH, 'soap', 'filter')
71   install_dir(SRCPATH, 'wsdl')
72   install_dir(SRCPATH, 'wsdl', 'xmlSchema')
73   install_dir(SRCPATH, 'wsdl', 'soap')
74   install_dir(SRCPATH, 'xsd')
75   install_dir(SRCPATH, 'xsd', 'codegen')
76   install_dir(SRCPATH, 'xsd', 'xmlparser')
77
78   # xmlscan
79   xmlscansrcdir = File.join('redist', 'xmlscan', 'xmlscan-20050522', 'lib')
80   if File.exist?(xmlscansrcdir)
81     install_dir(xmlscansrcdir, 'xmlscan')
82   end
83
84   puts "install succeed!"
85
86 rescue
87   puts "install failed!"
88   puts $!
89
90 end
Note: See TracBrowser for help on using the browser.