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



263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/inspec/resources/package.rb', line 263

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]

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