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

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/module_tool/tar/gnu.rb

Instance Method Summary collapse

Instance Method Details

#pack(sourcedir, destfile) ⇒ Object


16
17
18
# File 'lib/puppet/module_tool/tar/gnu.rb', line 16

def pack(sourcedir, destfile)
  Puppet::Util::Execution.execute("tar cf - #{sourcedir} | gzip -c > #{File.basename(destfile)}")
end

#unpack(sourcefile, destdir, owner) ⇒ Object


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

def unpack(sourcefile, destdir, owner)
  sourcefile = File.expand_path(sourcefile)
  destdir = File.expand_path(destdir)

  Dir.chdir(destdir) do
    Puppet::Util::Execution.execute("gzip -dc #{Shellwords.shellescape(sourcefile)} | tar xof -")
    Puppet::Util::Execution.execute("find . -type d -exec chmod 755 {} +")
    Puppet::Util::Execution.execute("find . -type f -exec chmod u+rw,g+r,a-st {} +")
    Puppet::Util::Execution.execute("chown -R #{owner} .")
  end
end