Class: Wright::Provider::Package::Yum

Inherits:
Wright::Provider::Package show all
Defined in:
lib/wright/provider/package/yum.rb

Overview

Yum package provider. Used as a provider for Resource::Package on Fedora-based systems.

Constant Summary

Constants inherited from Wright::Provider

Wright::Provider::PROVIDER_DIR

Instance Method Summary collapse

Methods inherited from Wright::Provider::Package

#install, #installed?, #package_name, #package_options, #package_version, #remove, #uptodate?

Methods inherited from Wright::Provider

#env, #exec_or_fail, #initialize, #unless_dry_run, #unless_uptodate, #updated?

Constructor Details

This class inherits a constructor from Wright::Provider

Instance Method Details

#install_packageObject (private)


22
23
24
# File 'lib/wright/provider/package/yum.rb', line 22

def install_package
  yum(:install, package_options, package_name, package_version)
end

#installed_versionsArray<String>

Returns the installed package versions.

Returns:

  • (Array<String>)

    the installed package versions


13
14
15
16
17
18
# File 'lib/wright/provider/package/yum.rb', line 13

def installed_versions
  version_format = '%{VERSION}-%{RELEASE}'
  rpm_args = %W(-q #{package_name} --qf #{version_format})
  stdout, _, status = Open3.capture3(env, 'rpm', *rpm_args)
  status.success? ? [stdout] : []
end

#remove_packageObject (private)


26
27
28
# File 'lib/wright/provider/package/yum.rb', line 26

def remove_package
  yum(:remove, package_options, package_name)
end

#yum(action, options, package, version = nil) ⇒ Object (private)


30
31
32
33
34
35
# File 'lib/wright/provider/package/yum.rb', line 30

def yum(action, options, package, version = nil)
  cmd = 'yum'
  package_version = version.nil? ? '' : "-#{version}"
  args = [*options, action.to_s, '-y', package + package_version]
  exec_or_fail(cmd, args, "cannot #{action} package '#{package}'")
end