Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 75 lines (62 sloc) 2.004 kb
d9b079a Initial revision
tim authored
1 # uninstall RMagick - called from Makefile uninstall target
2
3 require 'ftools'
4
5 class Dir
6 def Dir.safe_unlink(dir)
7 begin
8 File.chmod 0777, dir
9 unlink dir
10 $stderr.puts dir
11 rescue
12 end
13 end
14 end
15
16 # remove directory & contents if the directory was created by post-install.rb
af37056 Fixes for 1.8.0
rmagick authored
17 def rmdir(dir, no_check=false)
d9b079a Initial revision
tim authored
18 # This can 't happen, but you can never be too safe...
19 if dir == '/' then
20 raise RuntimeError, "rm -rf /? I don't think so!"
21 end
af37056 Fixes for 1.8.0
rmagick authored
22 if no_check || File.file?(dir+'/.rmagick') then
d9b079a Initial revision
tim authored
23 targets = Dir[dir+'/*']
271bdcd Properly delete .examples file so the ex/ directory can be deleted.
tim authored
24 targets += Dir[dir+'/.*'].delete_if { |f| FileTest.directory?(f) }
d9b079a Initial revision
tim authored
25 if not targets.empty?
26 File.safe_unlink(*targets)
27 end
28 Dir.safe_unlink(dir)
29 end
30 end
31
5ee052c Use File.join
rmagick authored
32
d9b079a Initial revision
tim authored
33 # Load up default values
34 rbconfig = 'rbconfig'
35
36 while arg = ARGV.shift
37 case arg
38 when /\A--rbconfig=(.*)\z/ # Get overriding rbconfig file name
39 rbconfig = $1
40 when /\A--prefix=(.*)\z/
41 path = $1
42 path = File.expand_path(path) unless path[0,1] == '/'
43 prefix = path
44 when /\A--site-ruby=(.*)\z/ # where RMagick.rb is
45 site_ruby = $1
46 when /\A--so-dir=(.*)\z/ # where RMagick.so is
47 so_dir = $1
48 when /\A--doc-dir=(.*)\z/ # where doc is
49 doc_dir = $1
50 end
51 end
52
53 require rbconfig # get specified/default rbconfig.rb
54
5ee052c Use File.join
rmagick authored
55 version = ::Config::CONFIG['ruby_version']
d9b079a Initial revision
tim authored
56 arch = ::Config::CONFIG['arch']
57
58 prefix ||= ::Config::CONFIG['prefix']
5ee052c Use File.join
rmagick authored
59 site_ruby ||= File.join(prefix, 'lib', 'ruby', 'site_ruby', version)
60 so_dir ||= File.join(prefix, 'lib', 'ruby', 'site_ruby', version, arch)
61 doc_dir ||= File.join(prefix, 'share', 'RMagick')
9670daf Use Config::CONFIG['DLEXT'] instead of 'so'
rmagick authored
62 dlext = ::Config::CONFIG['DLEXT']
d9b079a Initial revision
tim authored
63
5ee052c Use File.join
rmagick authored
64 File.safe_unlink File.join(site_ruby, 'RMagick.rb'), true
9670daf Use Config::CONFIG['DLEXT'] instead of 'so'
rmagick authored
65 File.safe_unlink File.join(so_dir, 'RMagick.' + dlext), true
d9b079a Initial revision
tim authored
66
5ee052c Use File.join
rmagick authored
67 rmdir File.join(site_ruby, 'rvg'), true
68 rmdir File.join(doc_dir, 'ex', 'images')
69 rmdir File.join(doc_dir, 'ex')
70 rmdir File.join(doc_dir, 'css')
71 rmdir File.join(doc_dir, 'scripts')
72 rmdir doc_dir
d9b079a Initial revision
tim authored
73
74 exit
Something went wrong with that request. Please try again.