Class: Inspec::Resources::Rpm
- Inherits:
-
PkgManagement
- Object
- PkgManagement
- Inspec::Resources::Rpm
- Defined in:
- lib/resources/package.rb
Overview
RHEL family
Instance Attribute Summary
Attributes inherited from PkgManagement
Instance Method Summary collapse
Methods inherited from PkgManagement
Constructor Details
This class inherits a constructor from Inspec::Resources::PkgManagement
Instance Method Details
#info(package_name) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/resources/package.rb', line 103 def info(package_name) cmd = inspec.command("rpm -qia #{package_name}") # CentOS does not return an error code if the package is not installed, # therefore we need to check for emptyness return nil if cmd.exit_status.to_i != 0 || cmd.stdout.chomp.empty? params = SimpleConfig.new( cmd.stdout.chomp, assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/, multiple_values: false, ).params # On some (all?) systems, the linebreak before the vendor line is missing if params['Version'] =~ /\s*Vendor:/ v = params['Version'].split(' ')[0] else v = params['Version'] end # On some (all?) systems, the linebreak before the build line is missing if params['Release'] =~ /\s*Build Date:/ r = params['Release'].split(' ')[0] else r = params['Release'] end { name: params['Name'], installed: true, version: "#{v}-#{r}", type: 'rpm', } end |