lib/linux_admin/yum.rb in linux_admin-0.14.0 vs lib/linux_admin/yum.rb in linux_admin-0.15.0
- old
+ new
@@ -1,12 +1,10 @@
require 'fileutils'
require 'inifile'
module LinuxAdmin
class Yum
- extend Common
-
def self.create_repo(path, options = {})
raise ArgumentError, "path is required" unless path
options = options.reverse_merge(:database => true, :unique_file_names => true)
FileUtils.mkdir_p(path)
@@ -14,11 +12,11 @@
cmd = "createrepo"
params = {nil => path}
params["--database"] = nil if options[:database]
params["--unique-md-filenames"] = nil if options[:unique_file_names]
- run!(cmd, :params => params)
+ Common.run!(cmd, :params => params)
end
def self.download_packages(path, packages, options = {})
raise ArgumentError, "path is required" unless path
raise ArgumentError, "packages are required" unless packages
@@ -32,22 +30,22 @@
end
params = {"-p" => path}
params["-a"] = options[:arch] if options[:arch]
params[nil] = packages
- run!(cmd, :params => params)
+ Common.run!(cmd, :params => params)
end
def self.repo_settings
self.parse_repo_dir("/etc/yum.repos.d")
end
def self.updates_available?(*packages)
cmd = "yum check-update"
params = {nil => packages} unless packages.blank?
- exitstatus = run(cmd, :params => params).exit_status
+ exitstatus = Common.run(cmd, :params => params).exit_status
case exitstatus
when 0; false
when 100; true
else raise "Error: Exit Code #{exitstatus}"
end
@@ -55,11 +53,11 @@
def self.update(*packages)
cmd = "yum -y update"
params = {nil => packages} unless packages.blank?
- out = run!(cmd, :params => params)
+ out = Common.run!(cmd, :params => params)
# Handle errors that exit 0 https://bugzilla.redhat.com/show_bug.cgi?id=1141318
raise AwesomeSpawn::CommandResultError.new(out.error, out) if out.error.include?("No Match for argument")
out
@@ -69,11 +67,11 @@
raise ArgumentError, "packages requires at least one package name" if packages.blank?
cmd = "repoquery --qf=\"%{name} %{version}\""
params = {nil => packages}
- out = run!(cmd, :params => params).output
+ out = Common.run!(cmd, :params => params).output
out.split("\n").each_with_object({}) do |i, versions|
name, version = i.split(" ", 2)
versions[name.strip] = version.strip
end
@@ -82,10 +80,10 @@
def self.repo_list(scope = "enabled")
# Scopes could be "enabled", "all"
cmd = "yum repolist"
params = {nil => scope}
- output = run!(cmd, :params => params).output
+ output = Common.run!(cmd, :params => params).output
parse_repo_list_output(output)
end
private