Sha256: 272848562e0cd1d3e6ac51e1ad4b4e1017d1321eeca24bc16250f555007d9a58

Contents?: true

Size: 1.83 KB

Versions: 10

Compression:

Stored size: 1.83 KB

Contents

# uninstall RMagick - called from Makefile uninstall target

require 'ftools'

class Dir
  def Dir.safe_unlink(dir)
    begin
      File.chmod 0777, dir
      unlink dir
      $stderr.puts dir
    rescue
    end
  end
end

# remove directory & contents if the directory was created by post-install.rb
def rmdir(dir, no_check=false)
  # This can 't happen, but you can never be too safe...
  if dir == '/' then
    raise RuntimeError, "rm -rf /? I don't think so!"
  end
  if no_check || File.file?(dir+'/.rmagick') then
    targets = Dir[dir+'/*']
    targets += Dir[dir+'/.*'].delete_if { |f| FileTest.directory?(f) }
    if not targets.empty?
        File.safe_unlink(*targets)
    end
    Dir.safe_unlink(dir)
  end
end

# Load up default values
rbconfig = 'rbconfig'

while arg = ARGV.shift
  case arg
    when /\A--rbconfig=(.*)\z/    # Get overriding rbconfig file name
      rbconfig = $1
    when /\A--prefix=(.*)\z/
      path = $1
      path = File.expand_path(path) unless path[0,1] == '/'
      prefix = path
    when /\A--site-ruby=(.*)\z/   # where RMagick.rb is
      site_ruby = $1
    when /\A--so-dir=(.*)\z/      # where RMagick.so is
      so_dir = $1
    when /\A--doc-dir=(.*)\z/     # where doc is
      doc_dir = $1
  end
end

require rbconfig                      # get specified/default rbconfig.rb

version = ::Config::CONFIG['MAJOR'] + '.' + ::Config::CONFIG['MINOR']
arch    = ::Config::CONFIG['arch']

prefix    ||= ::Config::CONFIG['prefix']
site_ruby ||= prefix+'/lib/ruby/site_ruby/'+version
so_dir    ||= prefix+'/lib/ruby/site_ruby/'+version+'/'+arch
doc_dir   ||= prefix+'/share/RMagick'

File.safe_unlink("#{site_ruby}/RMagick.rb", true)
File.safe_unlink("#{so_dir}/RMagick.so", true)

rmdir("#{site_ruby}/rvg", true)
rmdir(doc_dir+'/ex/images')
rmdir(doc_dir+'/ex')
rmdir(doc_dir+'/css')
rmdir(doc_dir+'/scripts')
rmdir(doc_dir)

exit

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rmagick-1.10.1 uninstall.rb
rmagick-1.10.0 uninstall.rb
rmagick-1.8.1 uninstall.rb
rmagick-1.8.0 uninstall.rb
rmagick-1.9.2 uninstall.rb
rmagick-1.8.3 uninstall.rb
rmagick-1.8.2 uninstall.rb
rmagick-1.9.0 uninstall.rb
rmagick-1.9.1 uninstall.rb
rmagick-1.9.3 uninstall.rb