| Path: | install.rb |
| Last Update: | Thu Aug 10 17:31:30 JST 2006 |
| OPTS | = | {} |
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
# File install.rb, line 18
18: def installBIN(from, opfile)
19:
20: tmp_dir = nil
21: for t in [".", "/tmp", "c:/temp", $bindir]
22: stat = File.stat(t) rescue next
23: if stat.directory? and stat.writable?
24: tmp_dir = t
25: break
26: end
27: end
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: File::install(tmp_file, File.join($bindir, opfile), 0755, true)
43: File::unlink(tmp_file)
44: end