class Chef::Resource::ArchiveFile
Public Instance Methods
archive_differs_from_disk?(src, dest)
click to toggle source
try to determine if the resource has updated or not by checking for files that are in the archive, but not on disk or files with a non-matching mtime
@param [String] src @param [String] dest
@return [Boolean]
# File lib/chef/resource/archive_file.rb, line 165 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
define_resource_requirements()
click to toggle source
# File lib/chef/resource/archive_file.rb, line 137 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
extract(src, dest, options = [])
click to toggle source
extract the archive
@param [String] src @param [String] dest @param [Array] options
@return [void]
# File lib/chef/resource/archive_file.rb, line 189 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
extract_option_map()
click to toggle source
This can’t be a constant since we might not have required ‘ffi-libarchive’ yet.
# File lib/chef/resource/archive_file.rb, line 144 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