Sha256: d7e019bbd74e6d7c36b434e1fb3b88e3839c888a56430dd25c1847bcf7c4aef1

Contents?: true

Size: 690 Bytes

Versions: 6

Compression:

Stored size: 690 Bytes

Contents

Ohai.plugin(:PkgDeps) do
  provides 'pkg_deps'
  depends 'platform_family'

  def from_cmd(cmd)
    so = shell_out(cmd)
    so.stdout.lines
  end

  def all_packages
    if %w{debian}.include? platform_family
      from_cmd("dpkg-query -W")
    end
  end

  def extract_dependecies(pkg)
    pkg_infos = from_cmd("apt-cache showpkg #{pkg}")
    pkg_infos.keep_if { |item| item.strip!.match(/^Depends:/)}
    pkg_infos.each { |item| item.slice!("Depends: ") }
  end

  collect_data(:linux) do
    pkg_deps Mash.new
    if %w{debian}.include? platform_family
      all_packages.each do |pkg|
        pkg_deps[pkg.split.first] = extract_dependecies(pkg.split.first)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cupper-0.2.1 lib/cupper/plugins/ohai/pkg_deps.rb
cupper-0.2.0 lib/cupper/plugins/ohai/pkg_deps.rb
cupper-0.1.3 lib/cupper/plugins/ohai/pkg_deps.rb
cupper-0.1.2 lib/cupper/plugins/ohai/pkg_deps.rb
cupper-0.1.1 lib/cupper/plugins/ohai/pkg_deps.rb
cupper-0.1.0 lib/cupper/plugins/ohai/pkg_deps.rb