Class: Inspec::Resources::Rpms

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

Overview

RedHat family

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



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/inspec/resources/packages.rb', line 99

def build_package_list
  # use two spaces as delimiter in case any of the fields has a space in it
  command = "rpm -qa --queryformat '%{NAME}  %{VERSION}-%{RELEASE}  %{ARCH}\\n'" # rubocop:disable Style/FormatStringToken
  cmd = inspec.command(command)
  all = cmd.stdout.split("\n")
  return [] if all.nil?

  all.map do |m|
    a = m.split("  ")
    a.unshift("installed")
    PackageStruct.new(*a)
  end
end