# File lib/fpm/util.rb, line 275
  def tar_cmd
    return @@tar_cmd if defined? @@tar_cmd

    # FIXME: don't assume current directory writeable
    FileUtils.touch(["fpm-dummy.tmp"])

    # Prefer tar that supports more of the features we want, stop if we find tar of our dreams
    best="tar"
    bestscore=0
    @@tar_cmd_deterministic = false
    # GNU Tar, if not the default, is usually on the path as gtar, but
    # Mac OS X 10.8 and earlier shipped it as /usr/bin/gnutar
    ["tar", "gtar", "gnutar"].each do |tar|
      opts=[]
      score=0
      ["--sort=name", "--mtime=@0"].each do |opt|
        system("#{tar} #{opt} -cf fpm-dummy.tar.tmp fpm-dummy.tmp > /dev/null 2>&1")
        if $?.exitstatus == 0
          opts << opt
          score += 1
        end
      end
      if score > bestscore
        best=tar
        bestscore=score
        if score == 2
          @@tar_cmd_deterministic = true
          break
        end
      end
    end
    @@tar_cmd = best
    return @@tar_cmd
  ensure
    # Clean up
    FileUtils.rm_f(["fpm-dummy.tar.tmp", "fpm-dummy.tmp"])
  end