remove_destination
どうもスルーされてしまったようだ。私の書いた恥ずかしいコード(?)を駆逐できるので、いつかもう一度メールしてみよう。
#いらない改行が入ってしまうかも。ていうかメールのアーカイブへのリンクでいいんじゃないか。
Index: Makefile.in =================================================================== RCS file: /src/ruby/Makefile.in,v retrieving revision 1.55.2.15 diff -u -r1.55.2.15 Makefile.in --- Makefile.in 8 Aug 2006 02:37:43 -0000 1.55.2.15 +++ Makefile.in 9 Aug 2006 17:52:55 -0000 @@ -85,7 +85,6 @@ OBJEXT = @OBJEXT@ MANTYPE = @MANTYPE@ -PREINSTALL = @PREINSTALL@ #### End of variables all: Index: configure.in =================================================================== RCS file: /src/ruby/configure.in,v retrieving revision 1.212.2.60 diff -u -r1.212.2.60 configure.in --- configure.in 8 Aug 2006 02:37:43 -0000 1.212.2.60 +++ configure.in 9 Aug 2006 17:52:56 -0000 @@ -1449,9 +1449,6 @@ esac MINIOBJS=dmydln.o ;; - aix*) - PREINSTALL='@$(RM) -r $(prefix)/lib/$(LIBRUBY_A) $(prefix)/lib/$(LIBRUBY_SO) $(prefix)/lib/ruby/$(MAJOR).$(MINOR)/$(arch)' - ;; *) ;; esac @@ -1484,7 +1481,6 @@ AC_SUBST(COMMON_HEADERS) AC_SUBST(EXPORT_PREFIX) AC_SUBST(MINIOBJS) -AC_SUBST(PREINSTALL) MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`" MAKEFILES="`echo $MAKEFILES`" Index: ext/extmk.rb =================================================================== RCS file: /src/ruby/ext/extmk.rb,v retrieving revision 1.44.2.29 diff -u -r1.44.2.29 extmk.rb --- ext/extmk.rb 21 Jul 2006 03:12:44 -0000 1.44.2.29 +++ ext/extmk.rb 9 Aug 2006 17:52:56 -0000 @@ -386,7 +386,7 @@ unless $destdir.empty? dest.sub!($dest_prefix_pattern, Config.expand($destdir.dup)) end - FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun) + FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun, :remove_destination => true) exit end unless $ignore Index: lib/fileutils.rb =================================================================== RCS file: /src/ruby/lib/fileutils.rb,v retrieving revision 1.36.2.16 diff -u -r1.36.2.16 fileutils.rb --- lib/fileutils.rb 18 Feb 2006 03:23:15 -0000 1.36.2.16 +++ lib/fileutils.rb 9 Aug 2006 17:52:56 -0000 @@ -392,7 +392,7 @@ OPT_TABLE['copy'] = %w( noop verbose preserve ) # - # Options: preserve noop verbose dereference_root + # Options: preserve noop verbose dereference_root remove_destination # # Copies +src+ to +dest+. If +src+ is a directory, this method copies # all its contents recursively. If +dest+ is a directory, copies @@ -415,17 +415,17 @@ # # but this doesn't. # def cp_r(src, dest, options = {}) - fu_check_options options, :preserve, :noop, :verbose, :dereference_root - fu_output_message "cp -r#{options[:preserve] ? 'p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose] + fu_check_options options, :preserve, :noop, :verbose, :dereference_root, :remove_destination + fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose] return if options[:noop] options[:dereference_root] = true unless options.key?(:dereference_root) fu_each_src_dest(src, dest) do |s, d| - copy_entry s, d, options[:preserve], options[:dereference_root] + copy_entry s, d, options[:preserve], options[:dereference_root], options[:remove_destination] end end module_function :cp_r - OPT_TABLE['cp_r'] = %w( noop verbose preserve dereference_root ) + OPT_TABLE['cp_r'] = %w( noop verbose preserve dereference_root remove_destination) # # Copies a file system entry +src+ to +dest+. @@ -441,9 +441,13 @@ # # If +dereference_root+ is true, this method dereference tree root. # - def copy_entry(src, dest, preserve = false, dereference_root = false) + # If +remove_destination+ is true, this method removes each destination file before copy. + # + + def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false) Entry_.new(src, nil, dereference_root).traverse do |ent| destent = Entry_.new(dest, ent.rel, false) + File.unlink destent.path if remove_destination && File.file?(destent.path) ent.copy destent.path ent.copy_metadata destent.path if preserve end