zypper-upgraderepo 1.8.1 → 1.10.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 +80 -0
- data/Gemfile +13 -1
- data/Gemfile.lock +50 -14
- data/README.md +5 -0
- data/Rakefile +7 -1
- data/lib/zypper/upgraderepo/cli.rb +93 -75
- data/lib/zypper/upgraderepo/os_release.rb +27 -29
- data/lib/zypper/upgraderepo/repository.rb +106 -84
- data/lib/zypper/upgraderepo/request.rb +16 -17
- data/lib/zypper/upgraderepo/requests/http.rb +52 -42
- data/lib/zypper/upgraderepo/requests/local.rb +28 -22
- data/lib/zypper/upgraderepo/traversable.rb +34 -32
- data/lib/zypper/upgraderepo/utils.rb +161 -44
- data/lib/zypper/upgraderepo/version.rb +3 -1
- data/lib/zypper/upgraderepo/view.rb +269 -154
- data/lib/zypper/upgraderepo.rb +73 -26
- data/zypper-upgraderepo.gemspec +25 -27
- metadata +10 -10
data/lib/zypper/upgraderepo.rb
CHANGED
@@ -1,19 +1,22 @@
|
|
1
|
-
|
2
|
-
require 'zypper/upgraderepo/request'
|
3
|
-
require 'zypper/upgraderepo/os_release'
|
4
|
-
require 'zypper/upgraderepo/utils'
|
5
|
-
require 'zypper/upgraderepo/view'
|
6
|
-
require 'zlib'
|
7
|
-
require 'minitar'
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
3
|
+
require "zypper/upgraderepo/repository"
|
4
|
+
require "zypper/upgraderepo/request"
|
5
|
+
require "zypper/upgraderepo/os_release"
|
6
|
+
require "zypper/upgraderepo/utils"
|
7
|
+
require "zypper/upgraderepo/view"
|
8
|
+
require "zlib"
|
9
|
+
require "minitar"
|
9
10
|
|
10
11
|
module Zypper
|
11
12
|
module Upgraderepo
|
12
|
-
|
13
|
+
#
|
14
|
+
# Facade class for all the operations.
|
15
|
+
#
|
13
16
|
class Builder
|
14
17
|
def initialize(options)
|
15
18
|
@os_release = OsRelease.new(options)
|
16
|
-
@repos = RepositoryList.new(options
|
19
|
+
@repos = RepositoryList.new(options, RepositoryVariables.new(@os_release.current))
|
17
20
|
@print_hint = options.hint
|
18
21
|
@view_class = Zypper::Upgraderepo::View.const_get options.view.to_s.capitalize
|
19
22
|
|
@@ -23,11 +26,11 @@ module Zypper
|
|
23
26
|
end
|
24
27
|
|
25
28
|
def backup
|
26
|
-
filename = File.join(@backup_path, "repos-backup-#{Time.now.to_s.delete(
|
29
|
+
filename = File.join(@backup_path, "repos-backup-#{Time.now.to_s.delete(": +-")[0..-5]}.tgz")
|
27
30
|
|
28
31
|
raise InvalidWritePermissions, filename unless File.writable? @backup_path
|
29
32
|
|
30
|
-
Minitar.pack(RepositoryList::REPOSITORY_PATH, Zlib::GzipWriter.new(File.open(filename,
|
33
|
+
Minitar.pack(RepositoryList::REPOSITORY_PATH, Zlib::GzipWriter.new(File.open(filename, "wb")))
|
31
34
|
|
32
35
|
Messages.ok "Backup file generated at #{filename.bold.green}"
|
33
36
|
end
|
@@ -38,7 +41,8 @@ module Zypper
|
|
38
41
|
end
|
39
42
|
|
40
43
|
def check_next
|
41
|
-
raise AlreadyUpgraded,
|
44
|
+
raise AlreadyUpgraded, "latest" if @os_release.last?
|
45
|
+
|
42
46
|
@repos.upgrade!(@os_release.next)
|
43
47
|
check_repos(@os_release.next)
|
44
48
|
end
|
@@ -49,25 +53,69 @@ module Zypper
|
|
49
53
|
end
|
50
54
|
|
51
55
|
def check_last
|
52
|
-
raise AlreadyUpgraded,
|
56
|
+
raise AlreadyUpgraded, "latest" if @os_release.last?
|
57
|
+
|
53
58
|
@repos.upgrade!(@os_release.last)
|
54
59
|
check_repos(@os_release.last)
|
55
60
|
end
|
56
61
|
|
62
|
+
def duplicates
|
63
|
+
dups = {}
|
64
|
+
dcount = 0
|
65
|
+
@view_class.duplicates_header(@repos.max_col)
|
66
|
+
@view_class.separator(@repos.max_col, "=", :yellow)
|
67
|
+
@repos.each_with_number do |repo, num|
|
68
|
+
uri = URI.parse(repo.url)
|
69
|
+
hostname = uri.hostname.split(".")[-2..-1].join(".")
|
70
|
+
idx = URI::HTTP.build(path: uri.path, host: hostname).to_s.gsub(%r{^http://}, "").gsub(%r{/$}, "")
|
71
|
+
dups[idx] ||= []
|
72
|
+
dups[idx] << { num: num, repo: repo }
|
73
|
+
end
|
74
|
+
dups.each do |_key, list|
|
75
|
+
next if list.count < 2
|
76
|
+
|
77
|
+
dcount += list.count.pred
|
78
|
+
list.each_with_index do |l, i|
|
79
|
+
@view_class.duplicates_item(l[:num], i.next, list.count, l[:repo], @repos.max_col)
|
80
|
+
@view_class.separator(@repos.max_col) unless i == list.count.pred
|
81
|
+
end
|
82
|
+
@view_class.separator(@repos.max_col, "=", :yellow)
|
83
|
+
end
|
84
|
+
@view_class.duplicates_footer(dcount, @repos.list.count)
|
85
|
+
end
|
86
|
+
|
87
|
+
def unused
|
88
|
+
ucount = 0
|
89
|
+
@view_class.unused_header(@repos.max_col)
|
90
|
+
@view_class.separator(@repos.max_col)
|
91
|
+
@repos.each_with_number do |repo, num|
|
92
|
+
packs = `zypper -q pa -i -r #{num} 2>/dev/null|grep "^i"|wc -l`.strip.to_i
|
93
|
+
next unless packs.zero?
|
94
|
+
|
95
|
+
ucount += 1
|
96
|
+
@view_class.unused_item(num, ucount, repo, @repos.max_col)
|
97
|
+
@view_class.separator(@repos.max_col)
|
98
|
+
end
|
99
|
+
@view_class.unused_footer(ucount, @repos.list.count)
|
100
|
+
end
|
101
|
+
|
57
102
|
def upgrade_to_next
|
58
|
-
raise AlreadyUpgraded,
|
103
|
+
raise AlreadyUpgraded, "latest" if @os_release.last?
|
104
|
+
|
59
105
|
@repos.upgrade!(@os_release.next)
|
60
106
|
upgrade_repos(@os_release.next)
|
61
107
|
end
|
62
108
|
|
63
109
|
def upgrade_to
|
64
110
|
raise AlreadyUpgraded, @os_release.custom if @os_release.current?(@os_release.custom)
|
111
|
+
|
65
112
|
@repos.upgrade!(@os_release.custom)
|
66
113
|
upgrade_repos(@os_release.custom)
|
67
114
|
end
|
68
115
|
|
69
116
|
def upgrade_to_last
|
70
|
-
raise AlreadyUpgraded,
|
117
|
+
raise AlreadyUpgraded, "latest" if @os_release.last?
|
118
|
+
|
71
119
|
@repos.upgrade!(@os_release.last)
|
72
120
|
upgrade_repos(@os_release.last)
|
73
121
|
end
|
@@ -91,13 +139,13 @@ module Zypper
|
|
91
139
|
@view_class.header(@repos.max_col)
|
92
140
|
|
93
141
|
@repos.each_with_number do |repo, num|
|
94
|
-
|
95
|
-
@view_class.separator
|
142
|
+
@view_class.separator @repos.max_col
|
96
143
|
|
97
144
|
if repo.available?
|
98
145
|
@view_class.available num, repo, @repos.max_col
|
99
146
|
else
|
100
147
|
raise UnableToUpgrade, { num: num, repo: repo } if @exit_on_fail
|
148
|
+
|
101
149
|
if repo.redirected?
|
102
150
|
@view_class.redirected num, repo, @repos.max_col, repo.redirected_to
|
103
151
|
elsif repo.not_found?
|
@@ -110,19 +158,20 @@ module Zypper
|
|
110
158
|
@view_class.forbidden num, repo, @repos.max_col
|
111
159
|
elsif repo.timeout?
|
112
160
|
@view_class.timeout num, repo, @repos.max_col
|
161
|
+
else
|
162
|
+
@view_class.server_error num, repo, @repos.max_col
|
113
163
|
end
|
114
164
|
end
|
115
165
|
end
|
116
166
|
|
117
|
-
@view_class.footer
|
167
|
+
@view_class.footer @repos.max_col
|
118
168
|
end
|
119
169
|
|
120
|
-
def upgrade_repos(
|
121
|
-
@view_class.header(@repos.max_col, true)
|
170
|
+
def upgrade_repos(_version)
|
171
|
+
@view_class.header(@repos.max_col, upgrade: true)
|
122
172
|
|
123
173
|
@repos.each_with_number do |repo, num|
|
124
|
-
|
125
|
-
@view_class.separator
|
174
|
+
@view_class.separator @repos.max_col
|
126
175
|
|
127
176
|
if repo.upgraded?
|
128
177
|
@view_class.upgraded num, repo, @repos.max_col
|
@@ -131,13 +180,11 @@ module Zypper
|
|
131
180
|
end
|
132
181
|
end
|
133
182
|
|
134
|
-
@view_class.separator
|
183
|
+
@view_class.separator @repos.max_col
|
135
184
|
|
136
185
|
@repos.save
|
137
|
-
Messages.ok
|
186
|
+
Messages.ok "Repositories upgraded!"
|
138
187
|
end
|
139
|
-
|
140
188
|
end
|
141
|
-
|
142
189
|
end
|
143
190
|
end
|
data/zypper-upgraderepo.gemspec
CHANGED
@@ -1,40 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'zypper/upgraderepo/version'
|
3
|
+
require_relative "lib/zypper/upgraderepo/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
6
|
+
spec.name = "zypper-upgraderepo"
|
7
|
+
spec.version = Zypper::Upgraderepo::VERSION
|
8
|
+
spec.authors = ["Fabio Mucciante"]
|
9
|
+
spec.email = ["fabio.mucciante@gmail.com"]
|
11
10
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
11
|
+
spec.summary = "Zypper addon to check and upgrade local repositories."
|
12
|
+
spec.description = "A complement to the zypper CLI tool to upgrade the repositories before executing zypper dup."
|
13
|
+
spec.homepage = "https://github.com/fabiomux/zypper-upgraderepo"
|
14
|
+
spec.license = "GPL-3.0"
|
15
|
+
spec.required_ruby_version = ">= 2.5.0"
|
16
16
|
|
17
|
-
spec.metadata
|
18
|
-
"
|
19
|
-
"
|
20
|
-
"
|
21
|
-
"
|
22
|
-
|
23
|
-
"source_code_uri" => 'https://github.com/fabiomux/zypper-upgraderepo',
|
24
|
-
"wiki_uri" => 'https://github.com/fabiomux/zypper-upgraderepo/wiki'
|
17
|
+
spec.metadata = {
|
18
|
+
"homepage_uri" => spec.homepage,
|
19
|
+
"source_code_uri" => "https://github.com/fabiomux/zypper-upgraderepo",
|
20
|
+
"changelog_uri" => "https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog",
|
21
|
+
"wiki_uri" => "https://github.com/fabiomux/zypper-upgraderepo/wiki",
|
22
|
+
"rubygems_mfa_required" => "true"
|
25
23
|
}
|
26
24
|
|
27
|
-
spec.files
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
26
|
f.match(%r{^(test|spec|features|.github)/|(.gitignore|.travis.yml|CODE_OF_CONDUCT.md)$})
|
29
27
|
end
|
30
|
-
spec.bindir =
|
28
|
+
spec.bindir = "exe"
|
31
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = [
|
30
|
+
spec.require_paths = ["lib"]
|
33
31
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
32
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
35
|
|
38
|
-
spec.add_runtime_dependency
|
39
|
-
spec.add_runtime_dependency
|
36
|
+
spec.add_runtime_dependency "iniparse"
|
37
|
+
spec.add_runtime_dependency "minitar"
|
40
38
|
end
|
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.
|
4
|
+
version: 1.10.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-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,8 +80,8 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
84
|
-
|
83
|
+
description: A complement to the zypper CLI tool to upgrade the repositories before
|
84
|
+
executing zypper dup.
|
85
85
|
email:
|
86
86
|
- fabio.mucciante@gmail.com
|
87
87
|
executables:
|
@@ -90,6 +90,7 @@ extensions: []
|
|
90
90
|
extra_rdoc_files: []
|
91
91
|
files:
|
92
92
|
- ".rspec"
|
93
|
+
- ".rubocop.yml"
|
93
94
|
- Gemfile
|
94
95
|
- Gemfile.lock
|
95
96
|
- LICENSE
|
@@ -114,12 +115,11 @@ homepage: https://github.com/fabiomux/zypper-upgraderepo
|
|
114
115
|
licenses:
|
115
116
|
- GPL-3.0
|
116
117
|
metadata:
|
117
|
-
|
118
|
-
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog
|
119
|
-
documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.8.1
|
120
|
-
homepage_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html
|
118
|
+
homepage_uri: https://github.com/fabiomux/zypper-upgraderepo
|
121
119
|
source_code_uri: https://github.com/fabiomux/zypper-upgraderepo
|
120
|
+
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog
|
122
121
|
wiki_uri: https://github.com/fabiomux/zypper-upgraderepo/wiki
|
122
|
+
rubygems_mfa_required: 'true'
|
123
123
|
post_install_message:
|
124
124
|
rdoc_options: []
|
125
125
|
require_paths:
|
@@ -128,14 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 2.5.0
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
134
|
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.4.3
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Zypper addon to check and upgrade local repositories.
|