zypper-onlinesearch 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +20 -19
- data/lib/zypper/onlinesearch/cli.rb +8 -4
- data/lib/zypper/onlinesearch/data.rb +31 -20
- data/lib/zypper/onlinesearch/version.rb +1 -1
- data/lib/zypper/onlinesearch/view.rb +13 -11
- data/lib/zypper/onlinesearch.rb +15 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc869b470d64f775fc321bd9b677a08a6f166d8d48e8341dc897d58cf3ee3cb
|
4
|
+
data.tar.gz: d9afc178408c4d609ba9e6c2f885e9b9a7a1fff389f9dcd2117aa4eadc1b2ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1345be095db1d73c03e2368a9bc5c4dcdee5036eef66c0e355cb0a8ab6704f2218f277056abe1773c8ec2f559ee9f962441cf77dc0729f8adf5f2b063cf452
|
7
|
+
data.tar.gz: 01d0bfdc95141355f6bbf51ce1c790e6582226dc08dced07155e7dd515af9e3e642da2ac87d870d4d209f70ca9358e97901710869df2f27f269521bd0769e34b
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zypper-onlinesearch (1.
|
4
|
+
zypper-onlinesearch (1.2.0)
|
5
5
|
iniparse
|
6
6
|
nokogiri
|
7
7
|
|
@@ -11,53 +11,54 @@ GEM
|
|
11
11
|
ast (2.4.2)
|
12
12
|
diff-lcs (1.5.0)
|
13
13
|
iniparse (1.5.0)
|
14
|
-
json (2.
|
15
|
-
mini_portile2 (2.8.
|
14
|
+
json (2.7.1)
|
15
|
+
mini_portile2 (2.8.5)
|
16
16
|
nokogiri (1.13.10)
|
17
17
|
mini_portile2 (~> 2.8.0)
|
18
18
|
racc (~> 1.4)
|
19
|
-
parallel (1.
|
20
|
-
parser (3.
|
19
|
+
parallel (1.24.0)
|
20
|
+
parser (3.3.0.5)
|
21
21
|
ast (~> 2.4.1)
|
22
|
-
|
22
|
+
racc
|
23
|
+
racc (1.7.3)
|
23
24
|
rainbow (3.1.1)
|
24
|
-
rake (13.0
|
25
|
-
regexp_parser (2.
|
26
|
-
rexml (3.2.
|
25
|
+
rake (13.1.0)
|
26
|
+
regexp_parser (2.9.0)
|
27
|
+
rexml (3.2.6)
|
27
28
|
rspec (3.12.0)
|
28
29
|
rspec-core (~> 3.12.0)
|
29
30
|
rspec-expectations (~> 3.12.0)
|
30
31
|
rspec-mocks (~> 3.12.0)
|
31
|
-
rspec-core (3.12.
|
32
|
+
rspec-core (3.12.2)
|
32
33
|
rspec-support (~> 3.12.0)
|
33
|
-
rspec-expectations (3.12.
|
34
|
+
rspec-expectations (3.12.3)
|
34
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
36
|
rspec-support (~> 3.12.0)
|
36
|
-
rspec-mocks (3.12.
|
37
|
+
rspec-mocks (3.12.6)
|
37
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
39
|
rspec-support (~> 3.12.0)
|
39
|
-
rspec-support (3.12.
|
40
|
-
rubocop (1.
|
40
|
+
rspec-support (3.12.1)
|
41
|
+
rubocop (1.50.2)
|
41
42
|
json (~> 2.3)
|
42
43
|
parallel (~> 1.10)
|
43
44
|
parser (>= 3.2.0.0)
|
44
45
|
rainbow (>= 2.2.2, < 4.0)
|
45
46
|
regexp_parser (>= 1.8, < 3.0)
|
46
47
|
rexml (>= 3.2.5, < 4.0)
|
47
|
-
rubocop-ast (>= 1.
|
48
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
48
49
|
ruby-progressbar (~> 1.7)
|
49
50
|
unicode-display_width (>= 2.4.0, < 3.0)
|
50
|
-
rubocop-ast (1.
|
51
|
+
rubocop-ast (1.30.0)
|
51
52
|
parser (>= 3.2.1.0)
|
52
|
-
rubocop-capybara (2.
|
53
|
+
rubocop-capybara (2.18.0)
|
53
54
|
rubocop (~> 1.41)
|
54
55
|
rubocop-rake (0.6.0)
|
55
56
|
rubocop (~> 1.0)
|
56
|
-
rubocop-rspec (2.
|
57
|
+
rubocop-rspec (2.20.0)
|
57
58
|
rubocop (~> 1.33)
|
58
59
|
rubocop-capybara (~> 2.17)
|
59
60
|
ruby-progressbar (1.13.0)
|
60
|
-
unicode-display_width (2.
|
61
|
+
unicode-display_width (2.5.0)
|
61
62
|
|
62
63
|
PLATFORMS
|
63
64
|
ruby
|
@@ -11,14 +11,14 @@ module Zypper
|
|
11
11
|
#
|
12
12
|
class OptParseMain
|
13
13
|
def self.parse(args)
|
14
|
-
options = Struct.new(:operation, :query, :refresh, :engine, :timeout, :
|
14
|
+
options = Struct.new(:operation, :query, :refresh, :engine, :timeout, :arch,
|
15
15
|
:distributions, :types, :number, :view, :format).new
|
16
16
|
options.operation = :search
|
17
17
|
options.query = ""
|
18
18
|
options.refresh = false
|
19
19
|
options.engine = :all # :opensuse, :packman
|
20
20
|
options.timeout = 20
|
21
|
-
options.
|
21
|
+
options.arch = :compatible # :all
|
22
22
|
options.distributions = :compatible # :all
|
23
23
|
options.types = %i[supported community experimental unsupported]
|
24
24
|
options.number = 0
|
@@ -86,8 +86,8 @@ module Zypper
|
|
86
86
|
opt.separator ""
|
87
87
|
opt.separator '"Page" and "Links" options:'
|
88
88
|
|
89
|
-
opt.on("--all-
|
90
|
-
options.
|
89
|
+
opt.on("--all-architectures", "Show all the available architectures") do
|
90
|
+
options.arch = :all
|
91
91
|
end
|
92
92
|
|
93
93
|
opt.on("--all-distributions", "Show all the available distributions") do
|
@@ -117,6 +117,10 @@ module Zypper
|
|
117
117
|
options.format = o.to_sym
|
118
118
|
end
|
119
119
|
|
120
|
+
opt.on("--architecture ARCHITECTURE", "Filter for packages with the specified ARCHITECTURE") do |o|
|
121
|
+
options.arch = o.to_sym
|
122
|
+
end
|
123
|
+
|
120
124
|
opt.on("--urls", "Show only the urls without headers") do
|
121
125
|
options.view = :urls
|
122
126
|
end
|
@@ -8,27 +8,33 @@ module Zypper
|
|
8
8
|
# Base class for page scraping.
|
9
9
|
#
|
10
10
|
class PageData
|
11
|
-
|
11
|
+
ARCHS = {
|
12
12
|
aarch64: "ARM v8.x 64-bit",
|
13
13
|
aarch64_ilp32: "ARM v8.x 64-bit ilp32 mode",
|
14
14
|
all: "All",
|
15
15
|
armv6l: "ARM v6",
|
16
16
|
armv7l: "ARM v7",
|
17
|
-
extra: "Extra",
|
18
17
|
i586: "Intel 32-bit",
|
19
18
|
i686: "Intel Pentium 32-bit",
|
20
|
-
lang: "Language",
|
21
19
|
lsrc: "Language source",
|
22
20
|
noarch: "No architecture",
|
23
21
|
ppc64le: "PowerPC 64-bit little-endian",
|
24
22
|
ppc64: "PowerPC 64-bit",
|
25
23
|
ppc: "PowerPC",
|
26
|
-
repo: "Repository",
|
27
24
|
riscv64: "Risc v64",
|
28
25
|
s390x: "IBM System/390",
|
29
26
|
src: "Source",
|
30
|
-
x86_64: "Intel/AMD 64-bit"
|
31
|
-
|
27
|
+
x86_64: "Intel/AMD 64-bit"
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
FORMATS = {
|
31
|
+
all: "All",
|
32
|
+
extra: "Extra",
|
33
|
+
lang: "Language",
|
34
|
+
repo: "Repository",
|
35
|
+
src: "Source",
|
36
|
+
ymp: "1 Click Install",
|
37
|
+
rpm: "RPM"
|
32
38
|
}.freeze
|
33
39
|
|
34
40
|
def initialize(page)
|
@@ -175,7 +181,8 @@ module Zypper
|
|
175
181
|
|
176
182
|
def extract(ver, res, type, xpath_group, xpath_version, xpath_link)
|
177
183
|
repo = ""
|
178
|
-
format =
|
184
|
+
format = :none
|
185
|
+
arch = :noarch
|
179
186
|
version = nil
|
180
187
|
|
181
188
|
ver.xpath(xpath_group).each do |pack|
|
@@ -187,8 +194,8 @@ module Zypper
|
|
187
194
|
@old_version = version
|
188
195
|
end
|
189
196
|
|
190
|
-
if
|
191
|
-
format =
|
197
|
+
if pack.text.strip =~ /1 Click Install/
|
198
|
+
format = :ymp
|
192
199
|
else
|
193
200
|
repo = pack.text.strip
|
194
201
|
if repo.empty?
|
@@ -202,14 +209,14 @@ module Zypper
|
|
202
209
|
|
203
210
|
if repo =~ /Expert Download/
|
204
211
|
res[:versions] << { distro: ver.text.gsub(/:/, " "), link: link, type: type,
|
205
|
-
repo: @old_repo, format: :extra, version: version }
|
212
|
+
repo: @old_repo, format: :extra, arch: arch, version: version }
|
206
213
|
next
|
207
214
|
end
|
208
215
|
|
209
216
|
next if format.to_s.empty? || link.include?("/package/show/")
|
210
217
|
|
211
218
|
res[:versions] << { distro: ver.text, link: link, type: type, repo: repo,
|
212
|
-
format: format, version: version }
|
219
|
+
format: format, arch: arch, version: version }
|
213
220
|
end
|
214
221
|
end
|
215
222
|
|
@@ -230,7 +237,7 @@ module Zypper
|
|
230
237
|
XPATH_PACKAGES = '//td[@id="package-details-left"]//tbody/tr'
|
231
238
|
XPATH_VERSION = ".//td[1]"
|
232
239
|
XPATH_DISTRO = ".//td[2]"
|
233
|
-
|
240
|
+
XPATH_ARCH = ".//td[3]"
|
234
241
|
XPATH_LINK = ".//a/@href"
|
235
242
|
|
236
243
|
def data
|
@@ -243,10 +250,10 @@ module Zypper
|
|
243
250
|
@page.xpath(XPATH_PACKAGES).each do |pack|
|
244
251
|
version = pack.xpath(XPATH_VERSION).text.split("-")[0].to_s
|
245
252
|
distro = pack.xpath(XPATH_DISTRO).text.gsub(/_/, " ")
|
246
|
-
|
253
|
+
arch = pack.xpath(XPATH_ARCH).text.strip.to_sym
|
247
254
|
link = pack.xpath(XPATH_LINK).text
|
248
255
|
|
249
|
-
res[:versions] << { format:
|
256
|
+
res[:versions] << { format: :extra, arch: arch, version: version, distro: distro,
|
250
257
|
type: :supported, link: "http://packman.links2linux.org#{link}",
|
251
258
|
repo: "Packman" }
|
252
259
|
end
|
@@ -272,7 +279,7 @@ module Zypper
|
|
272
279
|
def data
|
273
280
|
res = { versions: [] }
|
274
281
|
|
275
|
-
extract(res,
|
282
|
+
extract(res, :noarch, XPATH_REPO, XPATH_REPO_DISTRO, XPATH_REPO_LINK)
|
276
283
|
extract(res, -2, XPATH_PACKAGE_GROUP, XPATH_PACKAGE_DISTRO, XPATH_PACKAGE_LINK)
|
277
284
|
|
278
285
|
res
|
@@ -280,7 +287,7 @@ module Zypper
|
|
280
287
|
|
281
288
|
private
|
282
289
|
|
283
|
-
def extract(res,
|
290
|
+
def extract(res, arch_idx, xpath_group, xpath_distro, xpath_link)
|
284
291
|
@page.xpath(xpath_group).each do |section|
|
285
292
|
distro = ""
|
286
293
|
section.xpath(xpath_distro).each do |subsection|
|
@@ -293,7 +300,8 @@ module Zypper
|
|
293
300
|
link = link.gsub("\n", " ").scan(%r{(https://[^ \n]+)}).pop.pop
|
294
301
|
res[:versions] << {
|
295
302
|
distro: distro,
|
296
|
-
format: File.basename(link).split(".")[
|
303
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
304
|
+
arch: arch_idx.is_a?(Integer) ? File.basename(link).split(".")[arch_idx].to_sym : arch_idx,
|
297
305
|
link: link
|
298
306
|
}
|
299
307
|
end
|
@@ -319,18 +327,20 @@ module Zypper
|
|
319
327
|
link = pack.text
|
320
328
|
res[:versions] << {
|
321
329
|
distro: distro,
|
322
|
-
format: File.basename(link).split(".")[-
|
330
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
331
|
+
arch: File.basename(link).split(".")[-2].to_sym,
|
323
332
|
link: URL + link
|
324
333
|
}
|
325
334
|
end
|
326
335
|
|
327
336
|
link = res[:versions].last[:link]
|
328
|
-
is_lang = (File.basename(link) =~ /-lang/) && (res[:versions].last[:
|
337
|
+
is_lang = (File.basename(link) =~ /-lang/) && (res[:versions].last[:arch] == :noarch)
|
329
338
|
|
330
339
|
link = @page.xpath(XPATH_LINK_SRC).text
|
331
340
|
res[:versions] << {
|
332
341
|
distro: distro,
|
333
|
-
format:
|
342
|
+
format: File.basename(link).split(".")[-1].to_sym,
|
343
|
+
arch: is_lang ? :lsrc : File.basename(link).split(".")[-2].to_sym,
|
334
344
|
link: URL + link
|
335
345
|
}
|
336
346
|
|
@@ -339,6 +349,7 @@ module Zypper
|
|
339
349
|
res[:versions] << {
|
340
350
|
distro: distro,
|
341
351
|
format: :ymp,
|
352
|
+
arch: :noarch,
|
342
353
|
link: URL + link
|
343
354
|
}
|
344
355
|
end
|
@@ -124,7 +124,7 @@ module Zypper
|
|
124
124
|
def self.general(args)
|
125
125
|
engine = args[:engine].bold.red
|
126
126
|
distro = args[:distro].bold.blue
|
127
|
-
arch = PageData::
|
127
|
+
arch = PageData::ARCHS[args[:architecture]].bold
|
128
128
|
cache = if args[:refresh]
|
129
129
|
"Off".bold
|
130
130
|
elsif args[:cache_time]
|
@@ -135,7 +135,7 @@ module Zypper
|
|
135
135
|
|
136
136
|
puts ""
|
137
137
|
puts "=" * SEPARATOR_LENGTH
|
138
|
-
puts "#{"Parameters: ".bold} Engine: #{engine} | OS: #{distro} |
|
138
|
+
puts "#{"Parameters: ".bold} Engine: #{engine} | OS: #{distro} | Arch.: #{arch} | Cache: #{cache}"
|
139
139
|
puts "=" * SEPARATOR_LENGTH
|
140
140
|
puts "#{"Name: ".bold}#{args[:name]}"
|
141
141
|
puts "#{"Summary: ".bold}#{args[:short_description]}" if args[:short_description]
|
@@ -264,7 +264,7 @@ module Zypper
|
|
264
264
|
def self.header(args)
|
265
265
|
super args
|
266
266
|
separator
|
267
|
-
puts "#{" " * 3} # | Format | Link"
|
267
|
+
puts "#{" " * 3} # | Format | Arch | Link"
|
268
268
|
separator
|
269
269
|
end
|
270
270
|
|
@@ -273,7 +273,11 @@ module Zypper
|
|
273
273
|
def self.link(args)
|
274
274
|
nl = args[:num].to_s.length
|
275
275
|
fl = args[:pack][:format].to_s.length
|
276
|
-
|
276
|
+
al = args[:pack][:arch].to_s.length
|
277
|
+
# rubocop:disable Style/LineEndConcatenation
|
278
|
+
puts "#{" " * (5 - nl)}#{args[:num]} | #{" " * (6 - fl)}#{args[:pack][:format]} |" +
|
279
|
+
"#{" " * (8 - al)}#{args[:pack][:arch]} | #{args[:pack][:link]}"
|
280
|
+
# rubocop:enable Style/LineEndConcatenation
|
277
281
|
separator
|
278
282
|
end
|
279
283
|
end
|
@@ -289,16 +293,14 @@ module Zypper
|
|
289
293
|
end
|
290
294
|
|
291
295
|
def self.link(args)
|
292
|
-
alt_format = if args[:pack][:format].to_s == PageData::FORMATS[args[:pack][:format]]
|
293
|
-
""
|
294
|
-
else
|
295
|
-
" (#{PageData::FORMATS[args[:pack][:format]]})"
|
296
|
-
end
|
297
296
|
n_length = args[:num].to_s.length
|
298
|
-
|
297
|
+
alt_format = PageData::FORMATS[args[:pack][:format]]
|
298
|
+
alt_arch = PageData::ARCHS[args[:pack][:arch]]
|
299
|
+
|
300
|
+
puts "#{" " * (5 - n_length)}#{args[:num]} | Format: #{args[:pack][:format].to_s.bold} (#{alt_format})"
|
301
|
+
puts "#{" " * 5} | Architecture: #{args[:pack][:arch]} (#{alt_arch})"
|
299
302
|
puts "#{" " * 5} | Distribution: #{args[:pack][:distro]}"
|
300
303
|
puts "#{" " * 5} | Link: #{args[:pack][:link]}"
|
301
|
-
|
302
304
|
separator
|
303
305
|
end
|
304
306
|
end
|
data/lib/zypper/onlinesearch.rb
CHANGED
@@ -22,7 +22,7 @@ module Zypper
|
|
22
22
|
refresh: options.refresh,
|
23
23
|
query: options.query
|
24
24
|
@release = Release.new
|
25
|
-
@
|
25
|
+
@arch = options.arch
|
26
26
|
@distributions = options.distributions
|
27
27
|
@format = options.format
|
28
28
|
@types = options.types
|
@@ -93,9 +93,7 @@ module Zypper
|
|
93
93
|
|
94
94
|
collection = collection.pop
|
95
95
|
collection.each do |pack|
|
96
|
-
if
|
97
|
-
packages << pack
|
98
|
-
else
|
96
|
+
if pack[:format] == :extra
|
99
97
|
result = RequestList.new operation: :links,
|
100
98
|
engine: engine,
|
101
99
|
timeout: @search.timeout,
|
@@ -110,9 +108,11 @@ module Zypper
|
|
110
108
|
f[:repo] = pack[:repo]
|
111
109
|
f[:version] ||= pack[:version]
|
112
110
|
f[:distro] ||= pack[:distro]
|
113
|
-
packages << f if package_select?(f)
|
111
|
+
packages << f if package_select?(f, true)
|
114
112
|
end
|
115
113
|
end
|
114
|
+
elsif package_select?(pack, true)
|
115
|
+
packages << pack
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -154,19 +154,24 @@ module Zypper
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def architecture
|
157
|
-
@
|
157
|
+
@arch == :compatible ? @release.arch : :all
|
158
158
|
end
|
159
159
|
|
160
|
-
def package_select?(package)
|
161
|
-
res =
|
162
|
-
|
163
|
-
|
160
|
+
def package_select?(package, format_and_arch = false)
|
161
|
+
res = if @arch == :compatible
|
162
|
+
[:src, :noarch, @release.arch].include?(package[:arch])
|
163
|
+
else
|
164
|
+
format_and_arch ? (@arch == package[:arch]) : true
|
165
|
+
end
|
166
|
+
|
164
167
|
if @distributions == :compatible
|
165
168
|
res &&= ((package[:distro] == :current) ||
|
166
169
|
package[:distro].match?(Regexp.new(@release.pretty_name, "i")))
|
167
170
|
end
|
168
171
|
res = false unless @types.include?(package[:type])
|
169
172
|
|
173
|
+
res &&= (@format == package[:format]) if @format != :all && format_and_arch
|
174
|
+
|
170
175
|
res
|
171
176
|
end
|
172
177
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zypper-onlinesearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Mucciante
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iniparse
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
rubygems_version: 3.
|
94
|
+
rubygems_version: 3.4.3
|
95
95
|
signing_key:
|
96
96
|
specification_version: 4
|
97
97
|
summary: Zypper addon to search packages online through the openSUSE software search
|