Class: Inspec::Resources::AlpinePkg

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

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



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/inspec/resources/package.rb', line 321

def info(package_name)
  cmd = inspec.command("apk info -vv --no-network | grep #{package_name}")
  return {} if cmd.exit_status.to_i != 0

  pkg_info = cmd.stdout.split("\n").delete_if { |e| e =~ /^WARNING/i }
  pkg = pkg_info[0].split(" - ")[0]

  version = pkg.partition("-")[2]
  {
    name: pkg.partition("-")[0],
    installed: true,
    version: version,
    type: "pkg",
    only_version_no: fetch_version_no(version),
  }
end

#latest_version(package_name) ⇒ Object



338
339
340
341
# File 'lib/inspec/resources/package.rb', line 338

def latest_version(package_name)
  cmd_string = "apk info #{package_name}"
  fetch_latest_version(cmd_string)
end