install(src, dest, options = {})
public
Options: mode preserve noop verbose
If src is not same as dest, copies it and changes the
permission mode to mode. If dest is a directory,
destination is dest/src. This method removes destination before copy.
FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
Show source
def install(src, dest, options = {})
fu_check_options options, OPT_TABLE['install']
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
return if options[:noop]
fu_each_src_dest(src, dest) do |s, d|
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
st = File.stat(s) if options[:preserve]
copy_file s, d
File.utime st.atime, st.mtime, d if options[:preserve]
File.chmod options[:mode], d if options[:mode]
end
end
end