Class: Puppet::ModuleTool::Tar::Mini Private
- Defined in:
- lib/puppet/module_tool/tar/mini.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
Instance Method Details
#pack(sourcedir, destfile) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/module_tool/tar/mini.rb', line 34 def pack(sourcedir, destfile) Zlib::GzipWriter.open(destfile) do |writer| Archive::Tar::Minitar.pack(sourcedir, writer) do |step, name, stats| # TODO smcclellan 2017-10-31 Set permissions here when this yield block # executes before the header is written. As it stands, the `stats` # argument isn't mutable in a way that will effect the desired mode for # the file. end end end |
#unpack(sourcefile, destdir, _) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/module_tool/tar/mini.rb', line 4 def unpack(sourcefile, destdir, _) Zlib::GzipReader.open(sourcefile) do |reader| # puppet doesn't have a hard dependency on minitar, so we # can't be certain which version is installed. If it's 0.9 # or above then we can prevent minitar from fsync'ing each # extracted file and directory, otherwise fallback to the # old behavior args = [reader, destdir, find_valid_files(reader)] spec = Gem::Specification.find_by_name('minitar') if spec && spec.version >= Gem::Version.new('0.9') args << { :fsync => false } end Archive::Tar::Minitar.unpack(*args) do |action, name, stats| case action when :dir validate_entry(destdir, name) set_dir_mode!(stats) Puppet.debug("Extracting: #{destdir}/#{name}") when :file_start # Octal string of the old file mode. validate_entry(destdir, name) set_file_mode!(stats) Puppet.debug("Extracting: #{destdir}/#{name}") end set_default_user_and_group!(stats) stats end end end |