class Chef::Resource::ArchiveFile

def archive_differs_from_disk?(src, dest)

Returns:
  • (Boolean) -

Parameters:
  • dest (String) --
  • src (String) --
def archive_differs_from_disk?(src, dest)
  modified = false
  archive = Archive::Reader.open_filename(src, nil, strip_components: new_resource.strip_components)
  Chef::Log.trace("Beginning the comparison of file mtime between contents of #{src} and #{dest}")
  archive.each_entry do |e|
    pathname = ::File.expand_path(e.pathname, dest)
    if ::File.exist?(pathname)
      Chef::Log.trace("#{pathname} mtime is #{::File.mtime(pathname)} and archive is #{e.mtime}")
      modified = true unless ::File.mtime(pathname) == e.mtime
    else
      Chef::Log.trace("#{pathname} doesn't exist on disk, but exists in the archive")
      modified = true
    end
  end
  modified
end

def define_resource_requirements

def define_resource_requirements
  if new_resource.mode.is_a?(Integer)
    Chef.deprecated(:archive_file_integer_file_mode, "The mode property should be passed to archive_file resources as a String and not an Integer to ensure the value is properly interpreted.")
  end
end

def extract(src, dest, options = [])

Returns:
  • (void) -

Parameters:
  • options (Array) --
  • dest (String) --
  • src (String) --
def extract(src, dest, options = [])
  converge_by("extract #{src} to #{dest}") do
    flags = [options].flatten.map { |option| extract_option_map[option] }.compact.reduce(:|)
    Dir.chdir(dest) do
      archive = Archive::Reader.open_filename(src, nil, strip_components: new_resource.strip_components)
      archive.each_entry do |e|
        archive.extract(e, flags.to_i)
      end
      archive.close
    end
  end
end

def extract_option_map

This can't be a constant since we might not have required 'ffi-libarchive' yet.
def extract_option_map
  {
    owner: Archive::EXTRACT_OWNER,
    permissions: Archive::EXTRACT_PERM,
    time: Archive::EXTRACT_TIME,
    no_overwrite: Archive::EXTRACT_NO_OVERWRITE,
    acl: Archive::EXTRACT_ACL,
    fflags: Archive::EXTRACT_FFLAGS,
    extended_information: Archive::EXTRACT_XATTR,
    xattr: Archive::EXTRACT_XATTR,
    no_overwrite_newer: Archive::EXTRACT_NO_OVERWRITE_NEWER,
  }
end