From: nobu.nakada@... Date: 2002-12-23T20:59:12+09:00 Subject: [ruby-dev:19167] Re: options to ext/extmk.rb and instruby.rb なかだです。 At Mon, 23 Dec 2002 19:54:41 +0900, WATANABE Hirofumi wrote: > > # install src dir [mode]って、どこのinstallの書式だろう。 > > ftoolsのinstallはmodeを省略できるように後に置いてあります。 > かなり強引ですが。 rm_rfとかln_sfを見て、基本的にコマンドとして使えるような出力を 意図してるのかと思ったんですが。 > > +mflags = $mflags.grep(/^-([^-].*)/) {$1}.join > > ああ、なるほど。これで--unixの件は対応できるのか。 とりあえず--option形式は放置ですが。 > 実際にインストールしてみると > ln -s libruby.so.1.7.3 /usr/local/lib/libruby.so.1.7 > /home/watanabe/src/ruby/lib/fileutils.rb:347:in `symlink': File exists - "libruby.so.1.7.3" (Errno::EEXIST) > のようにln_sfがエラーになってしまいました。 > trueじゃなくて:verboseじゃないといけないみたい。 あ、すいません。最初トップレベルで直接FileUtils::Verboseとかを includeするようにしてInstallerと一緒にtrueを消してしまったんで すが、Installerを戻したときにtrueまで復活させてしまいました。と いうことで、gsub(/, true/, '')です。Installerもやっぱりいらない かな。 というか、ln_sfを使ってるのに途中で:forceが消えてしまうのは FileUtilsのバグじゃないでしょうか。あとFile.symlinkのメッセージ もリンク先を出したほうが分かりやすいのでは。 Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.122 diff -u -2 -p -r1.122 file.c --- file.c 21 Dec 2002 18:02:00 -0000 1.122 +++ file.c 23 Dec 2002 11:54:49 -0000 @@ -1259,5 +1259,5 @@ rb_file_s_symlink(klass, from, to) if (symlink(RSTRING(from)->ptr, RSTRING(to)->ptr) < 0) - rb_sys_fail(RSTRING(from)->ptr); + rb_sys_fail(RSTRING(to)->ptr); return INT2FIX(0); #else Index: lib/fileutils.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/fileutils.rb,v retrieving revision 1.2 diff -u -2 -p -r1.2 fileutils.rb --- lib/fileutils.rb 17 Oct 2002 03:54:25 -0000 1.2 +++ lib/fileutils.rb 23 Dec 2002 11:53:39 -0000 @@ -592,5 +595,5 @@ module FileUtils def install( src, dest, mode, *options ) noop, verbose, = fu_parseargs(options, :noop, :verbose) - fu_output_message "install #{[src,dest].flatten.join ' '}#{mode ? ' %o'%mode : ''}" if verbose + fu_output_message "install#{mode ? ' -m %o'%mode : ''} #{[src,dest].flatten.join ' '}" if verbose return if noop @@ -743,5 +743,9 @@ module FileUtils @fileutils_verbose = true end - args.push :verbose if @fileutils_verbose + case args.last + when true, false + else + args.push :verbose if @fileutils_verbose + end super(*args) end Index: instruby.rb =================================================================== RCS file: /cvs/ruby/src/ruby/instruby.rb,v retrieving revision 1.32 diff -u -2 -p -r1.32 instruby.rb --- instruby.rb 22 Nov 2002 10:22:29 -0000 1.32 +++ instruby.rb 23 Dec 2002 11:33:22 -0000 @@ -4,54 +4,28 @@ load "./rbconfig.rb" include Config +$:.unshift File.join(CONFIG["srcdir"], "lib") +require 'fileutils' +require 'shellwords' + File.umask(0) while arg = ARGV.shift case arg - when /^--/ # ignore + when /^--make-flags=(.*)/ + Shellwords.shellwords($1).grep(/^-[^-]*n/) {break $dryrun = true} + when "-n" + $dryrun = true when /^-/ - $dryrun = /n/ =~ arg - when /=/ # ignore else destdir ||= arg - break end end destdir ||= '' -$:.unshift File.join(CONFIG["srcdir"], "lib") -require 'ftools' -require 'shellwords' - -class Installer < File; end -class << Installer - if $dryrun - def makedirs(*dirs) - String === dirs.last or dirs.pop - for dir in dirs - File.directory?(dir) or print "mkdir -p #{dir}\n" - end - end - def install(file, dir, mode = nil, verbose = false) - to = catname(file, dir) - unless FileTest.exist? to and cmp file, to - print "install#{' -m %#o'%mode if mode} #{file} #{dir}\n" - end - end - def makelink(orig, link, verbose = false) - unless File.symlink?(link) and File.readlink(link) == orig - print "ln -sf #{orig} #{link}\n" - end - end - else - require "ftools" - def makelink(orig, link, verbose = false) - if exist? link - delete link - end - symlink orig, link - print "link #{orig} -> #{link}\n" - end - end -end +include FileUtils::Verbose +include FileUtils::NoWrite if $dryrun +@fileutils_output = STDOUT +@fileutils_label = '' +alias makelink ln_sf exeext = CONFIG["EXEEXT"] @@ -74,18 +48,18 @@ lib = CONFIG["LIBRUBY"] arc = CONFIG["LIBRUBY_A"] -Installer.makedirs bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir, mandir, true +makedirs bindir, libdir, rubylibdir, archlibdir, sitelibdir, sitearchlibdir, mandir -Installer.install ruby_install_name+exeext, File.join(bindir, ruby_install_name+exeext), 0755, true +install ruby_install_name+exeext, File.join(bindir, ruby_install_name+exeext), 0755 if rubyw_install_name and !rubyw_install_name.empty? - Installer.install rubyw_install_name+exeext, bindir, 0755, true + install rubyw_install_name+exeext, bindir, 0755 end -Installer.install dll, bindir, 0755, true if enable_shared and dll != lib -Installer.install lib, libdir, 0555, true unless lib == arc -Installer.install arc, libdir, 0644, true -Installer.install "config.h", archlibdir, 0644, true -Installer.install "rbconfig.rb", archlibdir, 0644, true +install dll, bindir, 0755 if enable_shared and dll != lib +install lib, libdir, 0555 unless lib == arc +install arc, libdir, 0644 +install "config.h", archlibdir, 0644 +install "rbconfig.rb", archlibdir, 0644 if CONFIG["ARCHFILE"] for file in CONFIG["ARCHFILE"].split - Installer.install file, archlibdir, 0644, true + install file, archlibdir, 0644 end end @@ -93,5 +67,5 @@ end if dll == lib and dll != arc for link in CONFIG["LIBRUBY_ALIASES"].split - Installer.makelink(dll, File.join(libdir, link), true) + makelink(dll, File.join(libdir, link)) end end @@ -106,5 +80,5 @@ for src in Dir["bin/*"] dest = File.join(bindir, name) - Installer.install src, dest, 0755, true + install src, dest, 0755 open(dest, "r+") { |f| @@ -138,18 +112,17 @@ end Dir.glob("lib/**/*{.rb,help-message}") do |f| dir = File.dirname(f).sub!(/\Alib/, rubylibdir) || rubylibdir - Installer.makedirs dir, true unless File.directory? dir - Installer.install f, dir, 0644, true + makedirs dir unless File.directory? dir + install f, dir, 0644 end for f in Dir["*.h"] - Installer.install f, archlibdir, 0644, true + install f, archlibdir, 0644 end if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/ - Installer.makedirs File.join(archlibdir, "win32"), true - Installer.install "win32/win32.h", File.join(archlibdir, "win32"), 0644, true + makedirs File.join(archlibdir, "win32") + install "win32/win32.h", File.join(archlibdir, "win32"), 0644 end -Installer.makedirs mandir, true -Installer.install "ruby.1", File.join(mandir, ruby_install_name+".1"), 0644, true +install "ruby.1", File.join(mandir, ruby_install_name+".1"), 0644 # vi:set sw=2: -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦