Class: Puppet::ModuleTool::Tar::Gnu Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/module_tool/tar/gnu.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.



17
18
19
20
21
22
# File 'lib/puppet/module_tool/tar/gnu.rb', line 17

def pack(sourcedir, destfile)
  safe_sourcedir = Shellwords.shellescape(sourcedir)
  safe_destfile = Shellwords.shellescape(File.basename(destfile))

  Puppet::Util::Execution.execute("tar cf - #{safe_sourcedir} | gzip -c > #{safe_destfile}")
end

#unpack(sourcefile, destdir, owner) ⇒ 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.



6
7
8
9
10
11
12
13
14
15
# File 'lib/puppet/module_tool/tar/gnu.rb', line 6

def unpack(sourcefile, destdir, owner)
  safe_sourcefile = Shellwords.shellescape(File.expand_path(sourcefile))
  destdir = File.expand_path(destdir)
  safe_destdir = Shellwords.shellescape(destdir)

  Puppet::Util::Execution.execute("gzip -dc #{safe_sourcefile} | tar --extract --no-same-owner --directory #{safe_destdir} --file -")
  Puppet::Util::Execution.execute(['find', destdir, '-type', 'd', '-exec', 'chmod', '755', '{}', '+'])
  Puppet::Util::Execution.execute(['find', destdir, '-type', 'f', '-exec', 'chmod', 'u+rw,g+r,a-st', '{}', '+'])
  Puppet::Util::Execution.execute(['chown', '-R', owner, destdir])
end