Class: Inspec::Resources::Rpms

Inherits:
PkgsManagement show all
Defined in:
lib/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



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/resources/packages.rb', line 96

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