lib/fpm/package/dir.rb
# Copy a path.
#
# Files will be hardlinked if possible, but copied otherwise.
# Symlinks should be copied as symlinks.
Copy a path.
Files will be hardlinked if possible, but copied otherwise.
Symlinks should be copied as symlinks.
Copy a path . Files will be hardlinked if possible but copied otherwise . Symlinks should be copied as symlinks .
def copy(source, destination)
    directory = File.dirname(destination)
    if !File.directory?(directory)
      FileUtils.mkdir_p(directory)
    end
    if File.directory?(source)
      if !File.symlink?(source)
        @logger.debug("Creating", :directory => destination)
        if !File.directory?(destination)
          FileUtils.mkdir(destination)
        end
      else
        @logger.debug("Copying symlinked directory", :source => source,
                      :destination => destination)
        FileUtils.copy_entry(source, destination)
      end
    else
      begin
        @logger.debug("Linking", :source => source, :destination => destination)
        File.link(source, destination)
      rescue Errno::EXDEV, Errno::EPERM
        @logger.debug("Copying", :source => source, :destination => destination)
        FileUtils.copy_entry(source, destination)
      end
    end
    copy_metadata(source, destination)
  end
def copy ( source , destination ) directory = File . dirname ( destination ) if ! File . directory? ( directory ) FileUtils . mkdir_p ( directory ) end if File . directory? ( source ) if ! File . symlink? ( source ) @logger . debug ( "Creating" , :directory => destination ) if ! File . directory? ( destination ) FileUtils . mkdir ( destination ) end else @logger . debug ( "Copying symlinked directory" , :source => source , :destination => destination ) FileUtils . copy_entry ( source , destination ) end else begin @logger . debug ( "Linking" , :source => source , :destination => destination ) File . link ( source , destination ) rescue Errno :: EXDEV , Errno :: EPERM @logger . debug ( "Copying" , :source => source , :destination => destination ) FileUtils . copy_entry ( source , destination ) end end copy_metadata ( source , destination ) end
Copy a path.
Copy a path .
# Create a directory if this path is a directory # Linking symlinked directories causes a hardlink to be created, which # results in the source directory being wiped out during cleanup, # so copy the symlink. # Otherwise try copying the file. # Hardlink attempt failed, copy it instead
source
<not_specific>
destination
<not_specific>