class Mixlib::Archive::Tar

def create(files, gzip: false)

gzip:: should the archive be gzipped?
=== Parameters

Creates an archive with the given set of +files+
def create(files, gzip: false)
  tgt_dir = File.dirname(archive)
  target = Tempfile.new(File.basename(archive), tgt_dir)
  target.binmode
  Gem::Package::TarWriter.new(target) do |tar|
    files.each do |fn|
      mode = File.stat(fn).mode
      if File.symlink?(fn)
        target = File.readlink(fn)
        tar.add_symlink(fn, target, mode)
      elsif File.directory?(fn)
        tar.mkdir(fn, mode)
      elsif File.file?(fn)
        file = File.open(fn, "rb")
        tar.add_file(fn, mode) do |io|
          io.write(file.read)
        end
        file.close
      end
    end
  end
  target.close
  if gzip
    Zlib::GzipWriter.open(archive, Zlib::BEST_COMPRESSION) do |gz|
      gz.mtime = File.mtime(target.path)
      gz.orig_name = File.basename(archive)
      File.open(target.path) do |file|
        while (chunk = file.read(16 * 1024))
          gz.write(chunk)
        end
      end
    end
  else
    FileUtils.mv(target.path, archive)
  end
ensure
  target.close unless target.closed?
end