install.rb

Path: install.rb
Last Update: Sun Mar 09 03:43:55 +0900 2008

Required files

rbconfig   find   fileutils   optparse  

Methods

Included Modules

Config

Constants

OPTS = {}

Public Instance methods

Install a binary file. We patch in on the way through to insert a #! line. If this is a Unix install, we name the command (for example) ‘rdoc’ and let the shebang line handle running it. Under windows, we add a ’.rb’ extension and let file associations to their stuff

[Source]

    # File install.rb, line 18
18: def installBIN(from, opfile)
19: 
20:   tmp_dir = nil
21:   [".", "/tmp", "c:/temp", $bindir].each{|t|
22:     stat = File.stat(t) rescue next
23:     if stat.directory? and stat.writable?
24:       tmp_dir = t
25:       break
26:     end
27:   }
28: 
29:   fail "Cannot find a temporary directory" unless tmp_dir
30:   tmp_file = File.join(tmp_dir, "_tmp")
31:     
32:     
33:   File.open(from) do |ip|
34:     File.open(tmp_file, "w") do |op|
35:       ruby = File.join($realbindir, $ruby)
36: #      op.puts "#!#{ruby}"
37:       op.write ip.read
38:     end
39:   end
40: 
41:   opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i
42:   FileUtils::makedirs($bindir, {:verbose => true})
43:   FileUtils::install(tmp_file, File.join($bindir, opfile), 
44:                      {:mode => 0755, :verbose => true})
45:   FileUtils::safe_unlink(tmp_file)
46: end

[Validate]