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

root/tags/RELEASE_1_4_8_1/uninstall.rb

Revision 585, 1.8 kB (checked in by nahi, 6 years ago)

Supports installing/uninstalling from other dir.

  • 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 'rbconfig'
4 require 'ftools'
5
6 include Config
7
8 RV = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
9 DSTPATH = CONFIG["sitedir"] + "/" +  RV
10 SRCPATH = File.dirname( $0 )
11
12 def join( *arg )
13   File.join( *arg )
14 end
15
16 require join( SRCPATH, '_installedFiles' )
17 $installed = InstalledFiles.new( SRCPATH )
18
19 def uninstall( name, path )
20   filePath = join( path, File.basename( name ))
21   if FileTest.exist?( filePath )
22     target = InstalledFile.new( filePath )
23     if $installed.uninstall( target )
24       STDERR.puts "File: #{ target.path } uninstalled."
25     end
26   end
27 end
28
29 def uninstallDir( targetDir, from )
30   unless FileTest.directory?( targetDir )
31     raise RuntimeError.new( "'#{ targetDir }' not found." )
32   end
33   Dir[ join( targetDir, '*.rb' ) ].each do | name |
34     uninstall( name, from )
35   end
36 end
37
38 def delPath( dirPath )
39   entries = Dir.entries( dirPath )
40   entries.delete( "." )
41   entries.delete( ".." )
42
43   if entries.empty?
44     Dir.unlink( dirPath )
45   else
46     STDERR.puts "Directory: #{ dirPath } is not empty.  The directory is not removed."
47   end
48 end
49
50 begin
51   uninstallDir( join( SRCPATH, 'lib', 'soap' ), join( DSTPATH, 'soap' ))
52   uninstallDir( join( SRCPATH, 'lib', 'wsdl', 'soap' ),
53     join( DSTPATH, 'wsdl', 'soap' ))
54   uninstallDir( join( SRCPATH, 'lib', 'wsdl', 'xmlSchema' ),
55     join( DSTPATH, 'wsdl', 'xmlSchema' ))
56   uninstallDir( join( SRCPATH, 'lib', 'wsdl' ), join( DSTPATH, 'wsdl' ))
57   uninstallDir( join( SRCPATH, 'redist', 'soap' ), join( DSTPATH, 'soap' ))
58   uninstallDir( join( SRCPATH, 'redist' ), join( DSTPATH ))
59
60   delPath( join( DSTPATH, 'soap' ))
61   delPath( join( DSTPATH, 'wsdl', 'xmlSchema' ))
62   delPath( join( DSTPATH, 'wsdl', 'soap' ))
63   delPath( join( DSTPATH, 'wsdl' ))
64
65 #  $installed.dump( SRCPATH )
66
67   puts "uninstall succeed!"
68
69 rescue
70   puts "uninstall failed!"
71   puts $!
72
73 end
Note: See TracBrowser for help on using the browser.