Class: Inspec::Resources::SolarisPkg

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

Overview

Solaris

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



441
442
443
444
445
446
447
# File 'lib/inspec/resources/package.rb', line 441

def info(package_name)
  if inspec.os[:release].to_i <= 10
    solaris10_info(package_name)
  else
    solaris11_info(package_name)
  end
end

#solaris10_info(package_name) ⇒ Object

solaris 10



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/inspec/resources/package.rb', line 450

def solaris10_info(package_name)
  cmd = inspec.command("pkginfo -l #{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

  # parse 11.10.0,REV=2006.05.18.01.46
  v = params["VERSION"].split(",")
  {
    name: params["PKGINST"],
    installed: true,
    version: v[0] + "-" + v[1].split("=")[1],
    type: "pkg",
  }
end

#solaris11_info(package_name) ⇒ Object

solaris 11



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/inspec/resources/package.rb', line 471

def solaris11_info(package_name)
  cmd = inspec.command("pkg info #{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,
    # 0.5.11-0.175.3.1.0.5.0
    version: "#{params["Version"]}-#{params["Branch"]}",
    type: "pkg",
  }
end