Module: Kanrisuru::Core::Yum

Extended by:
OsPackage::Define
Defined in:
lib/kanrisuru/core/yum.rb,
lib/kanrisuru/core/yum/types.rb,
lib/kanrisuru/core/yum/commands.rb,
lib/kanrisuru/core/yum/parsers/base.rb,
lib/kanrisuru/core/yum/parsers/info.rb,
lib/kanrisuru/core/yum/parsers/list.rb,
lib/kanrisuru/core/yum/commands/info.rb,
lib/kanrisuru/core/yum/commands/list.rb,
lib/kanrisuru/core/yum/commands/clean.rb,
lib/kanrisuru/core/yum/commands/erase.rb,
lib/kanrisuru/core/yum/parsers/search.rb,
lib/kanrisuru/core/yum/commands/remove.rb,
lib/kanrisuru/core/yum/commands/search.rb,
lib/kanrisuru/core/yum/commands/update.rb,
lib/kanrisuru/core/yum/commands/install.rb,
lib/kanrisuru/core/yum/commands/upgrade.rb,
lib/kanrisuru/core/yum/parsers/repolist.rb,
lib/kanrisuru/core/yum/commands/repolist.rb,
lib/kanrisuru/core/yum/commands/autoremove.rb,
lib/kanrisuru/core/yum/commands/localinstall.rb

Defined Under Namespace

Modules: Parser Classes: PackageDetail, PackageOverview, PackageSearchResult, Repolist

Instance Method Summary collapse

Methods included from OsPackage::Define

extended, os_define

Instance Method Details

#yum(action, opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kanrisuru/core/yum.rb', line 16

def yum(action, opts = {})
  case action
  when 'install'
    yum_install(opts)
  when 'localinstall'
    yum_localinstall(opts)
  when 'list'
    yum_list(opts)
  when 'search'
    yum_search(opts)
  when 'info'
    yum_info(opts)
  when 'repolist'
    yum_repolist(opts)
  when 'clean'
    yum_clean(opts)
  when 'remove'
    yum_remove(opts)
  when 'autoremove'
    yum_autoremove(opts)
  when 'erase'
    yum_erase(opts)
  when 'update'
    yum_update(opts)
  when 'upgrade'
    yum_upgrade(opts)
  end
end

#yum_autoremove(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/yum/commands/autoremove.rb', line 6

def yum_autoremove(_opts)
  command = Kanrisuru::Command.new('yum autoremove')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#yum_clean(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kanrisuru/core/yum/commands/clean.rb', line 6

def yum_clean(opts)
  command = Kanrisuru::Command.new('yum clean')

  command.append_flag('dbcache', opts[:dbcache])
  command.append_flag('expire-cache', opts[:expire_cache])
  command.append_flag('metadata', opts[:metadata])
  command.append_flag('packages', opts[:packages])
  command.append_flag('headers', opts[:headers])
  command.append_flag('rpmdb', opts[:rpmdb])
  command.append_flag('all', opts[:all])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#yum_erase(opts) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kanrisuru/core/yum/commands/erase.rb', line 6

def yum_erase(opts)
  command = Kanrisuru::Command.new('yum erase')
  command.append_flag('-y')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  raise ArgumentError, "can't erase yum" if packages.include?('yum')

  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#yum_info(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kanrisuru/core/yum/commands/info.rb', line 6

def yum_info(opts)
  command = Kanrisuru::Command.new('yum info')
  command.append_flag('--quiet')
  command.append_flag('installed', opts[:installed])

  command << Kanrisuru::Util.array_join_string(opts[:packages], ' ') if opts[:packages]

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::Info.parse(cmd)
  end
end

#yum_install(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/kanrisuru/core/yum/commands/install.rb', line 6

def yum_install(opts)
  command = Kanrisuru::Command.new('yum install')
  command.append_flag('-y')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#yum_list(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kanrisuru/core/yum/commands/list.rb', line 6

def yum_list(opts)
  command = Kanrisuru::Command.new('yum list')

  yum_disable_repo(command, opts[:disable_repo])

  command.append_flag('all', opts[:all])
  command.append_flag('available', opts[:available])
  command.append_flag('updates', opts[:updates])
  command.append_flag('installed', opts[:installed])
  command.append_flag('extras', opts[:extras])
  command.append_flag('obsoletes', opts[:obsoletes])

  command << opts[:query] if Kanrisuru::Util.present?(opts[:query])

  pipe_output_newline(command)

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::List.parse(cmd)
  end
end

#yum_localinstall(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kanrisuru/core/yum/commands/localinstall.rb', line 6

def yum_localinstall(opts)
  command = Kanrisuru::Command.new('yum localinstall')
  yum_disable_repo(command, opts[:disable_repo])
  command.append_flag('-y')

  if Kanrisuru::Util.present?(opts[:repos])
    repos = Kanrisuru::Util.array_join_string(opts[:repos], ' ')
    command << repos
  end

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#yum_remove(opts) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kanrisuru/core/yum/commands/remove.rb', line 6

def yum_remove(opts)
  command = Kanrisuru::Command.new('yum remove')
  command.append_flag('-y')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  raise ArgumentError, "can't remove yum" if packages.include?('yum')

  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#yum_repolist(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kanrisuru/core/yum/commands/repolist.rb', line 6

def yum_repolist(opts)
  command = Kanrisuru::Command.new('yum repolist')
  command.append_flag('--verbose')

  command << Kanrisuru::Util.array_join_string(opts[:repos], ' ') if opts[:repos]

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::Repolist.parse(cmd)
  end
end

#yum_search(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kanrisuru/core/yum/commands/search.rb', line 6

def yum_search(opts)
  command = Kanrisuru::Command.new('yum search')
  command.append_flag('all', opts[:all])
  command << Kanrisuru::Util.array_join_string(opts[:packages], ' ')

  pipe_output_newline(command)

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::Search.parse(cmd)
  end
end

#yum_update(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/yum/commands/update.rb', line 6

def yum_update(_opts)
  command = Kanrisuru::Command.new('yum update')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#yum_upgrade(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/yum/commands/upgrade.rb', line 6

def yum_upgrade(_opts)
  command = Kanrisuru::Command.new('yum upgrade')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end