PageRenderTime 79ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/ruby-1.9.3-p194/tool/rbinstall.rb

#
Ruby | 613 lines | 608 code | 4 blank | 1 comment | 1 complexity | 184ea4761b16460bee2a8ed8b31f0406 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-3.0, 0BSD, Unlicense
  1. #!./miniruby
  2. begin
  3. load "./rbconfig.rb"
  4. rescue LoadError
  5. CONFIG = Hash.new {""}
  6. else
  7. include RbConfig
  8. $".unshift File.expand_path("./rbconfig.rb")
  9. end
  10. srcdir = File.expand_path('../..', __FILE__)
  11. unless defined?(CROSS_COMPILING) and CROSS_COMPILING
  12. $:.replace([srcdir+"/lib", Dir.pwd])
  13. end
  14. require 'fileutils'
  15. require 'shellwords'
  16. require 'optparse'
  17. require 'optparse/shellwords'
  18. STDOUT.sync = true
  19. File.umask(0)
  20. def parse_args(argv = ARGV)
  21. $mantype = 'doc'
  22. $destdir = nil
  23. $extout = nil
  24. $make = 'make'
  25. $mflags = []
  26. $install = []
  27. $installed_list = nil
  28. $dryrun = false
  29. $rdocdir = nil
  30. $data_mode = 0644
  31. $prog_mode = 0755
  32. $dir_mode = nil
  33. $script_mode = nil
  34. $strip = false
  35. $cmdtype = (if File::ALT_SEPARATOR == '\\'
  36. File.exist?("rubystub.exe") ? 'exe' : 'bat'
  37. end)
  38. mflags = []
  39. opt = OptionParser.new
  40. opt.on('-n', '--dry-run') {$dryrun = true}
  41. opt.on('--dest-dir=DIR') {|dir| $destdir = dir}
  42. opt.on('--extout=DIR') {|dir| $extout = (dir unless dir.empty?)}
  43. opt.on('--make=COMMAND') {|make| $make = make}
  44. opt.on('--mantype=MAN') {|man| $mantype = man}
  45. opt.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
  46. if arg = v.first
  47. arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
  48. end
  49. $mflags.concat(v)
  50. end
  51. opt.on('-i', '--install=TYPE', $install_procs.keys) do |ins|
  52. $install << ins
  53. end
  54. opt.on('--data-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
  55. $data_mode = mode
  56. end
  57. opt.on('--prog-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
  58. $prog_mode = mode
  59. end
  60. opt.on('--dir-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
  61. $dir_mode = mode
  62. end
  63. opt.on('--script-mode=OCTAL-MODE', OptionParser::OctalInteger) do |mode|
  64. $script_mode = mode
  65. end
  66. opt.on('--installed-list [FILENAME]') {|name| $installed_list = name}
  67. opt.on('--rdoc-output [DIR]') {|dir| $rdocdir = dir}
  68. opt.on('--cmd-type=TYPE', %w[bat cmd plain]) {|cmd| $cmdtype = (cmd unless cmd == 'plain')}
  69. opt.on('--[no-]strip') {|strip| $strip = strip}
  70. opt.order!(argv) do |v|
  71. case v
  72. when /\AINSTALL[-_]([-\w]+)=(.*)/
  73. argv.unshift("--#{$1.tr('_', '-')}=#{$2}")
  74. when /\A\w[-\w+]*=\z/
  75. mflags << v
  76. when /\A\w[-\w+]*\z/
  77. $install << v.intern
  78. else
  79. raise OptionParser::InvalidArgument, v
  80. end
  81. end rescue abort "#{$!.message}\n#{opt.help}"
  82. unless defined?(RbConfig)
  83. puts opt.help
  84. exit
  85. end
  86. $make, *rest = Shellwords.shellwords($make)
  87. $mflags.unshift(*rest) unless rest.empty?
  88. $mflags.unshift(*mflags)
  89. def $mflags.set?(flag)
  90. grep(/\A-(?!-).*#{flag.chr}/i) { return true }
  91. false
  92. end
  93. def $mflags.defined?(var)
  94. grep(/\A#{var}=(.*)/) {return block_given? ? yield($1) : $1}
  95. false
  96. end
  97. if $mflags.set?(?n)
  98. $dryrun = true
  99. else
  100. $mflags << '-n' if $dryrun
  101. end
  102. $destdir ||= $mflags.defined?("DESTDIR")
  103. if $extout ||= $mflags.defined?("EXTOUT")
  104. RbConfig.expand($extout)
  105. end
  106. $continue = $mflags.set?(?k)
  107. if $installed_list ||= $mflags.defined?('INSTALLED_LIST')
  108. RbConfig.expand($installed_list, RbConfig::CONFIG)
  109. $installed_list = open($installed_list, "ab")
  110. $installed_list.sync = true
  111. end
  112. $rdocdir ||= $mflags.defined?('RDOCOUT')
  113. $dir_mode ||= $prog_mode | 0700
  114. $script_mode ||= $prog_mode
  115. end
  116. $install_procs = Hash.new {[]}
  117. def install?(*types, &block)
  118. $install_procs[:all] <<= block
  119. types.each do |type|
  120. $install_procs[type] <<= block
  121. end
  122. end
  123. def strip_file(file)
  124. if !defined?($strip_command) and (cmd = CONFIG["STRIP"])
  125. case cmd
  126. when "", "true", ":" then return
  127. else $strip_command = Shellwords.shellwords(cmd)
  128. end
  129. elsif !$strip_command
  130. return
  131. end
  132. system(*($strip_command + [file]))
  133. end
  134. def install(src, dest, options = {})
  135. options = options.clone
  136. strip = options.delete(:strip)
  137. options[:preserve] = true
  138. d = with_destdir(dest)
  139. super(src, d, options)
  140. if strip
  141. d = File.join(d, File.basename(src)) if $made_dirs[dest]
  142. strip_file(d)
  143. end
  144. if $installed_list
  145. dest = File.join(dest, File.basename(src)) if $made_dirs[dest]
  146. $installed_list.puts dest
  147. end
  148. end
  149. def ln_sf(src, dest)
  150. super(src, with_destdir(dest))
  151. $installed_list.puts dest if $installed_list
  152. end
  153. $made_dirs = {}
  154. def makedirs(dirs)
  155. dirs = fu_list(dirs)
  156. dirs.collect! do |dir|
  157. realdir = with_destdir(dir)
  158. realdir unless $made_dirs.fetch(dir) do
  159. $made_dirs[dir] = true
  160. $installed_list.puts(File.join(dir, "")) if $installed_list
  161. File.directory?(realdir)
  162. end
  163. end.compact!
  164. super(dirs, :mode => $dir_mode) unless dirs.empty?
  165. end
  166. FalseProc = proc {false}
  167. def path_matcher(pat)
  168. if pat and !pat.empty?
  169. proc {|f| pat.any? {|n| File.fnmatch?(n, f)}}
  170. else
  171. FalseProc
  172. end
  173. end
  174. def install_recursive(srcdir, dest, options = {})
  175. opts = options.clone
  176. noinst = opts.delete(:no_install)
  177. glob = opts.delete(:glob) || "*"
  178. subpath = (srcdir.size+1)..-1
  179. prune = []
  180. skip = []
  181. if noinst
  182. if Array === noinst
  183. prune = noinst.grep(/#{File::SEPARATOR}/o).map!{|f| f.chomp(File::SEPARATOR)}
  184. skip = noinst.grep(/\A[^#{File::SEPARATOR}]*\z/o)
  185. else
  186. if noinst.index(File::SEPARATOR)
  187. prune = [noinst]
  188. else
  189. skip = [noinst]
  190. end
  191. end
  192. end
  193. skip |= %w"#*# *~ *.old *.bak *.orig *.rej *.diff *.patch *.core"
  194. prune = path_matcher(prune)
  195. skip = path_matcher(skip)
  196. File.directory?(srcdir) or return rescue return
  197. paths = [[srcdir, dest, true]]
  198. found = []
  199. while file = paths.shift
  200. found << file
  201. file, d, dir = *file
  202. if dir
  203. files = []
  204. Dir.foreach(file) do |f|
  205. src = File.join(file, f)
  206. d = File.join(dest, dir = src[subpath])
  207. stat = File.stat(src) rescue next
  208. if stat.directory?
  209. files << [src, d, true] if /\A\./ !~ f and !prune[dir]
  210. else
  211. files << [src, d, false] if File.fnmatch?(glob, f) and !skip[f]
  212. end
  213. end
  214. paths.insert(0, *files)
  215. end
  216. end
  217. for src, d, dir in found
  218. if dir
  219. makedirs(d)
  220. else
  221. makedirs(d[/.*(?=\/)/m])
  222. if block_given?
  223. yield src, d, opts
  224. else
  225. install src, d, opts
  226. end
  227. end
  228. end
  229. end
  230. def open_for_install(path, mode)
  231. data = open(realpath = with_destdir(path), "rb") {|f| f.read} rescue nil
  232. newdata = yield
  233. unless $dryrun
  234. unless newdata == data
  235. open(realpath, "wb", mode) {|f| f.write newdata}
  236. end
  237. File.chmod(mode, realpath)
  238. end
  239. $installed_list.puts path if $installed_list
  240. end
  241. def with_destdir(dir)
  242. return dir if !$destdir or $destdir.empty?
  243. dir = dir.sub(/\A\w:/, '') if File::PATH_SEPARATOR == ';'
  244. $destdir + dir
  245. end
  246. def prepare(mesg, basedir, subdirs=nil)
  247. case
  248. when !subdirs
  249. dirs = basedir
  250. when subdirs.size == 0
  251. subdirs = nil
  252. when subdirs.size == 1
  253. dirs = [basedir = File.join(basedir, subdirs)]
  254. subdirs = nil
  255. else
  256. dirs = [basedir, *subdirs.collect {|dir| File.join(basedir, dir)}]
  257. end
  258. printf("installing %-18s %s%s\n", "#{mesg}:", basedir,
  259. (subdirs ? " (#{subdirs.join(', ')})" : ""))
  260. makedirs(dirs)
  261. end
  262. exeext = CONFIG["EXEEXT"]
  263. ruby_install_name = CONFIG["ruby_install_name"]
  264. rubyw_install_name = CONFIG["rubyw_install_name"]
  265. goruby_install_name = "go" + ruby_install_name
  266. bindir = CONFIG["bindir"]
  267. libdir = CONFIG["libdir"]
  268. archhdrdir = rubyhdrdir = CONFIG["rubyhdrdir"]
  269. archhdrdir += "/" + CONFIG["arch"]
  270. rubylibdir = CONFIG["rubylibdir"]
  271. archlibdir = CONFIG["archdir"]
  272. sitelibdir = CONFIG["sitelibdir"]
  273. sitearchlibdir = CONFIG["sitearchdir"]
  274. vendorlibdir = CONFIG["vendorlibdir"]
  275. vendorarchlibdir = CONFIG["vendorarchdir"]
  276. rubygemsdir = CONFIG["rubygemsdir"]
  277. mandir = CONFIG["mandir"]
  278. capidir = CONFIG["docdir"]
  279. configure_args = Shellwords.shellwords(CONFIG["configure_args"])
  280. enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
  281. dll = CONFIG["LIBRUBY_SO"]
  282. lib = CONFIG["LIBRUBY"]
  283. arc = CONFIG["LIBRUBY_A"]
  284. major = CONFIG["MAJOR"]
  285. minor = CONFIG["MINOR"]
  286. load_relative = configure_args.include?("--enable-load-relative")
  287. install?(:local, :arch, :bin, :'bin-arch') do
  288. prepare "binary commands", bindir
  289. install ruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
  290. if rubyw_install_name and !rubyw_install_name.empty?
  291. install rubyw_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
  292. end
  293. if File.exist? goruby_install_name+exeext
  294. install goruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
  295. end
  296. if enable_shared and dll != lib
  297. install dll, bindir, :mode => $prog_mode, :strip => $strip
  298. end
  299. end
  300. install?(:local, :arch, :lib) do
  301. prepare "base libraries", libdir
  302. install lib, libdir, :mode => $prog_mode, :strip => $strip unless lib == arc
  303. install arc, libdir, :mode => $data_mode
  304. if dll == lib and dll != arc
  305. for link in CONFIG["LIBRUBY_ALIASES"].split
  306. ln_sf(dll, File.join(libdir, link))
  307. end
  308. end
  309. prepare "arch files", archlibdir
  310. install "rbconfig.rb", archlibdir, :mode => $data_mode
  311. if CONFIG["ARCHFILE"]
  312. for file in CONFIG["ARCHFILE"].split
  313. install file, archlibdir, :mode => $data_mode
  314. end
  315. end
  316. end
  317. install?(:local, :arch, :data) do
  318. pc = CONFIG["ruby_pc"]
  319. if pc and File.file?(pc) and File.size?(pc)
  320. prepare "pkgconfig data", pkgconfigdir = File.join(libdir, "pkgconfig")
  321. install pc, pkgconfigdir, :mode => $data_mode
  322. end
  323. end
  324. install?(:ext, :arch, :'ext-arch') do
  325. prepare "extension objects", archlibdir
  326. noinst = %w[-* -*/] | (CONFIG["no_install_files"] || "").split
  327. install_recursive("#{$extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode, :strip => $strip)
  328. prepare "extension objects", sitearchlibdir
  329. prepare "extension objects", vendorarchlibdir
  330. end
  331. install?(:ext, :arch, :'ext-arch') do
  332. prepare "extension headers", archhdrdir
  333. install_recursive("#{$extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode)
  334. end
  335. install?(:ext, :comm, :'ext-comm') do
  336. prepare "extension scripts", rubylibdir
  337. install_recursive("#{$extout}/common", rubylibdir, :mode => $data_mode)
  338. prepare "extension scripts", sitelibdir
  339. prepare "extension scripts", vendorlibdir
  340. end
  341. install?(:ext, :comm, :'ext-comm') do
  342. hdrdir = rubyhdrdir + "/ruby"
  343. prepare "extension headers", hdrdir
  344. install_recursive("#{$extout}/include/ruby", hdrdir, :glob => "*.h", :mode => $data_mode)
  345. end
  346. install?(:doc, :rdoc) do
  347. if $rdocdir
  348. ridatadir = File.join([CONFIG['ridir'], RbConfig::CONFIG['USE_VERSIONED_PATHS'] == 'YES' ? version : nil, "system"].compact)
  349. prepare "rdoc", ridatadir
  350. install_recursive($rdocdir, ridatadir, :mode => $data_mode)
  351. end
  352. end
  353. install?(:doc, :capi) do
  354. prepare "capi-docs", capidir
  355. install_recursive "doc/capi", capidir, :mode => $data_mode
  356. end
  357. if load_relative
  358. PROLOG_SCRIPT = <<EOS
  359. #!/bin/sh\n# -*- ruby -*-
  360. bindir=`#{CONFIG["CHDIR"]} "${0%/*}" 2>/dev/null; pwd`
  361. EOS
  362. if CONFIG["LIBRUBY_RELATIVE"] != 'yes' and libpathenv = CONFIG["LIBPATHENV"]
  363. pathsep = File::PATH_SEPARATOR
  364. PROLOG_SCRIPT << <<EOS
  365. prefix="${bindir%/bin}"
  366. export #{libpathenv}="$prefix/lib${#{libpathenv}#{pathsep}+#{pathsep}$#{libpathenv}}"
  367. EOS
  368. end
  369. PROLOG_SCRIPT << %Q[exec "$bindir/#{ruby_install_name}" -x "$0" "$@"\n]
  370. else
  371. PROLOG_SCRIPT = nil
  372. end
  373. install?(:local, :comm, :bin, :'bin-comm') do
  374. prepare "command scripts", bindir
  375. ruby_shebang = File.join(bindir, ruby_install_name)
  376. if File::ALT_SEPARATOR
  377. ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
  378. if $cmdtype == 'exe'
  379. stub = File.open("rubystub.exe", "rb") {|f| f.read} << "\n" rescue nil
  380. end
  381. end
  382. if trans = CONFIG["program_transform_name"]
  383. exp = []
  384. trans.gsub!(/\$\$/, '$')
  385. trans.scan(%r[\G[\s;]*(/(?:\\.|[^/])*/)?([sy])(\\?\W)((?:(?!\3)(?:\\.|.))*)\3((?:(?!\3)(?:\\.|.))*)\3([gi]*)]) do
  386. |addr, cmd, sep, pat, rep, opt|
  387. addr &&= Regexp.new(addr[/\A\/(.*)\/\z/, 1])
  388. case cmd
  389. when 's'
  390. next if pat == '^' and rep.empty?
  391. exp << [addr, (opt.include?('g') ? :gsub! : :sub!),
  392. Regexp.new(pat, opt.include?('i')), rep.gsub(/&/){'\&'}]
  393. when 'y'
  394. exp << [addr, :tr!, Regexp.quote(pat), rep]
  395. end
  396. end
  397. trans = proc do |base|
  398. exp.each {|addr, opt, pat, rep| base.__send__(opt, pat, rep) if !addr or addr =~ base}
  399. base
  400. end
  401. elsif /ruby/ =~ ruby_install_name
  402. trans = proc {|base| ruby_install_name.sub(/ruby/, base)}
  403. else
  404. trans = proc {|base| base}
  405. end
  406. install_recursive(File.join(srcdir, "bin"), bindir) do |src, cmd|
  407. cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
  408. shebang = ''
  409. body = ''
  410. open(src, "rb") do |f|
  411. shebang = f.gets
  412. body = f.read
  413. end
  414. if PROLOG_SCRIPT
  415. shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
  416. else
  417. shebang.sub!(/\A\#!.*?ruby\b/) {"#!" + ruby_shebang}
  418. end
  419. shebang.sub!(/\r$/, '')
  420. body.gsub!(/\r$/, '')
  421. cmd << ".#{$cmdtype}" if $cmdtype
  422. open_for_install(cmd, $script_mode) do
  423. case $cmdtype
  424. when "exe"
  425. stub + shebang + body
  426. when "bat"
  427. [<<-"EOH".gsub(/^\s+/, ''), shebang, body, "__END__\n:endofruby\n"].join.gsub(/$/, "\r")
  428. @echo off
  429. @if not "%~d0" == "~d0" goto WinNT
  430. #{ruby_bin} -x "#{cmd}" %1 %2 %3 %4 %5 %6 %7 %8 %9
  431. @goto endofruby
  432. :WinNT
  433. "%~dp0#{ruby_install_name}" -x "%~f0" %*
  434. @goto endofruby
  435. EOH
  436. when "cmd"
  437. <<"/EOH" << shebang << body
  438. @"%~dp0#{ruby_install_name}" -x "%~f0" %*
  439. @exit /b %ERRORLEVEL%
  440. /EOH
  441. else
  442. shebang + body
  443. end
  444. end
  445. end
  446. end
  447. install?(:local, :comm, :lib) do
  448. prepare "library scripts", rubylibdir
  449. noinst = %w[README* *.txt *.rdoc]
  450. noinst += %w[*ubygems.rb rubygems/ datadir.rb] if rubygemsdir
  451. install_recursive(File.join(srcdir, "lib"), rubylibdir, :no_install => noinst, :mode => $data_mode)
  452. if rubygemsdir
  453. noinst = %w[obsolete.rb]
  454. install_recursive(File.join(srcdir, "lib", "rubygems"), File.join(rubygemsdir, "rubygems"), :mode => $data_mode)
  455. install_recursive(File.join(srcdir, "lib", "rbconfig"), File.join(rubygemsdir, "rbconfig"), :no_install => noinst, :mode => $data_mode)
  456. install(File.join(srcdir, "lib", "ubygems.rb"), File.join(rubygemsdir, "ubygems.rb"), :mode => $data_mode)
  457. install(File.join(srcdir, "lib", "rubygems.rb"), File.join(rubygemsdir, "rubygems.rb"), :mode => $data_mode)
  458. end
  459. end
  460. install?(:local, :arch, :lib) do
  461. prepare "common headers", rubyhdrdir
  462. noinst = []
  463. unless RUBY_PLATFORM =~ /mswin|mingw|bccwin/
  464. noinst << "win32.h"
  465. end
  466. noinst = nil if noinst.empty?
  467. install_recursive(File.join(srcdir, "include"), rubyhdrdir, :no_install => noinst, :glob => "*.h", :mode => $data_mode)
  468. end
  469. install?(:local, :comm, :man) do
  470. mdocs = Dir["#{srcdir}/man/*.[1-9]"]
  471. prepare "manpages", mandir, ([] | mdocs.collect {|mdoc| mdoc[/\d+$/]}).sort.collect {|sec| "man#{sec}"}
  472. mandir = File.join(mandir, "man")
  473. has_goruby = File.exist?(goruby_install_name+exeext)
  474. require File.join(srcdir, "tool/mdoc2man.rb") if $mantype != "doc"
  475. mdocs.each do |mdoc|
  476. next unless File.file?(mdoc) and open(mdoc){|fh| fh.read(1) == '.'}
  477. base = File.basename(mdoc)
  478. if base == "goruby.1"
  479. next unless has_goruby
  480. end
  481. destdir = mandir + (section = mdoc[/\d+$/])
  482. destname = ruby_install_name.sub(/ruby/, base.chomp(".#{section}"))
  483. destfile = File.join(destdir, "#{destname}.#{section}")
  484. if $mantype == "doc"
  485. install mdoc, destfile, :mode => $data_mode
  486. else
  487. class << (w = [])
  488. alias print push
  489. end
  490. open(mdoc) {|r| Mdoc2Man.mdoc2man(r, w)}
  491. open_for_install(destfile, $data_mode) {w.join("")}
  492. end
  493. end
  494. end
  495. install?(:ext, :comm, :gem) do
  496. $:.unshift(File.join(srcdir, "lib"))
  497. require("rubygems.rb")
  498. gem_dir = Gem.default_dir
  499. directories = Gem.ensure_gem_subdirectories(gem_dir)
  500. prepare "default gems", gem_dir, directories
  501. spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0])
  502. File.foreach(File.join(srcdir, "defs/default_gems")) do |line|
  503. line.chomp!
  504. line.sub!(/\s*#.*/, '')
  505. next if line.empty?
  506. words = []
  507. line.scan(/\G\s*([^\[\]\s]+|\[([^\[\]]*)\])/) do
  508. words << ($2 ? $2.split : $1)
  509. end
  510. name, src, execs = *words
  511. next unless name and src
  512. execs ||= []
  513. src = File.join(srcdir, src)
  514. version = open(src) {|f| f.find {|s| /^\s*\w*VERSION\s*=(?!=)/ =~ s}} or next
  515. version = version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
  516. full_name = "#{name}-#{version}"
  517. puts "#{" "*30}#{name} #{version}"
  518. open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
  519. <<-GEMSPEC
  520. Gem::Specification.new do |s|
  521. s.name = #{name.dump}
  522. s.version = #{version.dump}
  523. s.summary = "This #{name} is bundled with Ruby"
  524. s.executables = #{execs.inspect}
  525. end
  526. GEMSPEC
  527. end
  528. unless execs.empty? then
  529. bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
  530. makedirs(bin_dir)
  531. execs.each do |exec|
  532. exec = File.join(srcdir, 'bin', exec)
  533. install(exec, bin_dir, :mode => $prog_mode)
  534. end
  535. end
  536. end
  537. end
  538. parse_args()
  539. include FileUtils
  540. include FileUtils::NoWrite if $dryrun
  541. @fileutils_output = STDOUT
  542. @fileutils_label = ''
  543. $install << :local << :ext if $install.empty?
  544. $install.each do |inst|
  545. if !(procs = $install_procs[inst]) || procs.empty?
  546. next warn("unknown install target - #{inst}")
  547. end
  548. procs.each do |block|
  549. dir = Dir.pwd
  550. begin
  551. block.call
  552. ensure
  553. Dir.chdir(dir)
  554. end
  555. end
  556. end
  557. # vi:set sw=2: