Module: Kanrisuru::Core::Zypper

Extended by:
OsPackage::Define
Defined in:
lib/kanrisuru/core/zypper.rb,
lib/kanrisuru/core/zypper/types.rb,
lib/kanrisuru/core/zypper/commands.rb,
lib/kanrisuru/core/zypper/constants.rb,
lib/kanrisuru/core/zypper/parsers/base.rb,
lib/kanrisuru/core/zypper/parsers/info.rb,
lib/kanrisuru/core/zypper/commands/info.rb,
lib/kanrisuru/core/zypper/commands/patch.rb,
lib/kanrisuru/core/zypper/parsers/search.rb,
lib/kanrisuru/core/zypper/commands/remove.rb,
lib/kanrisuru/core/zypper/commands/search.rb,
lib/kanrisuru/core/zypper/commands/update.rb,
lib/kanrisuru/core/zypper/commands/verify.rb,
lib/kanrisuru/core/zypper/commands/install.rb,
lib/kanrisuru/core/zypper/commands/add_lock.rb,
lib/kanrisuru/core/zypper/commands/add_repo.rb,
lib/kanrisuru/core/zypper/parsers/list_locks.rb,
lib/kanrisuru/core/zypper/parsers/list_repos.rb,
lib/kanrisuru/core/zypper/commands/list_locks.rb,
lib/kanrisuru/core/zypper/commands/list_repos.rb,
lib/kanrisuru/core/zypper/parsers/patch_check.rb,
lib/kanrisuru/core/zypper/commands/add_service.rb,
lib/kanrisuru/core/zypper/commands/clean_cache.rb,
lib/kanrisuru/core/zypper/commands/clean_locks.rb,
lib/kanrisuru/core/zypper/commands/modify_repo.rb,
lib/kanrisuru/core/zypper/commands/patch_check.rb,
lib/kanrisuru/core/zypper/commands/remove_lock.rb,
lib/kanrisuru/core/zypper/commands/remove_repo.rb,
lib/kanrisuru/core/zypper/commands/rename_repo.rb,
lib/kanrisuru/core/zypper/parsers/list_patches.rb,
lib/kanrisuru/core/zypper/parsers/list_updates.rb,
lib/kanrisuru/core/zypper/commands/dist_upgrade.rb,
lib/kanrisuru/core/zypper/commands/list_patches.rb,
lib/kanrisuru/core/zypper/commands/list_updates.rb,
lib/kanrisuru/core/zypper/parsers/list_services.rb,
lib/kanrisuru/core/zypper/commands/list_services.rb,
lib/kanrisuru/core/zypper/commands/purge_kernels.rb,
lib/kanrisuru/core/zypper/commands/refresh_repos.rb,
lib/kanrisuru/core/zypper/commands/modify_service.rb,
lib/kanrisuru/core/zypper/commands/remove_service.rb,
lib/kanrisuru/core/zypper/commands/source_install.rb,
lib/kanrisuru/core/zypper/commands/refresh_services.rb,
lib/kanrisuru/core/zypper/commands/install_new_recommends.rb

Defined Under Namespace

Modules: Parser Classes: Lock, PackageDetail, PackageUpdate, PatchCount, PatchUpdate, Repo, SearchResult, Service

Constant Summary collapse

PACKAGE_TYPES =
%w[package patch pattern product srcpackage application].freeze
PATCH_CATEGORIES =
%w[security recommended optional feature document yast].freeze
PATCH_SEVERITIES =
%w[critical important moderate low unspecified].freeze
SOLVER_FOCUS_MODES =
%w[job installed update].freeze
MEDIUM_TYPES =
%w[dir file cd dvd nfs iso http https ftp cifs smb hd].freeze
EXIT_INF_UPDATE_NEEDED =
100
EXIT_INF_SEC_UPDATE_NEEDED =
101
EXIT_INF_REBOOT_NEEDED =
102
EXIT_INF_RESTART_NEEDED =
103
EXIT_INF_CAP_NOT_FOUND =
104

Instance Method Summary collapse

Methods included from OsPackage::Define

extended, os_define

Instance Method Details

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



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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/kanrisuru/core/zypper.rb', line 17

def zypper(action, opts = {})
  case action
  when 'repos', 'lr'
    zypper_list_repos(opts)
  when 'refresh', 'ref'
    zypper_refresh_repos(opts)
  when 'modifyrepo', 'mr'
    zypper_modify_repo(opts)
  when 'addrepo', 'ar'
    zypper_add_repo(opts)
  when 'removerepo', 'rr'
    zypper_remove_repo(opts)
  when 'renamerepo', 'nr'
    zypper_rename_repo(opts)

  when 'addservice', 'as'
    zypper_add_service(opts)
  when 'removeservice', 'rs'
    zypper_remove_service(opts)
  when 'modifyservice', 'ms'
    zypper_modify_service(opts)
  when 'services', 'ls'
    zypper_list_services(opts)
  when 'refresh-services', 'refs'
    zypper_refresh_services(opts)

  when 'addlock', 'al'
    zypper_add_lock(opts)
  when 'locks', 'll'
    zypper_list_locks(opts)
  when 'removelock', 'rl'
    zypper_remove_lock(opts)
  when 'cleanlocks', 'cl'
    zypper_clean_locks(opts)

  when 'info', 'if'
    zypper_info(opts)
  when 'install', 'in'
    zypper_install(opts)
  when 'source-install', 'si'
    zypper_source_install(opts)
  when 'verify', 've'
    zypper_verify(opts)
  when 'install-new-recommends', 'inr'
    zypper_install_new_recommends(opts)
  when 'remove', 'rm'
    zypper_remove(opts)
  when 'purge-kernels'
    zypper_purge_kernels(opts)
  when 'search', 'se'
    zypper_search(opts)
  when 'clean', 'cc'
    zypper_clean_cache(opts)
  when 'list-updates', 'lu'
    zypper_list_updates(opts)
  when 'list-patches', 'lp'
    zypper_list_patches(opts)

  when 'patch-check', 'pchk'
    zypper_patch_check(opts)
  when 'patch'
    zypper_patch(opts)
  when 'dist-upgrade', 'dup'
    zypper_dist_upgrade(opts)
  when 'update', 'up'
    zypper_update(opts)
  end
end

#zypper_add_lock(opts) ⇒ Object



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

def zypper_add_lock(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'addlock'

  command.append_arg('--repo', opts[:repo])
  zypper_package_type_opt(command, opts)

  command << opts[:lock]

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_add_repo(opts) ⇒ Object



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

def zypper_add_repo(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'addrepo'

  command.append_flag('--check', opts[:check])
  command.append_flag('--no-check', opts[:no_check])
  command.append_flag('--enable', opts[:enable])
  command.append_flag('--disable', opts[:disable])
  command.append_flag('--refresh', opts[:refresh])
  command.append_flag('--no-refresh', opts[:no_refresh])
  command.append_flag('--keep-packages', opts[:keep_packages])
  command.append_flag('--no-keep-packages', opts[:no_keep_packages])
  command.append_arg('--priority', opts[:priority])

  zypper_gpg_opts(command, opts)
  zypper_repos_opt(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_add_service(opts) ⇒ Object



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

def zypper_add_service(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'addservice'

  name = ("'#{opts[:name]}'" if Kanrisuru::Util.present?(opts[:name]))

  command.append_arg('--name', name)
  command.append_flag('--enable', opts[:enable])
  command.append_flag('--disable', opts[:disable])
  command.append_flag('--refresh', opts[:refresh])
  command.append_flag('--no-refresh', opts[:no_refresh])

  command << opts[:service]
  command << opts[:alias]

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_clean_cache(opts) ⇒ Object



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

def zypper_clean_cache(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'clean'
  command.append_flag('--metadata', opts[:metadata])
  command.append_flag('--raw-metadata', opts[:raw_metadata])
  command.append_flag('--all', opts[:all])
  command.append_array(opts[:repos])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_clean_locks(opts) ⇒ Object



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

def zypper_clean_locks(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'cleanlocks'

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_dist_upgrade(opts) ⇒ Object



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

def zypper_dist_upgrade(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'dist-upgrade'

  command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
  command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])
  command.append_flag('--dry-run', opts[:dry_run])

  zypper_repos_opt(command, opts)
  zypper_solver_opts(command, opts)
  zypper_expert_opts(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_info(opts) ⇒ Object



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

def zypper_info(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'info'

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)

  command.append_array(opts[:packages])

  execute_shell(command)

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

#zypper_install(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kanrisuru/core/zypper/commands/install.rb', line 6

def zypper_install(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'install'

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)

  command.append_arg('-n', opts[:name])
  command.append_flag('-f', opts[:force])
  command.append_flag('--oldpackage', opts[:oldpackage])
  command.append_arg('--from', opts[:from])
  command.append_arg('--capability', opts[:capability])
  command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
  command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])
  command.append_flag('--replacefiles', opts[:replacefiles])

  command.append_flag('--dry-run', opts[:dry_run])
  command.append_flag('--allow-unsigned-rpm', opts[:allow_unsigned_rpm])

  zypper_solver_opts(command, opts)
  zypper_download_and_install_opts(command, opts)
  zypper_expert_opts(command, opts)

  command.append_array(opts[:packages])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_install_new_recommends(opts) ⇒ Object



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

def zypper_install_new_recommends(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'install-new-recommends'

  command.append_flag('--dry-run', opts[:dry_run])

  zypper_repos_opt(command, opts)
  zypper_solver_opts(command, opts)
  zypper_expert_opts(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_list_locks(opts) ⇒ Object



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

def zypper_list_locks(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command.append_flag('--quiet')
  command << 'locks'

  command.append_flag('--matches')

  execute_shell(command)

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

#zypper_list_patches(opts) ⇒ Object



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

def zypper_list_patches(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command.append_flag('--quiet')
  command << 'list-patches'

  command.append_arg('--bugzilla', opts[:bugzilla])
  command.append_arg('--cve', opts[:cve])
  command.append_arg('--date', opts[:date])

  zypper_patch_category_opt(command, opts)
  zypper_patch_severity_opt(command, opts)

  command.append_flag('--issues', opts[:issues])
  command.append_flag('--all', opts[:all])
  command.append_flag('--with-optional', opts[:with_optional])
  command.append_flag('--without-optional', opts[:without_optional])

  zypper_repos_opt(command, opts)

  execute_shell(command)

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

#zypper_list_repos(opts) ⇒ Object



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

def zypper_list_repos(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'repos'
  command.append_flag('--details')

  execute_shell(command)

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

#zypper_list_services(opts) ⇒ Object



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

def zypper_list_services(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'services'
  command.append_flag('--details')

  execute_shell(command)

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

#zypper_list_updates(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/zypper/commands/list_updates.rb', line 6

def zypper_list_updates(opts)
  return zypper_list_patches(opts) if opts[:type] == 'patch'

  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command.append_flag('--quiet')
  command << 'list-updates'

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)

  command.append_flag('--all', opts[:all])
  command.append_flag('--best-effort', opts[:best_effort])

  zypper_expert_opts(command, opts)

  execute_shell(command)

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

#zypper_modify_repo(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/kanrisuru/core/zypper/commands/modify_repo.rb', line 6

def zypper_modify_repo(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'modifyrepo'

  command.append_arg('--name', opts[:name])
  command.append_arg('--priority', opts[:priority])

  command.append_flag('--enable', opts[:enable])
  command.append_flag('--disable', opts[:disable])
  command.append_flag('--refresh', opts[:refresh])
  command.append_flag('--no-refresh', opts[:no_refresh])
  command.append_flag('--keep-packages', opts[:keep_packages])
  command.append_flag('--no-keep-packages', opts[:no_keep_packages])

  zypper_gpg_opts(command, opts)

  command.append_flag('--all', opts[:all])
  command.append_flag('--local', opts[:local])
  command.append_flag('--remote', opts[:remote])

  if Kanrisuru::Util.present?(opts[:medium_type])
    raise ArgumentError, 'Invalid medium type' unless MEDIUM_TYPES.include?(opts[:medium_type])

    command.append_arg('--medium-type', opts[:medium_type])
  end

  command.append_array(opts[:repos])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_modify_service(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/kanrisuru/core/zypper/commands/modify_service.rb', line 6

def zypper_modify_service(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'modifyservice'

  command.append_arg('--name', opts[:name])
  command.append_flag('--enable', opts[:enable])
  command.append_flag('--disable', opts[:disable])
  command.append_flag('--refresh', opts[:refresh])
  command.append_flag('--no-refresh', opts[:no_refresh])
  command.append_flag('--all', opts[:all])
  command.append_flag('--local', opts[:local])
  command.append_flag('--remote', opts[:remote])

  command.append_arg('--ar-to-enable', opts[:ar_to_enable])
  command.append_arg('--ar-to-disable', opts[:ar_to_disable])
  command.append_arg('--rr-to-enable', opts[:rr_to_enable])
  command.append_arg('--rr-to-disable', opts[:rr_to_disable])
  command.append_arg('--cl-to-enable', opts[:cl_to_enable])
  command.append_arg('--cl-to-disable', opts[:cl_to_disable])

  if Kanrisuru::Util.present?(opts[:medium_type])
    raise ArgumentError, 'Invalid medium type' unless MEDIUM_TYPES.include?(opts[:medium_type])

    command.append_arg('--medium-type', opts[:medium_type])
  end

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

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_patch(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kanrisuru/core/zypper/commands/patch.rb', line 6

def zypper_patch(opts)
  command = Kanrisuru::Command.new('zypper')
  command.append_valid_exit_code(EXIT_INF_REBOOT_NEEDED)
  command.append_valid_exit_code(EXIT_INF_RESTART_NEEDED)
  zypper_global_opts(command, opts)

  command << 'patch'

  command.append_flag('--updatestack-only', opts[:updatestack_only])
  command.append_flag('--with-update', opts[:with_update])
  command.append_flag('--with-optional', opts[:with_optional])
  command.append_flag('--without-optional', opts[:without_optional])
  command.append_flag('--replacefiles', opts[:replacefiles])
  command.append_flag('--dry-run', opts[:dry_run])

  command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
  command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])

  command.append_arg('--bugzilla', opts[:bugzilla])
  command.append_arg('--cve', opts[:cve])
  command.append_arg('--date', opts[:date])

  zypper_patch_category_opt(command, opts)
  zypper_patch_severity_opt(command, opts)
  zypper_repos_opt(command, opts)
  zypper_solver_opts(command, opts)
  zypper_expert_opts(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_patch_check(opts) ⇒ Object



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

def zypper_patch_check(opts)
  command = Kanrisuru::Command.new('zypper')
  command.append_valid_exit_code(EXIT_INF_UPDATE_NEEDED)
  command.append_valid_exit_code(EXIT_INF_SEC_UPDATE_NEEDED)

  zypper_global_opts(command, opts)
  command.append_flag('--quiet')
  command << 'patch-check'

  command.append_flag('--updatestack-only', opts[:updatestack_only])
  command.append_flag('--with-optional', opts[:with_optional])
  command.append_flag('--without-optional', opts[:without_optional])

  zypper_repos_opt(command, opts)

  execute_shell(command)

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

#zypper_purge_kernels(opts) ⇒ Object



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

def zypper_purge_kernels(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'purge-kernels'
  command.append_flag('--dry-run', opts[:dry_run])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_refresh_repos(opts) ⇒ Object



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

def zypper_refresh_repos(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'refresh'

  command.append_flag('--force', opts[:force])
  command.append_flag('--force-build', opts[:force_build])
  command.append_flag('--force-download', opts[:force_download])
  command.append_flag('--build-only', opts[:build_only])
  command.append_flag('--download-only', opts[:download_only])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_refresh_services(opts) ⇒ Object



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

def zypper_refresh_services(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'refresh-services'
  command.append_flag('--force', opts[:force])
  command.append_flag('--with-repos', opts[:with_repos])
  command.append_flag('--restore-status', opts[:restore_status])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_remove(opts) ⇒ Object



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

def zypper_remove(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'remove'

  command.append_flag('--dry-run', opts[:dry_run])
  command.append_flag('--capability', opts[:capability])

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)
  zypper_solver_opts(command, opts)

  command.append_array(opts[:packages])

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

#zypper_remove_lock(opts) ⇒ Object



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

def zypper_remove_lock(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'removelock'

  command.append_arg('--repo', opts[:repo])
  zypper_package_type_opt(command, opts)

  command << opts[:lock]

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_remove_repo(opts) ⇒ Object



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

def zypper_remove_repo(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'removerepo'

  command.append_flag('--loose-auth', opts[:loose_auth])
  command.append_flag('--loose-query', opts[:loose_query])
  command.append_flag('--all', opts[:all])
  command.append_flag('--local', opts[:local])
  command.append_flag('--remote', opts[:remote])

  if Kanrisuru::Util.present?(opts[:medium_type])
    raise ArgumentError, 'Invalid media type' unless MEDIUM_TYPES.include?(opts[:medium_type])

    command.append_arg('--medium-type', opts[:medium_type])
  end

  command.append_array(opts[:repos])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_remove_service(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kanrisuru/core/zypper/commands/remove_service.rb', line 6

def zypper_remove_service(opts)
  service = opts[:service]

  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'removeservice'
  command.append_flag('--loose-auth', opts[:loose_auth])
  command.append_flag('--loose-query', opts[:loose_query])

  service = "'#{service}'" if service.match(/\s/)

  command << service

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_rename_repo(opts) ⇒ Object



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

def zypper_rename_repo(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)

  command << 'renamerepo'
  command << opts[:repo]
  command << opts[:alias]

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_search(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
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
44
45
46
47
# File 'lib/kanrisuru/core/zypper/commands/search.rb', line 6

def zypper_search(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'search'

  command.append_flag('--details')
  command.append_flag('--match-substrings', opts[:match_substrings])
  command.append_flag('--match-words', opts[:match_words])
  command.append_flag('--match-exact', opts[:match_exact])
  command.append_flag('--provides', opts[:provides])
  command.append_flag('--requires', opts[:requires])
  command.append_flag('--recommends', opts[:recommends])
  command.append_flag('--suggests', opts[:suggests])
  command.append_flag('--conflicts', opts[:conflicts])
  command.append_flag('--obsoletes', opts[:obsoletes])
  command.append_flag('--supplements', opts[:supplements])
  command.append_flag('--provides-pkg', opts[:provides_pkg])
  command.append_flag('--requires-pkg', opts[:requires_pkg])
  command.append_flag('--recommends-pkg', opts[:recommends_pkg])
  command.append_flag('--supplements-pkg', opts[:supplements_pkg])
  command.append_flag('--conflicts-pkg', opts[:conflicts_pkg])
  command.append_flag('--obsoletes-pkg', opts[:obsoletes_pkg])
  command.append_flag('--suggests-pkg', opts[:suggests_pkg])
  command.append_flag('--name', opts[:name])
  command.append_flag('--file-list', opts[:file_list])
  command.append_flag('--search-descriptions', opts[:search_descriptions])
  command.append_flag('--case-sensitive', opts[:case_sensitive])
  command.append_flag('--installed-only', opts[:installed_only])
  command.append_flag('--not-installed-only', opts[:not_installed_only])
  command.append_flag('--sort-by-name', opts[:sort_by_name])
  command.append_flag('--sort-by-repo', opts[:sort_by_repo])

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)
  command.append_array(opts[:packages])

  execute_shell(command)

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

#zypper_source_install(opts) ⇒ Object



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

def zypper_source_install(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'sourceinstall'

  zypper_repos_opt(command, opts)
  command.append_flag('--build-deps-only', opts[:build_deps_only])
  command.append_flag('--no-build-deps', opts[:no_build_deps])
  command.append_flag('--download-only', opts[:download_only])

  command.append_array(opts[:packages])

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_update(opts) ⇒ Object



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

def zypper_update(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'update'

  zypper_repos_opt(command, opts)
  zypper_package_type_opt(command, opts)

  command.append_flag('--replacefiles', opts[:replacefiles])
  command.append_flag('--dry-run', opts[:dry_run])
  command.append_flag('--best-effort', opts[:best_effort])

  zypper_solver_opts(command, opts)
  zypper_expert_opts(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end

#zypper_verify(opts) ⇒ Object



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

def zypper_verify(opts)
  command = Kanrisuru::Command.new('zypper')
  zypper_global_opts(command, opts)
  command << 'verify'

  command.append_flag('--dry-run', opts[:dry_run])

  zypper_repos_opt(command, opts)
  zypper_solver_opts(command, opts)
  zypper_expert_opts(command, opts)

  execute_shell(command)

  Kanrisuru::Result.new(command)
end