zypper-upgraderepo 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f063f691c5f780a94c2016e4be62f636c4e70e6f21377993b3a2b6c57d7ca59
4
- data.tar.gz: 68b13bc527f0f87456a4613c2ed7c3ab23214991a6a8eea09c0d94b8da7c7c73
3
+ metadata.gz: 3a50f5e64f656b77d574d69068ef2663d9387e9607b1a8f4fa54e4428caf980d
4
+ data.tar.gz: e0d52912c451b2d3fca3e230cbd601f1dde2ec8830ca2e7ebbee451b4f425844
5
5
  SHA512:
6
- metadata.gz: 78c01cb2796e0ada9252bccbbcf027b2e9f81e09d593f6b2f682c86d717e348c02ee58ba2008696edccc441288bb8ad569dc90d42d362c5acd94945d8580f82e
7
- data.tar.gz: b406a9567d05634b2c4f906e5fb925b6d9ae78275f9f4fd42c920b1ea2bac696d14db2ac081b2f40ed7bd331eeb87e38a6ceec8563c0a2a6103985d8dd79d662
6
+ metadata.gz: 46fab3ffa2117323ca0fc13bf51dd6f699a7af3b949abfef30ebd57323c54659760846fd1e3ae33b711171e8fd6b8d9c2db970631c401b97031486c8c45e718f
7
+ data.tar.gz: 576992e8186033757a0b5d6fc2cba6a9ac061c0862ceac78f9a799e7a7ab0135229dfd09f55334485a2bc919dd98d83bfe91d5936571e0daff0d152385deda68
data/Gemfile.lock CHANGED
@@ -12,19 +12,19 @@ GEM
12
12
  iniparse (1.5.0)
13
13
  minitar (0.9)
14
14
  rake (13.0.6)
15
- rspec (3.10.0)
16
- rspec-core (~> 3.10.0)
17
- rspec-expectations (~> 3.10.0)
18
- rspec-mocks (~> 3.10.0)
19
- rspec-core (3.10.1)
20
- rspec-support (~> 3.10.0)
21
- rspec-expectations (3.10.1)
15
+ rspec (3.12.0)
16
+ rspec-core (~> 3.12.0)
17
+ rspec-expectations (~> 3.12.0)
18
+ rspec-mocks (~> 3.12.0)
19
+ rspec-core (3.12.0)
20
+ rspec-support (~> 3.12.0)
21
+ rspec-expectations (3.12.2)
22
22
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.10.0)
24
- rspec-mocks (3.10.2)
23
+ rspec-support (~> 3.12.0)
24
+ rspec-mocks (3.12.3)
25
25
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-support (3.10.3)
26
+ rspec-support (~> 3.12.0)
27
+ rspec-support (3.12.0)
28
28
 
29
29
  PLATFORMS
30
30
  ruby
@@ -36,4 +36,4 @@ DEPENDENCIES
36
36
  zypper-upgraderepo!
37
37
 
38
38
  BUNDLED WITH
39
- 2.2.19
39
+ 2.4.3
data/README.md CHANGED
@@ -29,26 +29,33 @@ in the related [project page][project_page] on my blog.
29
29
 
30
30
  ## Usage
31
31
 
32
+ ***Warning!!! The executables name prior the 1.8.0 version is zypper-upgraderepo, unfortunately the
33
+ RPM package installation introduces annoying copies of the same executable having a version appended
34
+ (zypper-upgraderepo.version, zypper-upgraderepo.rubyversion, zypper-upgraderepo.rubyversion.version)
35
+ interpreted by zypper itself as different subcommands. So I considered more convenient to remove the
36
+ zypper prefix from the original executable and let the sole zypper-upgraderepo-plugin package install
37
+ it as a zypper plugin.***
38
+
32
39
  To check the availability of the current repositories:
33
40
  ```shell
34
- $ zypper-upgraderepo
41
+ $ upgraderepo
35
42
  ```
36
43
 
37
44
  To check the availability of the next version repositories:
38
45
  ```shell
39
- $ zypper-upgraderepo --check-next
46
+ $ upgraderepo --check-next
40
47
  ```
41
48
 
42
49
  To upgrade the repositories to the next version:
43
50
  ```shell
44
- $ sudo zypper-upgraderepo --upgrade
51
+ $ sudo upgraderepo --upgrade
45
52
  ```
46
53
 
47
54
  ## Get help
48
55
 
49
56
  Where to start:
50
57
  ```shell
51
- $ zypper-upgraderepo --help
58
+ $ upgraderepo --help
52
59
  ```
53
60
 
54
61
  ## More Help:
File without changes
@@ -34,7 +34,7 @@ module Zypper
34
34
  if ENV['ZYPPER_UPGRADEREPO']
35
35
  opt.banner = 'Usage: zypper upgraderepo [OPTIONS] [OPERATION]'
36
36
  else
37
- opt.banner = 'Usage: zypper-upgraderepo [OPTIONS] [OPERATION]'
37
+ opt.banner = 'Usage: upgraderepo [OPTIONS] [OPERATION]'
38
38
  end
39
39
 
40
40
  opt.separator ''
@@ -67,6 +67,10 @@ module Zypper
67
67
  options.operation = :reset
68
68
  end
69
69
 
70
+ opt.on('-t', '--update', 'Update the repositories to the current OS version') do |v|
71
+ options.operation = :update
72
+ end
73
+
70
74
  opt.on('-u', '--upgrade', 'Upgrade to the next version available') do |o|
71
75
  options.operation = :upgrade_to_next
72
76
  end
@@ -126,8 +130,8 @@ module Zypper
126
130
  options.only_enabled = true
127
131
  end
128
132
 
129
- opt.on('--only-repo <NUMBER>[,NUMBER2,...]', 'Include only the repositories specified by NUMBER') do |o|
130
- options.only_repo = o.split(',').map(&:to_i)
133
+ opt.on('--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]', 'Include only the repositories specified by a NUMBER or a string matching the NAME, @ALIAS, #URL, or &ANY of them') do |o|
134
+ options.only_repo = o.split(',')
131
135
  end
132
136
 
133
137
  opt.on('--only-invalid', 'Show only invalid repositories') do |o|
@@ -153,7 +157,7 @@ module Zypper
153
157
  options.sort_by = :priority
154
158
  end
155
159
 
156
- opt.on('--ini', 'Output the result in Ini format') do |o|
160
+ opt.on('--ini', 'Output the result as INI format') do |o|
157
161
  options.view = :ini
158
162
  end
159
163
 
@@ -165,6 +169,9 @@ module Zypper
165
169
  options.view = :report
166
170
  end
167
171
 
172
+ opt.on('--solved', 'Output as INI with the suggestions for the invalid repositories applied') do |o|
173
+ options.view = :solved
174
+ end
168
175
 
169
176
  unless ENV['ZYPPER_UPGRADEREPO']
170
177
  opt.separator ''
@@ -12,6 +12,10 @@ module Zypper
12
12
 
13
13
  UNSTABLE_VERSION = '15.5'
14
14
 
15
+ OS_RELEASE_FILE = '/etc/os-release'
16
+
17
+ SUSE_RELEASE_FILE = '/etc/SuSE-release'
18
+
15
19
  def initialize(options)
16
20
 
17
21
  if options.allow_unstable
@@ -20,10 +24,10 @@ module Zypper
20
24
  @unstable = true
21
25
  end
22
26
 
23
- fname = if File.exist? '/etc/os-release'
24
- '/etc/os-release'
25
- elsif File.exist? '/etc/SuSE-release'
26
- '/etc/SuSE-release'
27
+ fname = if File.exist? self.class::OS_RELEASE_FILE
28
+ self.class::OS_RELEASE_FILE
29
+ elsif File.exist? self.class::SUSE_RELEASE_FILE
30
+ self.class::SUSE_RELEASE_FILE
27
31
  else
28
32
  raise ReleaseFileNotFound
29
33
  end
@@ -22,7 +22,7 @@ module Zypper
22
22
  @list = []
23
23
  @cpu_arch, @arch = `rpm --eval "%cpu_arch;%_arch"`.tr("\n", '').split(';')
24
24
 
25
- Dir.glob(File.join(REPOSITORY_PATH, '*.repo')).each do |i|
25
+ Dir.glob(File.join(self.class::REPOSITORY_PATH, '*.repo')).each do |i|
26
26
  r = Request.build(Repository.new(i), options.timeout)
27
27
  @list << r
28
28
  end
@@ -32,6 +32,8 @@ module Zypper
32
32
 
33
33
  @list.sort_by! { |x| x[:repo].send(options.sort_by) } if options.sort_by != :alias
34
34
 
35
+ @only_repo = select_repos(@only_repo) unless @only_repo.nil?
36
+
35
37
  load_overrides(options.overrides_filename) if options.overrides_filename
36
38
  end
37
39
 
@@ -83,6 +85,41 @@ module Zypper
83
85
 
84
86
  private
85
87
 
88
+ def select_repos(repos)
89
+ res = []
90
+ repos.each do |r|
91
+ if r.to_i > 0
92
+ res.push r.to_i
93
+ elsif r =~ /^\ *@.*/
94
+ a = r.gsub(/@/, '').strip
95
+ @list.select { |x| x[:repo].alias.match?(Regexp.new(a, 'i')) }.each do |l|
96
+ res.push l[:num]
97
+ end
98
+ elsif r =~ /^\ *\#.*/
99
+ u = r.gsub(/\#/, '').strip
100
+ @list.select { |x| x[:repo].url.match?(Regexp.new(u, 'i')) }.each do |l|
101
+ res.push l[:num]
102
+ end
103
+ elsif r =~ /^\ *\&.*/
104
+ s = r.gsub(/\&/, '').strip
105
+ @list.select do |x|
106
+ x[:repo].alias.match?(Regexp.new(s, 'i')) ||
107
+ x[:repo].name.match?(Regexp.new(s, 'i')) ||
108
+ x[:repo].url.match?(Regexp.new(s, 'i'))
109
+ end.each do |l|
110
+ res.push l[:num]
111
+ end
112
+ else
113
+ n = r.strip
114
+ @list.select { |x| x[:repo].name.match?(Regexp.new(n, 'i')) }.each do |l|
115
+ res.push l[:num]
116
+ end
117
+ end
118
+ end
119
+
120
+ res.uniq
121
+ end
122
+
86
123
  def expand_variables(str, version)
87
124
  str.gsub(/\$releasever_major/, version.split('.')[0])
88
125
  .gsub(/\$releasever_minor/, version.split('.')[1])
@@ -67,17 +67,21 @@ module Zypper
67
67
  http.request(request)
68
68
  end
69
69
 
70
- def ping(uri = nil, head = true)
70
+ def ping(uri = nil, head = true, cache = true)
71
71
  begin
72
72
  if @page.nil? || uri
73
- @page = get_request(uri, head)
73
+ if cache
74
+ @page = get_request(uri, head)
75
+ else
76
+ unpage = get_request(uri, head)
77
+ end
74
78
  end
75
79
  rescue SocketError
76
80
  raise NoConnection
77
81
  rescue Net::OpenTimeout
78
82
  @page = Net::HTTPRequestTimeOut.new('1.1', '', '')
79
83
  end
80
- @page
84
+ cache ? @page : unpage
81
85
  end
82
86
 
83
87
  end
@@ -112,8 +116,7 @@ module Zypper
112
116
  end
113
117
 
114
118
  def has_repodata?(uri)
115
- ping(repodata_uri(uri))
116
- available?
119
+ ping(repodata_uri(uri), true, false).is_a?(Net::HTTPSuccess)
117
120
  end
118
121
 
119
122
  def subfolders(uri)
@@ -6,7 +6,9 @@ module Zypper
6
6
  def traverse_url(uri, version)
7
7
  ping(uri)
8
8
 
9
- if forbidden?
9
+ if available? && !has_repodata?(uri)
10
+ return { url: '', message: 'This repository doesn\'t seem working and should be disabled.'}
11
+ elsif forbidden?
10
12
  res = { url: url, message: 'Can\'t navigate through the repository!' }
11
13
  elsif available? && uri.to_s =~ /#{version}/
12
14
  res = traverse_url_forward(uri, version)
@@ -1,5 +1,5 @@
1
1
  module Zypper
2
2
  module Upgraderepo
3
- VERSION = "1.7.1"
3
+ VERSION = "1.8.0"
4
4
  end
5
5
  end
@@ -215,7 +215,7 @@ module Zypper
215
215
  end
216
216
 
217
217
  def self.alternative(num, repo, max_col, alt)
218
- self.info num, 'Not Found', repo, false
218
+ self.info num, 'Not Found', repo, false, alt[:url]
219
219
  puts "hint=#{alt[:message]}"
220
220
  puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
221
221
  end
@@ -254,12 +254,12 @@ module Zypper
254
254
 
255
255
  private
256
256
 
257
- def self.info(num, status, repo, valid = true)
257
+ def self.info(num, status, repo, valid = true, suggested = '')
258
258
  @@number = num
259
259
  puts "[repository_#{num}]"
260
260
  puts "name=#{repo.name}"
261
261
  puts "alias=#{repo.alias}"
262
- puts "old_url=#{repo.old_url}" if repo.upgraded?
262
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
263
263
  if valid
264
264
  if repo.unversioned? && repo.old_url
265
265
  puts <<-'HEADER'.gsub(/^ +/, '')
@@ -273,7 +273,7 @@ module Zypper
273
273
  elsif repo.enabled?
274
274
  puts <<-'HEADER'.gsub(/^ +/, '')
275
275
  # The interpolated URL is invalid, try overriding with the one suggested
276
- # in the fields below or find it manually starting from the old_url.
276
+ # in the field below or find it manually starting from the old_url.
277
277
  # The alternatives are:
278
278
  # 1. Waiting for a repository upgrade;
279
279
  # 2. Change the provider for the related installed packages;
@@ -295,6 +295,71 @@ module Zypper
295
295
  end
296
296
  end
297
297
 
298
+
299
+ class Solved < Ini
300
+
301
+ def self.alternative(num, repo, max_col, alt)
302
+ self.info num, 'Not Found', repo, false, alt[:url]
303
+ puts "hint=#{alt[:message]}"
304
+ puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
305
+ end
306
+
307
+
308
+ private
309
+
310
+ def self.info(num, status, repo, valid = true, suggested = '')
311
+ @@number = num
312
+ puts "[repository_#{num}]"
313
+ puts "name=#{repo.name}"
314
+ puts "alias=#{repo.alias}"
315
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
316
+ if valid
317
+ if repo.unversioned? && repo.old_url
318
+ puts <<-'HEADER'.gsub(/^ +/, '')
319
+ # The repository is unversioned: its packages should be perfectly
320
+ # working regardless the distribution version, that because all the
321
+ # required dependencies are included in the repository itself and
322
+ # automatically picked up.
323
+ HEADER
324
+ end
325
+ puts "url=#{repo.url}"
326
+ elsif repo.enabled?
327
+ unless suggested.empty?
328
+ puts <<-'HEADER'.gsub(/^ +/, '')
329
+ # The interpolated URL is invalid, but the script found an alternative
330
+ # URL which will be used to override the old value.
331
+ # Unfortunately the script is not able to know if the found URL is exact,
332
+ # so review the result before accepting any change, and in case want
333
+ # to disable it, just turn the "enabled" field below to "No".
334
+ #
335
+ HEADER
336
+ puts "url=#{suggested}"
337
+ puts 'enabled=Yes'
338
+ else
339
+ puts <<-'HEADER'.gsub(/^ +/, '')
340
+ # The interpolated URL is invalid, and the script has not been able to find
341
+ # an alternative. The best thing to do here is to disable the repository.
342
+ # In case a valid alternative will be discovered, just replace its URL in
343
+ # the "url" field below and make sure to re-enable the repository by switching
344
+ # the "enabled" field to "Yes" again.
345
+ #
346
+ HEADER
347
+ puts "url=#{repo.old_url}"
348
+ puts 'enabled=No'
349
+ end
350
+ else
351
+ puts <<-'HEADER'.gsub(/^ +/, '')
352
+ # The interpolated URL is invalid, but being the repository disabled you can
353
+ # keep the old_url in the field below, it will be ignored anyway during the
354
+ # system update and upgrade process until the repository is enabled again.
355
+ HEADER
356
+ puts "url=#{suggested.empty? ? repo.old_url : suggested}"
357
+ end
358
+ puts "priority=#{repo.priority}"
359
+ puts "status=#{status}"
360
+ end
361
+ end
362
+
298
363
  end
299
364
  end
300
365
  end
@@ -33,6 +33,7 @@ module Zypper
33
33
  end
34
34
 
35
35
  def check_current
36
+ @repos.upgrade!(@os_release.current)
36
37
  check_repos(@os_release.current)
37
38
  end
38
39
 
@@ -79,6 +80,11 @@ module Zypper
79
80
  @view_class.status(@os_release)
80
81
  end
81
82
 
83
+ def update
84
+ @repos.upgrade!(@os_release.current)
85
+ upgrade_repos(@os_release.current)
86
+ end
87
+
82
88
  private
83
89
 
84
90
  def check_repos(version)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zypper-upgraderepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.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: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,7 +85,7 @@ description: This is just a complement to zypper command which helps to upgrade
85
85
  email:
86
86
  - fabio.mucciante@gmail.com
87
87
  executables:
88
- - zypper-upgraderepo
88
+ - upgraderepo
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
@@ -97,7 +97,7 @@ files:
97
97
  - Rakefile
98
98
  - bin/console
99
99
  - bin/setup
100
- - exe/zypper-upgraderepo
100
+ - exe/upgraderepo
101
101
  - lib/zypper/upgraderepo.rb
102
102
  - lib/zypper/upgraderepo/cli.rb
103
103
  - lib/zypper/upgraderepo/os_release.rb
@@ -116,7 +116,7 @@ licenses:
116
116
  metadata:
117
117
  bug_tracker_uri: https://github.com/fabiomux/zypper-upgraderepo/issues
118
118
  changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog
119
- documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.7.1
119
+ documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.8.0
120
120
  homepage_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html
121
121
  source_code_uri: https://github.com/fabiomux/zypper-upgraderepo
122
122
  wiki_uri: https://github.com/fabiomux/zypper-upgraderepo/wiki
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.2.19
138
+ rubygems_version: 3.2.3
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Zypper addon to check and upgrade local repositories.