kanrisuru 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/kanrisuru/core/apt/commands/autoclean.rb +13 -0
  4. data/lib/kanrisuru/core/apt/commands/autoremove.rb +15 -0
  5. data/lib/kanrisuru/core/apt/commands/clean.rb +13 -0
  6. data/lib/kanrisuru/core/apt/commands/full_upgrade.rb +14 -0
  7. data/lib/kanrisuru/core/apt/commands/install.rb +22 -0
  8. data/lib/kanrisuru/core/apt/commands/list.rb +21 -0
  9. data/lib/kanrisuru/core/apt/commands/purge.rb +18 -0
  10. data/lib/kanrisuru/core/apt/commands/remove.rb +18 -0
  11. data/lib/kanrisuru/core/apt/commands/search.rb +18 -0
  12. data/lib/kanrisuru/core/apt/commands/show.rb +21 -0
  13. data/lib/kanrisuru/core/apt/commands/update.rb +14 -0
  14. data/lib/kanrisuru/core/apt/commands/upgrade.rb +14 -0
  15. data/lib/kanrisuru/core/apt/commands.rb +14 -0
  16. data/lib/kanrisuru/core/apt/parser.rb +6 -0
  17. data/lib/kanrisuru/core/apt/parsers/base.rb +51 -0
  18. data/lib/kanrisuru/core/apt/parsers/list.rb +28 -0
  19. data/lib/kanrisuru/core/apt/parsers/search.rb +32 -0
  20. data/lib/kanrisuru/core/apt/parsers/show.rb +90 -0
  21. data/lib/kanrisuru/core/apt/types.rb +36 -0
  22. data/lib/kanrisuru/core/apt.rb +4 -284
  23. data/lib/kanrisuru/core/archive/commands/tar.rb +126 -0
  24. data/lib/kanrisuru/core/archive/commands.rb +3 -0
  25. data/lib/kanrisuru/core/archive/types.rb +9 -0
  26. data/lib/kanrisuru/core/archive.rb +3 -121
  27. data/lib/kanrisuru/core/disk/commands/blkid.rb +35 -0
  28. data/lib/kanrisuru/core/disk/commands/df.rb +26 -0
  29. data/lib/kanrisuru/core/disk/commands/du.rb +24 -0
  30. data/lib/kanrisuru/core/disk/commands/lsblk.rb +54 -0
  31. data/lib/kanrisuru/core/disk/commands.rb +6 -0
  32. data/lib/kanrisuru/core/disk/parser.rb +6 -0
  33. data/lib/kanrisuru/core/disk/parsers/blkid.rb +72 -0
  34. data/lib/kanrisuru/core/disk/parsers/df.rb +33 -0
  35. data/lib/kanrisuru/core/disk/parsers/du.rb +25 -0
  36. data/lib/kanrisuru/core/disk/parsers/lsblk.rb +96 -0
  37. data/lib/kanrisuru/core/disk/types.rb +21 -0
  38. data/lib/kanrisuru/core/disk.rb +5 -290
  39. data/lib/kanrisuru/core/dmi/commands/dmi.rb +42 -0
  40. data/lib/kanrisuru/core/dmi/commands.rb +3 -0
  41. data/lib/kanrisuru/core/dmi/parser.rb +3 -0
  42. data/lib/kanrisuru/core/dmi/parsers/dmi.rb +149 -0
  43. data/lib/kanrisuru/core/dmi/types.rb +361 -0
  44. data/lib/kanrisuru/core/dmi.rb +4 -522
  45. data/lib/kanrisuru/core/file/commands/chmod.rb +29 -0
  46. data/lib/kanrisuru/core/file/commands/chown.rb +35 -0
  47. data/lib/kanrisuru/core/file/commands/copy.rb +56 -0
  48. data/lib/kanrisuru/core/file/commands/link.rb +25 -0
  49. data/lib/kanrisuru/core/file/commands/mkdir.rb +37 -0
  50. data/lib/kanrisuru/core/file/commands/move.rb +48 -0
  51. data/lib/kanrisuru/core/file/commands/rm.rb +38 -0
  52. data/lib/kanrisuru/core/file/commands/symlink.rb +46 -0
  53. data/lib/kanrisuru/core/file/commands/touch.rb +33 -0
  54. data/lib/kanrisuru/core/file/commands/unlink.rb +13 -0
  55. data/lib/kanrisuru/core/file/commands/wc.rb +16 -0
  56. data/lib/kanrisuru/core/file/commands.rb +29 -0
  57. data/lib/kanrisuru/core/file/parser.rb +3 -0
  58. data/lib/kanrisuru/core/file/parsers/wc.rb +16 -0
  59. data/lib/kanrisuru/core/file/types.rb +9 -0
  60. data/lib/kanrisuru/core/file.rb +4 -312
  61. data/lib/kanrisuru/core/find/commands/find.rb +97 -0
  62. data/lib/kanrisuru/core/find/commands.rb +3 -0
  63. data/lib/kanrisuru/core/find/constants.rb +9 -0
  64. data/lib/kanrisuru/core/find/parser.rb +3 -0
  65. data/lib/kanrisuru/core/find/parsers/find.rb +18 -0
  66. data/lib/kanrisuru/core/find/types.rb +9 -0
  67. data/lib/kanrisuru/core/find.rb +5 -97
  68. data/lib/kanrisuru/core/group/commands/create_group.rb +21 -0
  69. data/lib/kanrisuru/core/group/commands/delete_group.rb +16 -0
  70. data/lib/kanrisuru/core/group/commands/get_gid.rb +17 -0
  71. data/lib/kanrisuru/core/group/commands/get_group.rb +29 -0
  72. data/lib/kanrisuru/core/group/commands/is_group.rb +14 -0
  73. data/lib/kanrisuru/core/group/commands/update_group.rb +23 -0
  74. data/lib/kanrisuru/core/group/commands.rb +8 -0
  75. data/lib/kanrisuru/core/group/parser.rb +4 -0
  76. data/lib/kanrisuru/core/group/parsers/gid.rb +15 -0
  77. data/lib/kanrisuru/core/group/parsers/group.rb +15 -0
  78. data/lib/kanrisuru/core/group/types.rb +10 -0
  79. data/lib/kanrisuru/core/group.rb +4 -81
  80. data/lib/kanrisuru/core/ip/commands/address.rb +69 -0
  81. data/lib/kanrisuru/core/ip/commands/address_label.rb +38 -0
  82. data/lib/kanrisuru/core/ip/commands/link.rb +74 -0
  83. data/lib/kanrisuru/core/ip/commands/maddress.rb +33 -0
  84. data/lib/kanrisuru/core/ip/commands/neighbour.rb +55 -0
  85. data/lib/kanrisuru/core/ip/commands/route.rb +115 -0
  86. data/lib/kanrisuru/core/ip/commands/rule.rb +42 -0
  87. data/lib/kanrisuru/core/ip/commands.rb +24 -0
  88. data/lib/kanrisuru/core/ip/constants.rb +13 -0
  89. data/lib/kanrisuru/core/ip/parser.rb +10 -0
  90. data/lib/kanrisuru/core/ip/parsers/address.rb +104 -0
  91. data/lib/kanrisuru/core/ip/parsers/address_label.rb +27 -0
  92. data/lib/kanrisuru/core/ip/parsers/base.rb +166 -0
  93. data/lib/kanrisuru/core/ip/parsers/link.rb +86 -0
  94. data/lib/kanrisuru/core/ip/parsers/maddress.rb +85 -0
  95. data/lib/kanrisuru/core/ip/parsers/neighbour.rb +89 -0
  96. data/lib/kanrisuru/core/ip/parsers/route.rb +76 -0
  97. data/lib/kanrisuru/core/ip/parsers/rule.rb +60 -0
  98. data/lib/kanrisuru/core/ip/types.rb +46 -0
  99. data/lib/kanrisuru/core/ip.rb +5 -995
  100. data/lib/kanrisuru/core/mount/commands/mount.rb +65 -0
  101. data/lib/kanrisuru/core/mount/commands/umount.rb +35 -0
  102. data/lib/kanrisuru/core/mount/commands.rb +49 -0
  103. data/lib/kanrisuru/core/mount.rb +2 -125
  104. data/lib/kanrisuru/core/path/commands/ls.rb +26 -0
  105. data/lib/kanrisuru/core/path/commands/pwd.rb +16 -0
  106. data/lib/kanrisuru/core/path/commands/readlink.rb +22 -0
  107. data/lib/kanrisuru/core/path/commands/realpath.rb +18 -0
  108. data/lib/kanrisuru/core/path/commands/which.rb +19 -0
  109. data/lib/kanrisuru/core/path/commands/whoami.rb +16 -0
  110. data/lib/kanrisuru/core/path/commands.rb +8 -0
  111. data/lib/kanrisuru/core/path/parser.rb +4 -0
  112. data/lib/kanrisuru/core/path/parsers/ls.rb +53 -0
  113. data/lib/kanrisuru/core/path/parsers/which.rb +18 -0
  114. data/lib/kanrisuru/core/path/types.rb +12 -0
  115. data/lib/kanrisuru/core/path.rb +4 -121
  116. data/lib/kanrisuru/core/socket/commands/ss.rb +44 -0
  117. data/lib/kanrisuru/core/socket/commands.rb +3 -0
  118. data/lib/kanrisuru/core/socket/constants.rb +29 -0
  119. data/lib/kanrisuru/core/socket/parser.rb +3 -0
  120. data/lib/kanrisuru/core/socket/parsers/ss.rb +109 -0
  121. data/lib/kanrisuru/core/socket/types.rb +18 -0
  122. data/lib/kanrisuru/core/socket.rb +5 -164
  123. data/lib/kanrisuru/core/stat/commands/stat.rb +62 -0
  124. data/lib/kanrisuru/core/stat/commands.rb +3 -0
  125. data/lib/kanrisuru/core/stat/parser.rb +3 -0
  126. data/lib/kanrisuru/core/stat/parsers/stat.rb +34 -0
  127. data/lib/kanrisuru/core/stat/types.rb +14 -0
  128. data/lib/kanrisuru/core/stat.rb +4 -81
  129. data/lib/kanrisuru/core/stream/commands/cat.rb +25 -0
  130. data/lib/kanrisuru/core/stream/commands/echo.rb +20 -0
  131. data/lib/kanrisuru/core/stream/commands/head.rb +18 -0
  132. data/lib/kanrisuru/core/stream/commands/read_file_chunk.rb +21 -0
  133. data/lib/kanrisuru/core/stream/commands/sed.rb +23 -0
  134. data/lib/kanrisuru/core/stream/commands/tail.rb +18 -0
  135. data/lib/kanrisuru/core/stream/commands.rb +27 -0
  136. data/lib/kanrisuru/core/stream/parser.rb +4 -0
  137. data/lib/kanrisuru/core/stream/parsers/echo.rb +17 -0
  138. data/lib/kanrisuru/core/stream/parsers/sed.rb +17 -0
  139. data/lib/kanrisuru/core/stream.rb +3 -104
  140. data/lib/kanrisuru/core/system/commands/cpu_info.rb +32 -0
  141. data/lib/kanrisuru/core/system/commands/free.rb +25 -0
  142. data/lib/kanrisuru/core/system/commands/kernel_statistics.rb +21 -0
  143. data/lib/kanrisuru/core/system/commands/kill.rb +22 -0
  144. data/lib/kanrisuru/core/system/commands/last.rb +31 -0
  145. data/lib/kanrisuru/core/system/commands/load_average.rb +16 -0
  146. data/lib/kanrisuru/core/system/commands/load_env.rb +16 -0
  147. data/lib/kanrisuru/core/system/commands/lscpu.rb +17 -0
  148. data/lib/kanrisuru/core/system/commands/lsof.rb +16 -0
  149. data/lib/kanrisuru/core/system/commands/poweroff.rb +42 -0
  150. data/lib/kanrisuru/core/system/commands/ps.rb +35 -0
  151. data/lib/kanrisuru/core/system/commands/reboot.rb +42 -0
  152. data/lib/kanrisuru/core/system/commands/uptime.rb +18 -0
  153. data/lib/kanrisuru/core/system/commands/w.rb +24 -0
  154. data/lib/kanrisuru/core/system/commands.rb +34 -0
  155. data/lib/kanrisuru/core/system/parser.rb +11 -0
  156. data/lib/kanrisuru/core/system/parsers/kernel_statistics.rb +56 -0
  157. data/lib/kanrisuru/core/system/parsers/last.rb +64 -0
  158. data/lib/kanrisuru/core/system/parsers/load_average.rb +15 -0
  159. data/lib/kanrisuru/core/system/parsers/load_env.rb +24 -0
  160. data/lib/kanrisuru/core/system/parsers/lscpu.rb +90 -0
  161. data/lib/kanrisuru/core/system/parsers/lsof.rb +62 -0
  162. data/lib/kanrisuru/core/system/parsers/ps.rb +71 -0
  163. data/lib/kanrisuru/core/system/parsers/uptime.rb +38 -0
  164. data/lib/kanrisuru/core/system/parsers/w.rb +30 -0
  165. data/lib/kanrisuru/core/system/types.rb +108 -0
  166. data/lib/kanrisuru/core/system.rb +4 -687
  167. data/lib/kanrisuru/core/transfer/commands/download.rb +26 -0
  168. data/lib/kanrisuru/core/transfer/commands/upload.rb +23 -0
  169. data/lib/kanrisuru/core/transfer/commands/wget.rb +168 -0
  170. data/lib/kanrisuru/core/transfer/commands.rb +5 -0
  171. data/lib/kanrisuru/core/transfer/constants.rb +10 -0
  172. data/lib/kanrisuru/core/transfer.rb +3 -199
  173. data/lib/kanrisuru/core/user/commands/create_user.rb +57 -0
  174. data/lib/kanrisuru/core/user/commands/delete_user.rb +20 -0
  175. data/lib/kanrisuru/core/user/commands/get_uid.rb +15 -0
  176. data/lib/kanrisuru/core/user/commands/get_user.rb +48 -0
  177. data/lib/kanrisuru/core/user/commands/is_user.rb +14 -0
  178. data/lib/kanrisuru/core/user/commands/update_user.rb +63 -0
  179. data/lib/kanrisuru/core/user/commands.rb +8 -0
  180. data/lib/kanrisuru/core/user/parser.rb +4 -0
  181. data/lib/kanrisuru/core/user/parsers/getent.rb +17 -0
  182. data/lib/kanrisuru/core/user/parsers/groups.rb +17 -0
  183. data/lib/kanrisuru/core/user/types.rb +11 -0
  184. data/lib/kanrisuru/core/user.rb +4 -182
  185. data/lib/kanrisuru/core/yum/commands/autoremove.rb +14 -0
  186. data/lib/kanrisuru/core/yum/commands/clean.rb +23 -0
  187. data/lib/kanrisuru/core/yum/commands/erase.rb +20 -0
  188. data/lib/kanrisuru/core/yum/commands/info.rb +21 -0
  189. data/lib/kanrisuru/core/yum/commands/install.rb +18 -0
  190. data/lib/kanrisuru/core/yum/commands/list.rb +30 -0
  191. data/lib/kanrisuru/core/yum/commands/localinstall.rb +22 -0
  192. data/lib/kanrisuru/core/yum/commands/remove.rb +20 -0
  193. data/lib/kanrisuru/core/yum/commands/repolist.rb +20 -0
  194. data/lib/kanrisuru/core/yum/commands/search.rb +21 -0
  195. data/lib/kanrisuru/core/yum/commands/update.rb +14 -0
  196. data/lib/kanrisuru/core/yum/commands/upgrade.rb +14 -0
  197. data/lib/kanrisuru/core/yum/commands.rb +39 -0
  198. data/lib/kanrisuru/core/yum/parser.rb +7 -0
  199. data/lib/kanrisuru/core/yum/parsers/base.rb +31 -0
  200. data/lib/kanrisuru/core/yum/parsers/info.rb +69 -0
  201. data/lib/kanrisuru/core/yum/parsers/list.rb +24 -0
  202. data/lib/kanrisuru/core/yum/parsers/repolist.rb +60 -0
  203. data/lib/kanrisuru/core/yum/parsers/search.rb +30 -0
  204. data/lib/kanrisuru/core/yum/types.rb +41 -0
  205. data/lib/kanrisuru/core/yum.rb +4 -347
  206. data/lib/kanrisuru/core/zypper/commands/add_lock.rb +22 -0
  207. data/lib/kanrisuru/core/zypper/commands/add_repo.rb +38 -0
  208. data/lib/kanrisuru/core/zypper/commands/add_service.rb +26 -0
  209. data/lib/kanrisuru/core/zypper/commands/clean_cache.rb +22 -0
  210. data/lib/kanrisuru/core/zypper/commands/clean_locks.rb +17 -0
  211. data/lib/kanrisuru/core/zypper/commands/dist_upgrade.rb +25 -0
  212. data/lib/kanrisuru/core/zypper/commands/info.rb +25 -0
  213. data/lib/kanrisuru/core/zypper/commands/install.rb +39 -0
  214. data/lib/kanrisuru/core/zypper/commands/install_new_recommends.rb +23 -0
  215. data/lib/kanrisuru/core/zypper/commands/list_locks.rb +22 -0
  216. data/lib/kanrisuru/core/zypper/commands/list_patches.rb +34 -0
  217. data/lib/kanrisuru/core/zypper/commands/list_repos.rb +21 -0
  218. data/lib/kanrisuru/core/zypper/commands/list_services.rb +21 -0
  219. data/lib/kanrisuru/core/zypper/commands/list_updates.rb +30 -0
  220. data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +48 -0
  221. data/lib/kanrisuru/core/zypper/commands/modify_service.rb +40 -0
  222. data/lib/kanrisuru/core/zypper/commands/patch.rb +40 -0
  223. data/lib/kanrisuru/core/zypper/commands/patch_check.rb +29 -0
  224. data/lib/kanrisuru/core/zypper/commands/purge_kernels.rb +18 -0
  225. data/lib/kanrisuru/core/zypper/commands/refresh_repos.rb +24 -0
  226. data/lib/kanrisuru/core/zypper/commands/refresh_services.rb +21 -0
  227. data/lib/kanrisuru/core/zypper/commands/remove.rb +26 -0
  228. data/lib/kanrisuru/core/zypper/commands/remove_lock.rb +22 -0
  229. data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +32 -0
  230. data/lib/kanrisuru/core/zypper/commands/remove_service.rb +21 -0
  231. data/lib/kanrisuru/core/zypper/commands/rename_repo.rb +20 -0
  232. data/lib/kanrisuru/core/zypper/commands/search.rb +52 -0
  233. data/lib/kanrisuru/core/zypper/commands/source_install.rb +22 -0
  234. data/lib/kanrisuru/core/zypper/commands/update.rb +27 -0
  235. data/lib/kanrisuru/core/zypper/commands/verify.rb +23 -0
  236. data/lib/kanrisuru/core/zypper/commands.rb +109 -0
  237. data/lib/kanrisuru/core/zypper/constants.rb +19 -0
  238. data/lib/kanrisuru/core/zypper/parser.rb +11 -0
  239. data/lib/kanrisuru/core/zypper/parsers/base.rb +18 -0
  240. data/lib/kanrisuru/core/zypper/parsers/info.rb +77 -0
  241. data/lib/kanrisuru/core/zypper/parsers/list_locks.rb +36 -0
  242. data/lib/kanrisuru/core/zypper/parsers/list_patches.rb +40 -0
  243. data/lib/kanrisuru/core/zypper/parsers/list_repos.rb +37 -0
  244. data/lib/kanrisuru/core/zypper/parsers/list_services.rb +36 -0
  245. data/lib/kanrisuru/core/zypper/parsers/list_updates.rb +32 -0
  246. data/lib/kanrisuru/core/zypper/parsers/patch_check.rb +34 -0
  247. data/lib/kanrisuru/core/zypper/parsers/search.rb +37 -0
  248. data/lib/kanrisuru/core/zypper/types.rb +88 -0
  249. data/lib/kanrisuru/core/zypper.rb +5 -998
  250. data/lib/kanrisuru/version.rb +1 -1
  251. data/spec/unit/util_spec.rb +16 -0
  252. metadata +231 -2
@@ -2,6 +2,11 @@
2
2
 
3
3
  require 'date'
4
4
 
5
+ require_relative 'zypper/constants'
6
+ require_relative 'zypper/types'
7
+ require_relative 'zypper/parser'
8
+ require_relative 'zypper/commands'
9
+
5
10
  module Kanrisuru
6
11
  module Core
7
12
  module Zypper
@@ -9,99 +14,6 @@ module Kanrisuru
9
14
 
10
15
  os_define :sles, :zypper
11
16
 
12
- PACKAGE_TYPES = %w[package patch pattern product srcpackage application].freeze
13
- PATCH_CATEGORIES = %w[security recommended optional feature document yast].freeze
14
- PATCH_SEVERITIES = %w[critical important moderate low unspecified].freeze
15
- SOLVER_FOCUS_MODES = %w[job installed update].freeze
16
- MEDIUM_TYPES = %w[dir file cd dvd nfs iso http https ftp cifs smb hd].freeze
17
-
18
- EXIT_INF_UPDATE_NEEDED = 100
19
- EXIT_INF_SEC_UPDATE_NEEDED = 101
20
- EXIT_INF_REBOOT_NEEDED = 102
21
- EXIT_INF_RESTART_NEEDED = 103
22
- EXIT_INF_CAP_NOT_FOUND = 104
23
-
24
- Repo = Struct.new(
25
- :number,
26
- :alias,
27
- :name,
28
- :enabled,
29
- :gpg_check,
30
- :refresh,
31
- :priority,
32
- :type,
33
- :uri,
34
- :service
35
- )
36
-
37
- Service = Struct.new(
38
- :number,
39
- :alias,
40
- :name,
41
- :enabled,
42
- :gpg_check,
43
- :refresh,
44
- :priority,
45
- :type,
46
- :uri
47
- )
48
-
49
- SearchResult = Struct.new(
50
- :repository,
51
- :package,
52
- :status,
53
- :type,
54
- :version,
55
- :architecture
56
- )
57
-
58
- PackageDetail = Struct.new(
59
- :repository,
60
- :package,
61
- :version,
62
- :architecture,
63
- :vendor,
64
- :support_level,
65
- :install_size,
66
- :installed,
67
- :status,
68
- :source_package,
69
- :summary,
70
- :description
71
- )
72
-
73
- PackageUpdate = Struct.new(
74
- :repository,
75
- :package,
76
- :current_version,
77
- :available_version,
78
- :architecture
79
- )
80
-
81
- PatchUpdate = Struct.new(
82
- :repository,
83
- :patch,
84
- :category,
85
- :severity,
86
- :interactive,
87
- :status,
88
- :summary
89
- )
90
-
91
- PatchCount = Struct.new(
92
- :category,
93
- :updatestack,
94
- :patches
95
- )
96
-
97
- Lock = Struct.new(
98
- :number,
99
- :name,
100
- :matches,
101
- :type,
102
- :repository
103
- )
104
-
105
17
  def zypper(action, opts = {})
106
18
  case action
107
19
  when 'repos', 'lr'
@@ -170,911 +82,6 @@ module Kanrisuru
170
82
  zypper_update(opts)
171
83
  end
172
84
  end
173
-
174
- private
175
-
176
- def zypper_clean_cache(opts)
177
- command = Kanrisuru::Command.new('zypper')
178
- zypper_global_opts(command, opts)
179
-
180
- command << 'clean'
181
- command.append_flag('--metadata', opts[:metadata])
182
- command.append_flag('--raw-metadata', opts[:raw_metadata])
183
- command.append_flag('--all', opts[:all])
184
- command.append_array(opts[:repos])
185
-
186
- execute_shell(command)
187
-
188
- Kanrisuru::Result.new(command)
189
- end
190
-
191
- def zypper_list_repos(opts)
192
- command = Kanrisuru::Command.new('zypper')
193
- zypper_global_opts(command, opts)
194
-
195
- command << 'repos'
196
- command.append_flag('--details')
197
-
198
- execute_shell(command)
199
-
200
- Kanrisuru::Result.new(command) do |cmd|
201
- lines = cmd.to_a
202
-
203
- rows = []
204
- lines.each do |line|
205
- next unless line.match(/^\d/)
206
-
207
- values = line.split('|')
208
- values = values.map(&:strip)
209
-
210
- rows << Repo.new(
211
- values[0].to_i,
212
- values[1],
213
- values[2],
214
- values[3] == 'Yes',
215
- values[4].include?('Yes'),
216
- values[5] == 'Yes',
217
- values[6].to_i,
218
- values[7],
219
- values[8],
220
- values.length == 10 ? values[9] : nil
221
- )
222
- end
223
- rows
224
- end
225
- end
226
-
227
- def zypper_refresh_repos(opts)
228
- command = Kanrisuru::Command.new('zypper')
229
- zypper_global_opts(command, opts)
230
-
231
- command << 'refresh'
232
-
233
- command.append_flag('--force', opts[:force])
234
- command.append_flag('--force-build', opts[:force_build])
235
- command.append_flag('--force-download', opts[:force_download])
236
- command.append_flag('--build-only', opts[:build_only])
237
- command.append_flag('--download-only', opts[:download_only])
238
-
239
- execute_shell(command)
240
-
241
- Kanrisuru::Result.new(command)
242
- end
243
-
244
- def zypper_modify_repo(opts)
245
- command = Kanrisuru::Command.new('zypper')
246
- zypper_global_opts(command, opts)
247
-
248
- command << 'modifyrepo'
249
-
250
- command.append_arg('--name', opts[:name])
251
- command.append_arg('--priority', opts[:priority])
252
-
253
- command.append_flag('--enable', opts[:enable])
254
- command.append_flag('--disable', opts[:disable])
255
- command.append_flag('--refresh', opts[:refresh])
256
- command.append_flag('--no-refresh', opts[:no_refresh])
257
- command.append_flag('--keep-packages', opts[:keep_packages])
258
- command.append_flag('--no-keep-packages', opts[:no_keep_packages])
259
-
260
- command.append_flag('--gpgcheck', opts[:gpgcheck])
261
- command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
262
- command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
263
- command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
264
- command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
265
- command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
266
- command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
267
-
268
- command.append_flag('--all', opts[:all])
269
- command.append_flag('--local', opts[:local])
270
- command.append_flag('--remote', opts[:remote])
271
-
272
- if Kanrisuru::Util.present?(opts[:medium_type])
273
- raise ArgumentError, 'Invalid medium type' unless MEDIUM_TYPES.include?(opts[:medium_type])
274
-
275
- command.append_arg('--medium-type', opts[:medium_type])
276
- end
277
-
278
- command.append_array(opts[:repos])
279
-
280
- execute_shell(command)
281
-
282
- Kanrisuru::Result.new(command)
283
- end
284
-
285
- def zypper_add_repo(opts)
286
- command = Kanrisuru::Command.new('zypper')
287
- zypper_global_opts(command, opts)
288
-
289
- command << 'addrepo'
290
-
291
- command.append_flag('--check', opts[:check])
292
- command.append_flag('--no-check', opts[:no_check])
293
- command.append_flag('--enable', opts[:enable])
294
- command.append_flag('--disable', opts[:disable])
295
- command.append_flag('--refresh', opts[:refresh])
296
- command.append_flag('--no-refresh', opts[:no_refresh])
297
- command.append_flag('--keep-packages', opts[:keep_packages])
298
- command.append_flag('--no-keep-packages', opts[:no_keep_packages])
299
- command.append_flag('--gpgcheck', opts[:gpgcheck])
300
- command.append_flag('--gpgcheck-strict', opts[:gpgcheck_strict])
301
- command.append_flag('--gpgcheck-allow-unsigned', opts[:gpgcheck_allow_unsigned])
302
- command.append_flag('--gpgcheck-allow-unsigned-repo', opts[:gpgcheck_allow_unsigned_repo])
303
- command.append_flag('--gpgcheck-allow-unsigned-package', opts[:gpgcheck_allow_unsigned_package])
304
- command.append_flag('--no-gpgcheck', opts[:no_gpgcheck])
305
- command.append_flag('--default-gpgcheck', opts[:default_gpgcheck])
306
-
307
- command.append_arg('--priority', opts[:priority])
308
-
309
- zypper_repos_opt(command, opts)
310
-
311
- execute_shell(command)
312
-
313
- Kanrisuru::Result.new(command)
314
- end
315
-
316
- def zypper_remove_repo(opts)
317
- command = Kanrisuru::Command.new('zypper')
318
- zypper_global_opts(command, opts)
319
-
320
- command << 'removerepo'
321
-
322
- command.append_flag('--loose-auth', opts[:loose_auth])
323
- command.append_flag('--loose-query', opts[:loose_query])
324
- command.append_flag('--all', opts[:all])
325
- command.append_flag('--local', opts[:local])
326
- command.append_flag('--remote', opts[:remote])
327
-
328
- if Kanrisuru::Util.present?(opts[:media_type])
329
- raise ArgumentError, 'Invalid media type' unless ZYPPER_MEDIA_TYPES.include?(opts[:media_type])
330
-
331
- command.append_arg('--media-type', opts[:media_type])
332
- end
333
-
334
- command.append_array(opts[:repos])
335
-
336
- execute_shell(command)
337
-
338
- Kanrisuru::Result.new(command)
339
- end
340
-
341
- def zypper_rename_repo(opts)
342
- command = Kanrisuru::Command.new('zypper')
343
- zypper_global_opts(command, opts)
344
-
345
- command << 'renamerepo'
346
- command << opts[:repo]
347
- command << opts[:alias]
348
-
349
- execute_shell(command)
350
-
351
- Kanrisuru::Result.new(command)
352
- end
353
-
354
- def zypper_add_service(opts)
355
- command = Kanrisuru::Command.new('zypper')
356
- zypper_global_opts(command, opts)
357
- command << 'addservice'
358
-
359
- command.append_arg('--name', opts[:name])
360
-
361
- command.append_flag('--enable', opts[:enable])
362
- command.append_flag('--disable', opts[:disable])
363
- command.append_flag('--refresh', opts[:refresh])
364
- command.append_flag('--no-refresh', opts[:no_refresh])
365
-
366
- command.append_array(opts[:services])
367
-
368
- execute_shell(command)
369
-
370
- Kanrisuru::Result.new(command)
371
- end
372
-
373
- def zypper_remove_service(opts)
374
- command = Kanrisuru::Command.new('zypper')
375
- zypper_global_opts(command, opts)
376
-
377
- command << 'removeservice'
378
- command.append_flag('--loose-auth', opts[:loose_auth])
379
- command.append_flag('--loose-query', opts[:loose_query])
380
- command.append_array(opts[:services])
381
-
382
- execute_shell(command)
383
-
384
- Kanrisuru::Result.new(command)
385
- end
386
-
387
- def zypper_modify_service(opts)
388
- command = Kanrisuru::Command.new('zypper')
389
- zypper_global_opts(command, opts)
390
-
391
- command << 'modifyservice'
392
- command.append_arg('--name', opts[:name])
393
-
394
- command.append_flag('--enable', opts[:enable])
395
- command.append_flag('--disable', opts[:disable])
396
- command.append_flag('--refresh', opts[:refresh])
397
- command.append_flag('--no-refresh', opts[:no_refresh])
398
- command.append_flag('--all', opts[:all])
399
- command.append_flag('--local', opts[:local])
400
- command.append_flag('--remote', opts[:remote])
401
-
402
- command.append_arg('--ar-to-enable', opts[:ar_to_enable])
403
- command.append_arg('--ar-to-disable', opts[:ar_to_disable])
404
- command.append_arg('--rr-to-enable', opts[:rr_to_enable])
405
- command.append_arg('--rr-to-disable', opts[:rr_to_disable])
406
- command.append_arg('--cl-to-enable', opts[:cl_to_enable])
407
- command.append_arg('--cl-to-disable', opts[:cl_to_disable])
408
-
409
- if Kanrisuru::Util.present?(opts[:medium_type])
410
- raise ArgumentError, 'Invalid medium type' unless MEDIUM_TYPES.include?(opts[:medium_type])
411
-
412
- command.append_arg('--medium-type', opts[:medium_type])
413
- end
414
-
415
- execute_shell(command)
416
-
417
- Kanrisuru::Result.new(command)
418
- end
419
-
420
- def zypper_list_services(opts)
421
- command = Kanrisuru::Command.new('zypper')
422
- zypper_global_opts(command, opts)
423
-
424
- command << 'services'
425
- command.append_flag('--details')
426
-
427
- execute_shell(command)
428
-
429
- Kanrisuru::Result.new(command) do |cmd|
430
- lines = cmd.to_a
431
-
432
- rows = []
433
- lines.each do |line|
434
- next unless line.match(/^\d/)
435
-
436
- values = line.split('|')
437
- values = values.map(&:strip)
438
-
439
- rows << Service.new(
440
- values[0].to_i,
441
- values[1],
442
- values[2],
443
- values[3] == 'Yes',
444
- values[4].include?('Yes'),
445
- values[5] == 'Yes',
446
- values[6].to_i,
447
- values[7],
448
- values[8]
449
- )
450
- end
451
- rows
452
- end
453
- end
454
-
455
- def zypper_refresh_services(opts)
456
- command = Kanrisuru::Command.new('zypper')
457
- zypper_global_opts(command, opts)
458
-
459
- command << 'refresh-services'
460
- command.append_flag('--force', opts[:force])
461
- command.append_flag('--with-repos', opts[:with_repos])
462
- command.append_flag('--restore-status', opts[:restore_status])
463
-
464
- execute_shell(command)
465
-
466
- Kanrisuru::Result.new(command)
467
- end
468
-
469
- def zypper_add_lock(opts)
470
- command = Kanrisuru::Command.new('zypper')
471
- zypper_global_opts(command, opts)
472
- command << 'addlock'
473
-
474
- command.append_arg('--repo', opts[:repo])
475
- zypper_package_type_opt(command, opts)
476
-
477
- command << opts[:lock]
478
-
479
- execute_shell(command)
480
-
481
- Kanrisuru::Result.new(command)
482
- end
483
-
484
- def zypper_remove_lock(opts)
485
- command = Kanrisuru::Command.new('zypper')
486
- zypper_global_opts(command, opts)
487
- command << 'removelock'
488
-
489
- command.append_arg('--repo', opts[:repo])
490
- zypper_package_type_opt(command, opts)
491
-
492
- command << opts[:lock]
493
-
494
- execute_shell(command)
495
-
496
- Kanrisuru::Result.new(command)
497
- end
498
-
499
- def zypper_list_locks(opts)
500
- command = Kanrisuru::Command.new('zypper')
501
- zypper_global_opts(command, opts)
502
- command.append_flag('--quiet')
503
- command << 'locks'
504
-
505
- command.append_flag('--matches')
506
-
507
- execute_shell(command)
508
-
509
- Kanrisuru::Result.new(command) do |cmd|
510
- lines = cmd.to_a
511
-
512
- rows = []
513
- lines.each do |line|
514
- next if line == ''
515
-
516
- values = line.split(' | ')
517
- next if values.length != 5
518
- next if values[0] == '#' && values[4] == 'Repository'
519
-
520
- values = values.map(&:strip)
521
-
522
- rows << Lock.new(
523
- values[0].to_i,
524
- values[1],
525
- values[2].to_i,
526
- values[3],
527
- values[4]
528
- )
529
- end
530
-
531
- rows
532
- end
533
- end
534
-
535
- def zypper_clean_locks(opts)
536
- command = Kanrisuru::Command.new('zypper')
537
- zypper_global_opts(command, opts)
538
- command << 'cleanlocks'
539
-
540
- execute_shell(command)
541
-
542
- Kanrisuru::Result.new(command)
543
- end
544
-
545
- def zypper_info(opts)
546
- command = Kanrisuru::Command.new('zypper')
547
- zypper_global_opts(command, opts)
548
- command << 'info'
549
-
550
- zypper_repos_opt(command, opts)
551
- zypper_package_type_opt(command, opts)
552
-
553
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
554
- command << packages
555
-
556
- execute_shell(command)
557
-
558
- Kanrisuru::Result.new(command) do |cmd|
559
- lines = cmd.to_a
560
-
561
- rows = []
562
- current_row = nil
563
- description = ''
564
- skip_description = false
565
-
566
- lines.each do |line|
567
- case line
568
- when /^Repository/
569
- repository = extract_single_zypper_line(line)
570
- next if repository == ''
571
-
572
- unless current_row.nil?
573
- skip_description = false
574
- current_row.description = description.strip
575
- description = ''
576
- rows << current_row
577
- end
578
-
579
- current_row = PackageDetail.new
580
- current_row.repository = repository
581
- when /^Name/
582
- current_row.package = extract_single_zypper_line(line)
583
- when /^Version/
584
- current_row.version = extract_single_zypper_line(line)
585
- when /^Arch/
586
- current_row.architecture = extract_single_zypper_line(line)
587
- when /^Vendor/
588
- current_row.vendor = extract_single_zypper_line(line)
589
- when /^Support Level/
590
- current_row.support_level = extract_single_zypper_line(line)
591
- when /^Installed Size/
592
- size = Kanrisuru::Util::Bits.normalize_size(extract_single_zypper_line(line))
593
- current_row.install_size = size
594
- when /^Installed/
595
- value = extract_single_zypper_line(line)
596
- current_row.installed = value == 'Yes'
597
- when /^Status/
598
- current_row.status = extract_single_zypper_line(line)
599
- when /^Source package/
600
- current_row.source_package = extract_single_zypper_line(line)
601
- when /^Summary/
602
- current_row.summary = extract_single_zypper_line(line)
603
- when /^Description/
604
- description = extract_single_zypper_line(line)
605
- when /^Builds binary package/, /^Contents/
606
- skip_description = true
607
- else
608
- next if line == ''
609
- next if line.include?('Information for package')
610
- next if line.include?('---------------------------')
611
-
612
- description += " #{line.strip}" unless skip_description
613
- end
614
- end
615
-
616
- if current_row
617
- current_row.description = description.strip
618
- rows << current_row
619
- end
620
-
621
- rows
622
- end
623
- end
624
-
625
- def zypper_install(opts)
626
- command = Kanrisuru::Command.new('zypper')
627
- zypper_global_opts(command, opts)
628
- command << 'install'
629
-
630
- zypper_repos_opt(command, opts)
631
- zypper_package_type_opt(command, opts)
632
-
633
- command.append_arg('-n', opts[:name])
634
- command.append_arg('-f', opts[:force])
635
- command.append_flag('--oldpackage', opts[:oldpackage])
636
- command.append_arg('--from', opts[:from])
637
- command.append_arg('--capability', opts[:capability])
638
- command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
639
- command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])
640
- command.append_flag('--replacefiles', opts[:replacefiles])
641
-
642
- command.append_flag('--dry-run', opts[:dry_run])
643
- command.append_flag('--allow-unsigned-rpm', opts[:allow_unsigned_rpm])
644
-
645
- zypper_solver_opts(command, opts)
646
- zypper_download_and_install_opts(command, opts)
647
- zypper_expert_opts(command, opts)
648
-
649
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
650
- command << packages
651
-
652
- execute_shell(command)
653
-
654
- Kanrisuru::Result.new(command)
655
- end
656
-
657
- def zypper_verify(opts)
658
- command = Kanrisuru::Command.new('zypper')
659
- zypper_global_opts(command, opts)
660
- command << 'verify'
661
-
662
- command.append_flag('--dry-run', opts[:dry_run])
663
-
664
- zypper_repos_opt(command, opts)
665
- zypper_solver_opts(command, opts)
666
- zypper_expert_opts(command, opts)
667
-
668
- execute_shell(command)
669
-
670
- Kanrisuru::Result.new(command)
671
- end
672
-
673
- def zypper_source_install(opts)
674
- command = Kanrisuru::Command.new('zypper')
675
- zypper_global_opts(command, opts)
676
- command << 'sourceinstall'
677
-
678
- zypper_repos_opt(command, opts)
679
- command.append_flag('--build-deps-only', opts[:build_deps_only])
680
- command.append_flag('--no-build-deps', opts[:no_build_deps])
681
- command.append_flag('--download-only', opts[:download_only])
682
-
683
- execute_shell(command)
684
-
685
- Kanrisuru::Result.new(command)
686
- end
687
-
688
- def zypper_remove(opts)
689
- command = Kanrisuru::Command.new('zypper')
690
- zypper_global_opts(command, opts)
691
- command << 'remove'
692
-
693
- command.append_flag('--dry-run', opts[:dry_run])
694
- command.append_flag('--capability', opts[:capability])
695
-
696
- zypper_repos_opt(command, opts)
697
- zypper_package_type_opt(command, opts)
698
- zypper_solver_opts(command, opts)
699
-
700
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
701
- command << packages
702
-
703
- execute_shell(command)
704
- Kanrisuru::Result.new(command)
705
- end
706
-
707
- def zypper_install_new_recommends(opts)
708
- command = Kanrisuru::Command.new('zypper')
709
- zypper_global_opts(command, opts)
710
- command << 'install-new-recommends'
711
-
712
- command.append_flag('--dry-run', opts[:dry_run])
713
-
714
- zypper_repos_opt(command, opts)
715
- zypper_solver_opts(command, opts)
716
- zypper_expert_opts(command, opts)
717
-
718
- execute_shell(command)
719
-
720
- Kanrisuru::Result.new(command)
721
- end
722
-
723
- def zypper_purge_kernels(opts)
724
- command = Kanrisuru::Command.new('zypper')
725
- zypper_global_opts(command, opts)
726
- command << 'purge-kernels'
727
- command.append_flag('--dry-run', opts[:dry_run])
728
-
729
- execute_shell(command)
730
-
731
- Kanrisuru::Result.new(command)
732
- end
733
-
734
- def zypper_search(opts)
735
- command = Kanrisuru::Command.new('zypper')
736
- zypper_global_opts(command, opts)
737
- command << 'search'
738
-
739
- command.append_flag('--details')
740
- command.append_flag('--match-substrings', opts[:match_substrings])
741
- command.append_flag('--match-words', opts[:match_words])
742
- command.append_flag('--match-exact', opts[:match_exact])
743
- command.append_flag('--provides', opts[:provides])
744
- command.append_flag('--requires', opts[:requires])
745
- command.append_flag('--recommends', opts[:recommends])
746
- command.append_flag('--suggests', opts[:suggests])
747
- command.append_flag('--conflicts', opts[:conflicts])
748
- command.append_flag('--obsoletes', opts[:obsoletes])
749
- command.append_flag('--supplements', opts[:supplements])
750
- command.append_flag('--provides-pkg', opts[:provides_pkg])
751
- command.append_flag('--requires-pkg', opts[:requires_pkg])
752
- command.append_flag('--recommends-pkg', opts[:recommends_pkg])
753
- command.append_flag('--supplements-pkg', opts[:supplements_pkg])
754
- command.append_flag('--conflicts-pkg', opts[:conflicts_pkg])
755
- command.append_flag('--obsoletes-pkg', opts[:obsoletes_pkg])
756
- command.append_flag('--suggests-pkg', opts[:suggests_pkg])
757
- command.append_flag('--name', opts[:name])
758
- command.append_flag('--file-list', opts[:file_list])
759
- command.append_flag('--search-descriptions', opts[:search_descriptions])
760
- command.append_flag('--case-sensitive', opts[:case_sensitive])
761
- command.append_flag('--installed-only', opts[:installed_only])
762
- command.append_flag('--not-installed-only', opts[:not_installed_only])
763
- command.append_flag('--sort-by-name', opts[:sort_by_name])
764
- command.append_flag('--sort-by-repo', opts[:sort_by_repo])
765
-
766
- zypper_repos_opt(command, opts)
767
- zypper_package_type_opt(command, opts)
768
-
769
- packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
770
- command << packages
771
-
772
- execute_shell(command)
773
-
774
- Kanrisuru::Result.new(command) do |cmd|
775
- lines = cmd.to_a
776
-
777
- rows = []
778
- lines.each do |line|
779
- next if line == ''
780
-
781
- values = line.split('|')
782
- next if values.length != 6
783
-
784
- values = values.map(&:strip)
785
- next if values[0] == 'S' && values[5] == 'Repository'
786
-
787
- rows << SearchResult.new(
788
- values[5],
789
- values[1],
790
- values[0],
791
- values[2],
792
- values[3],
793
- values[4]
794
- )
795
- end
796
-
797
- rows
798
- end
799
- end
800
-
801
- def zypper_update(opts)
802
- command = Kanrisuru::Command.new('zypper')
803
- zypper_global_opts(command, opts)
804
- command << 'update'
805
-
806
- zypper_repos_opt(command, opts)
807
- zypper_package_type_opt(command, opts)
808
-
809
- command.append_flag('--replacefiles', opts[:replacefiles])
810
- command.append_flag('--dry-run', opts[:dry_run])
811
- command.append_flag('--best-effort', opts[:best_effort])
812
-
813
- zypper_solver_opts(command, opts)
814
- zypper_expert_opts(command, opts)
815
-
816
- execute_shell(command)
817
-
818
- Kanrisuru::Result.new(command)
819
- end
820
-
821
- def zypper_list_updates(opts)
822
- return zypper_list_patches(opts) if opts[:type] == 'patch'
823
-
824
- command = Kanrisuru::Command.new('zypper')
825
- zypper_global_opts(command, opts)
826
- command.append_flag('--quiet')
827
- command << 'list-updates'
828
-
829
- zypper_repos_opt(command, opts)
830
- zypper_package_type_opt(command, opts)
831
-
832
- command.append_flag('--all', opts[:all])
833
- command.append_flag('--best-effort', opts[:best_effort])
834
-
835
- zypper_expert_opts(command, opts)
836
-
837
- execute_shell(command)
838
-
839
- Kanrisuru::Result.new(command) do |cmd|
840
- lines = cmd.to_a
841
- lines.shift
842
-
843
- rows = []
844
- lines.each do |line|
845
- values = line.split(' | ')
846
- values = values.map(&:strip)
847
-
848
- rows << PackageUpdate.new(
849
- values[1],
850
- values[2],
851
- values[3],
852
- values[4],
853
- values[5]
854
- )
855
- end
856
-
857
- rows
858
- end
859
- end
860
-
861
- def zypper_list_patches(opts)
862
- command = Kanrisuru::Command.new('zypper')
863
- zypper_global_opts(command, opts)
864
- command.append_flag('--quiet')
865
- command << 'list-patches'
866
-
867
- command.append_arg('--bugzilla', opts[:bugzilla])
868
- command.append_arg('--cve', opts[:cve])
869
- command.append_arg('--date', opts[:date])
870
-
871
- zypper_patch_category_opt(command, opts)
872
- zypper_patch_severity_opt(command, opts)
873
-
874
- command.append_flag('--issues', opts[:issues])
875
- command.append_flag('--all', opts[:all])
876
- command.append_flag('--with-optional', opts[:with_optional])
877
- command.append_flag('--without-optional', opts[:without_optional])
878
-
879
- zypper_repos_opt(command, opts)
880
-
881
- execute_shell(command)
882
-
883
- Kanrisuru::Result.new(command) do |cmd|
884
- lines = cmd.to_a
885
- lines.shift
886
- lines.shift
887
-
888
- rows = []
889
- lines.each do |line|
890
- next if line == ''
891
-
892
- values = line.split(' | ')
893
- next if values.length != 7
894
-
895
- values = values.map(&:strip)
896
- next if values[0] == 'Repository' && values[6] == 'Summary'
897
-
898
- rows << PatchUpdate.new(
899
- values[0],
900
- values[1],
901
- values[2],
902
- values[3],
903
- values[4] == '---' ? '' : values[4],
904
- values[5],
905
- values[6]
906
- )
907
- end
908
-
909
- rows
910
- end
911
- end
912
-
913
- def zypper_patch_check(opts)
914
- command = Kanrisuru::Command.new('zypper')
915
- command.append_valid_exit_code(EXIT_INF_UPDATE_NEEDED)
916
- command.append_valid_exit_code(EXIT_INF_SEC_UPDATE_NEEDED)
917
-
918
- zypper_global_opts(command, opts)
919
- command.append_flag('--quiet')
920
- command << 'patch-check'
921
-
922
- command.append_flag('--updatestack-only', opts[:updatestack_only])
923
- command.append_flag('--with-optional', opts[:with_optional])
924
- command.append_flag('--without-optional', opts[:without_optional])
925
-
926
- zypper_repos_opt(command, opts)
927
-
928
- execute_shell(command)
929
-
930
- Kanrisuru::Result.new(command) do |cmd|
931
- lines = cmd.to_a
932
-
933
- rows = []
934
- lines.each do |line|
935
- next if line == ''
936
-
937
- values = line.split(' | ')
938
- next if values.length != 3
939
-
940
- values = values.map(&:strip)
941
- next if values[0] == 'Category'
942
-
943
- rows << PatchCount.new(
944
- values[0],
945
- values[1].to_i,
946
- values[2].to_i
947
- )
948
- end
949
-
950
- rows
951
- end
952
- end
953
-
954
- def zypper_patch(opts)
955
- command = Kanrisuru::Command.new('zypper')
956
- command.append_valid_exit_code(EXIT_INF_REBOOT_NEEDED)
957
- command.append_valid_exit_code(EXIT_INF_RESTART_NEEDED)
958
- zypper_global_opts(command, opts)
959
-
960
- command << 'patch'
961
-
962
- command.append_flag('--updatestack-only', opts[:updatestack_only])
963
- command.append_flag('--with-update', opts[:with_update])
964
- command.append_flag('--with-optional', opts[:with_optional])
965
- command.append_flag('--without-optional', opts[:without_optional])
966
- command.append_flag('--replacefiles', opts[:replacefiles])
967
- command.append_flag('--dry-run', opts[:dry_run])
968
-
969
- command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
970
- command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])
971
-
972
- command.append_arg('--bugzilla', opts[:bugzilla])
973
- command.append_arg('--cve', opts[:cve])
974
- command.append_arg('--date', opts[:date])
975
-
976
- zypper_patch_category_opt(command, opts)
977
- zypper_patch_severity_opt(command, opts)
978
- zypper_repos_opt(command, opts)
979
- zypper_solver_opts(command, opts)
980
- zypper_expert_opts(command, opts)
981
-
982
- execute_shell(command)
983
-
984
- Kanrisuru::Result.new(command)
985
- end
986
-
987
- def zypper_dist_upgrade(opts)
988
- command = Kanrisuru::Command.new('zypper')
989
- zypper_global_opts(command, opts)
990
- command << 'dist-upgrade'
991
-
992
- command.append_flag('--auto-agree-with-licenses', opts[:auto_agree_with_licenses])
993
- command.append_flag('--auto-agree-with-product-licenses', opts[:auto_agree_with_product_licenses])
994
- command.append_flag('--dry-run', opts[:dry_run])
995
-
996
- zypper_repos_opt(command, opts)
997
- zypper_solver_opts(command, opts)
998
- zypper_expert_opts(command, opts)
999
-
1000
- execute_shell(command)
1001
-
1002
- Kanrisuru::Result.new(command)
1003
- end
1004
-
1005
- def zypper_global_opts(command, opts)
1006
- command.append_flag('--non-interactive')
1007
- command.append_flag('--ignore-unknown')
1008
- command.append_flag('--no-color')
1009
- command.append_flag('--no-abbrev')
1010
- command.append_arg('--config', opts[:config_file])
1011
- end
1012
-
1013
- def zypper_solver_opts(command, opts)
1014
- command.append_flag('--debug-solver', opts[:debug_solver])
1015
- command.append_flag('--force-resolution', opts[:force_resolution])
1016
- command.append_flag('--no-force-resolution', opts[:no_force_resolution])
1017
-
1018
- solver_focus_mode = opts[:solver_focus_mode]
1019
- if Kanrisuru::Util.present?(solver_focus_mode) && SOLVER_FOCUS_MODES.include?(solver_focus_mode)
1020
- command.append_arg('--solver-focus', solver_focus_mode)
1021
- end
1022
-
1023
- command.append_flag('--clean-deps', opts[:clean_deps])
1024
- command.append_flag('--no-clean-deps', opts[:no_clean_deps])
1025
- end
1026
-
1027
- def zypper_download_and_install_opts(command, opts)
1028
- command.append_flag('--download-only', opts[:download_only])
1029
- command.append_flag('--download-in-advance', opts[:download_in_advance])
1030
- command.append_flag('--download-in-heaps', opts[:download_in_heaps])
1031
- command.append_flag('--download-as-needed', opts[:download_as_needed])
1032
- end
1033
-
1034
- def zypper_expert_opts(command, opts)
1035
- command.append_flag('--allow-downgrade', opts[:allow_downgrade])
1036
- command.append_flag('--no-allow-downgrade', opts[:no_allow_downgrade])
1037
- command.append_flag('--allow-name-change', opts[:allow_name_change])
1038
- command.append_flag('--no-allow-name-change', opts[:no_allow_name_change])
1039
- command.append_flag('--allow-arch-change', opts[:allow_arch_change])
1040
- command.append_flag('--no-allow-arch-change', opts[:no_allow_arch_change])
1041
- command.append_flag('--allow-vendor-change', opts[:allow_vendor_change])
1042
- command.append_flag('--no-allow-vendor-change', opts[:no_allow_vendor_change])
1043
- end
1044
-
1045
- def zypper_repos_opt(command, opts)
1046
- zypper_array_opt(command, opts[:repos], '--repo')
1047
- end
1048
-
1049
- def zypper_patch_category_opt(command, opts)
1050
- zypper_array_opt(command, opts[:category], '--category', PATCH_CATEGORIES)
1051
- end
1052
-
1053
- def zypper_patch_severity_opt(command, opts)
1054
- zypper_array_opt(command, opts[:severity], '--severity', PATCH_SEVERITIES)
1055
- end
1056
-
1057
- def zypper_array_opt(command, value, opt_value, array = nil)
1058
- return unless Kanrisuru::Util.present?(value)
1059
-
1060
- values = value.instance_of?(String) ? [value] : value
1061
- values.each do |v|
1062
- next if Kanrisuru::Util.present?(array) && !array.include?(v)
1063
-
1064
- command.append_arg(opt_value, v)
1065
- end
1066
- end
1067
-
1068
- def zypper_package_type_opt(command, opts)
1069
- type = opts[:type]
1070
-
1071
- command.append_arg('-t', type) if Kanrisuru::Util.present?(type) && PACKAGE_TYPES.include?(type)
1072
- end
1073
-
1074
- def extract_single_zypper_line(line)
1075
- values = line.split(': ', 2)
1076
- values.length == 2 ? values[1] : ''
1077
- end
1078
85
  end
1079
86
  end
1080
87
  end