Class: Inspec::Resources::Debs

Inherits:
PkgsManagement show all
Defined in:
lib/inspec/resources/packages.rb

Overview

Debian / Ubuntu

Instance Attribute Summary

Attributes inherited from PkgsManagement

#inspec

Instance Method Summary collapse

Methods inherited from PkgsManagement

#initialize

Constructor Details

This class inherits a constructor from Inspec::Resources::PkgsManagement

Instance Method Details

#build_package_listObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/inspec/resources/packages.rb', line 79

def build_package_list
  # use two spaces as delimiter in case any of the fields has a space in it
  command = "dpkg-query -W -f='${db:Status-Abbrev}  ${Package}  ${Version}  ${Architecture}\\n'"
  cmd = inspec.command(command)
  all = cmd.stdout.split("\n")
  return [] if all.nil?

  all.map do |m|
    a = m.split(/ {2,}/)
    a[0] = "installed" if a[0] =~ /^.i/
    a[2] = a[2].split(":").last
    PackageStruct.new(*a)
  end
end