1 # $Id: installer.rb 585 2003-07-21 03:46:50Z icculus $
11 def initialize target_dir = "", &user_skip
12 @user_skip = user_skip or proc {|f| false}
14 @version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
15 @libdir = File.join(CONFIG["libdir"], "ruby", @version)
16 @sitedir = CONFIG["sitedir"] || File.join(@libdir, "site_ruby")
17 @dest = File.join @sitedir, target_dir
20 File::chmod 0755, @dest, true
25 file[0] == ?. or file[-1] == ?~ or file[-1] == ?#
29 File::makedirs(File.join(@dest, dir))
30 File::chmod(0755, File.join(@dest, dir), true)
31 Dir.foreach(dir) {|file|
34 if File.ftype(File.join(dir, file)) == "directory"
35 install_dir File.join(dir, file)
37 install_file File.join(dir, file)
46 File::install file, File.join(@dest, file), 0644, true
51 File::install file, File.join(CONFIG["sitearchdir"], file), 0644, true
55 file = File.join(CONFIG["sitearchdir"], file)
56 File::safe_unlink file
63 install x if x.is_a? String
66 if File.ftype(something) == "directory"
69 install_file something
74 def uninstall what = "*"
77 files = what.map {|x| File.join(@dest, x)}
79 files = Dir[File.join(@dest, what)]
83 # FIXME: recursive uninstall is a must
84 next if FileTest.directory? x
90 if !argv.grep(/--uninstall/).empty?
101 $stderr.puts "Installing slimb installer..."
102 Slimb::Installer.new("slimb").install File.basename(__FILE__)