Class: Inspec::Resources::Pacman

Inherits:
PkgManagement show all
Defined in:
lib/inspec/resources/package.rb

Overview

Arch Linux

Instance Attribute Summary

Attributes inherited from PkgManagement

#inspec

Instance Method Summary collapse

Methods inherited from PkgManagement

#initialize, #missing_requirements

Constructor Details

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

Instance Method Details

#info(package_name) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/inspec/resources/package.rb', line 280

def info(package_name)
  cmd = inspec.command("pacman -Qi #{package_name}")
  return {} if cmd.exit_status.to_i != 0

  params = SimpleConfig.new(
    cmd.stdout.chomp,
    assignment_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
    multiple_values: false
  ).params

  {
    name: params["Name"],
    installed: true,
    version: params["Version"],
    type: "pacman",
    only_version_no: fetch_version_no(params["Version"]),
  }
end

#latest_version(package_name) ⇒ Object



299
300
301
302
# File 'lib/inspec/resources/package.rb', line 299

def latest_version(package_name)
  cmd_string = "pacman -Ss #{package_name} | grep #{package_name} | grep installed"
  fetch_latest_version(cmd_string)
end