title: verify that an OS package is installed
body: <p>I need to verify that an OS package is installed after deploying using capistrano (it's a rails project, in case it matters). I'd like to support the major linux distros and OS X. Fortunately, the name of the package is the same on all platforms.</p>
  
  <p>I've thought adding a capistrano task, something like (untested code):</p>
  
  <pre><code>%w(yum apt-get brew).each do |manager|
    path = `which #{manager}`.chomp
    if path &amp;&amp; path.size &gt; 0
      `#{path} install -y #{PKG}`
      return
    end
  end
  </code></pre>
  
  <p>Inspired by <a href="https://unix.stackexchange.com/q/46081/52730">this question</a>.</p>
  
  <p>Is there a better way?
  I've thought checking <code>uname</code>, but it doesn't always have the distro, just "Linux". I also thought using <code>lsb_release</code> or listing files in <code>/etc/*-release</code>, but not all distros support it (e.g. centos).</p>