diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/extmk.rb | 2 | ||||
-rw-r--r-- | lib/fileutils.rb | 13 |
3 files changed, 18 insertions, 6 deletions
@@ -1,3 +1,12 @@ +Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org> + + * lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination + option. + + * ext/extmk.rb: use :remove_destination to install extension libraries + to avoid SEGV. + [ruby-dev:28417] + Fri Mar 3 14:41:04 2006 Minero Aoki <aamine@loveruby.net> * ext/dl/.cvsignore: ignore callback.h. diff --git a/ext/extmk.rb b/ext/extmk.rb index 8daf3ae38f..93f9a2fccd 100644 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -381,7 +381,7 @@ if $extout RbConfig.expand(extout = "#$extout", RbConfig::CONFIG.merge("topdir"=>$topdir)) if $install RbConfig.expand(dest = "#{$destdir}#{$rubylibdir}") - FileUtils.cp_r(extout+"/.", dest, :verbose => true, :noop => $dryrun) + FileUtils.cp_r(extout+"/.", dest, :remove_destination => true, :verbose => true, :noop => $dryrun) exit end unless $ignore diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 3e7989a287..d45c6767a2 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -392,7 +392,7 @@ module FileUtils 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,11 +415,11 @@ module FileUtils # # 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] 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 @@ -440,9 +440,12 @@ module FileUtils # # 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 |