zypper-upgraderepo 1.10.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -49
- data/Gemfile +2 -0
- data/Gemfile.lock +45 -33
- data/README.md +11 -11
- data/bin/console +2 -0
- data/exe/upgraderepo +2 -0
- data/lib/zypper/upgraderepo/cli.rb +10 -5
- data/lib/zypper/upgraderepo/os_release.rb +52 -29
- data/lib/zypper/upgraderepo/repository.rb +131 -55
- data/lib/zypper/upgraderepo/request.rb +2 -0
- data/lib/zypper/upgraderepo/requests/http.rb +4 -2
- data/lib/zypper/upgraderepo/requests/local.rb +6 -4
- data/lib/zypper/upgraderepo/utils.rb +32 -16
- data/lib/zypper/upgraderepo/version.rb +1 -1
- data/lib/zypper/upgraderepo/view.rb +6 -5
- data/lib/zypper/upgraderepo.rb +48 -36
- data/zypper-upgraderepo.gemspec +2 -6
- metadata +3 -48
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e33496c6f52e625ef76cdb05a0428921a5b382398a081d8c2e180d2d6954f11c
|
|
4
|
+
data.tar.gz: 1c2b1ec8862bc2d7e601ee7f81d69ccc0f40a57e5de7b9c2650ae375147cfb40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a99ec07a90c68575998a9fdefe6b7dca5faa3fcf60ccd9c3f48b5897a05917f37ff7dfdbb32af2f5ff700bf2036656ee5850d56894837c410002ddc44bf0ce0
|
|
7
|
+
data.tar.gz: a958c51806aa971129fb1da35fb693dd3438254831ed7894c745344941146ff83c5d858882c8c09e6c12f521f636ba7879d9f26da54eb0fc80e8a83f356b09ee
|
data/.rubocop.yml
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
# plugins:
|
|
2
|
+
# - rubocop-rake
|
|
3
|
+
# - rubocop-rspec
|
|
4
|
+
|
|
1
5
|
AllCops:
|
|
2
6
|
TargetRubyVersion: 2.5
|
|
3
7
|
NewCops: enable
|
|
4
8
|
SuggestExtensions: false
|
|
5
9
|
|
|
6
|
-
Style/ClassVars:
|
|
7
|
-
Enabled: false
|
|
8
|
-
|
|
9
10
|
Style/StringLiterals:
|
|
10
11
|
Enabled: true
|
|
11
12
|
EnforcedStyle: double_quotes
|
|
@@ -17,64 +18,33 @@ Style/StringLiteralsInInterpolation:
|
|
|
17
18
|
Layout/LineLength:
|
|
18
19
|
Max: 120
|
|
19
20
|
|
|
20
|
-
Naming/FileName:
|
|
21
|
-
Enabled: false
|
|
22
|
-
|
|
23
21
|
Metrics/MethodLength:
|
|
24
|
-
|
|
22
|
+
Exclude:
|
|
23
|
+
- './lib/**/view.rb'
|
|
24
|
+
- './lib/**/cli.rb'
|
|
25
|
+
- './lib/**/traversable.rb'
|
|
25
26
|
|
|
26
27
|
Metrics/AbcSize:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
Exclude:
|
|
29
|
+
- './lib/**/view.rb'
|
|
30
|
+
- './lib/**/traversable.rb'
|
|
31
|
+
- './lib/**/cli.rb'
|
|
31
32
|
|
|
32
33
|
Metrics/ClassLength:
|
|
33
|
-
Enabled: true
|
|
34
34
|
Exclude:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- './lib/**/upgraderepo.rb'
|
|
35
|
+
- './lib/**/cli.rb'
|
|
36
|
+
- './lib/**/upgraderepo.rb'
|
|
38
37
|
|
|
39
38
|
Metrics/BlockLength:
|
|
40
|
-
Enabled: true
|
|
41
39
|
Exclude:
|
|
42
|
-
|
|
43
|
-
- './lib/**/cli.rb'
|
|
44
|
-
- './lib/**/repository.rb'
|
|
45
|
-
- './spec/**/*'
|
|
40
|
+
- './lib/**/cli.rb'
|
|
46
41
|
|
|
47
42
|
Metrics/PerceivedComplexity:
|
|
48
|
-
Enabled: true
|
|
49
43
|
Exclude:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- './lib/**/view.rb'
|
|
53
|
-
- './lib/**/traversable.rb'
|
|
44
|
+
- './lib/**/view.rb'
|
|
45
|
+
- './lib/**/traversable.rb'
|
|
54
46
|
|
|
55
47
|
Metrics/CyclomaticComplexity:
|
|
56
|
-
Enabled: true
|
|
57
|
-
Exclude:
|
|
58
|
-
- './lib/**/upgraderepo.rb'
|
|
59
|
-
- './lib/**/repository.rb'
|
|
60
|
-
- './lib/**/view.rb'
|
|
61
|
-
- './lib/**/traversable.rb'
|
|
62
|
-
|
|
63
|
-
Lint/UriEscapeUnescape:
|
|
64
|
-
Enabled: false
|
|
65
|
-
|
|
66
|
-
Lint/UnusedMethodArgument:
|
|
67
|
-
Enabled: true
|
|
68
|
-
Exclude:
|
|
69
|
-
- './lib/**/local.rb'
|
|
70
|
-
|
|
71
|
-
Style/MixinUsage:
|
|
72
|
-
Enabled: true
|
|
73
|
-
Exclude:
|
|
74
|
-
- './spec/**/*'
|
|
75
|
-
|
|
76
|
-
Style/FrozenStringLiteralComment:
|
|
77
|
-
Enabled: true
|
|
78
48
|
Exclude:
|
|
79
|
-
|
|
80
|
-
|
|
49
|
+
- './lib/**/view.rb'
|
|
50
|
+
- './lib/**/traversable.rb'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,66 +1,78 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
zypper-upgraderepo (1.
|
|
4
|
+
zypper-upgraderepo (1.12.0)
|
|
5
5
|
iniparse
|
|
6
6
|
minitar
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
ast (2.4.
|
|
12
|
-
diff-lcs (1.
|
|
11
|
+
ast (2.4.3)
|
|
12
|
+
diff-lcs (1.6.2)
|
|
13
13
|
iniparse (1.5.0)
|
|
14
|
-
json (2.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
json (2.18.0)
|
|
15
|
+
language_server-protocol (3.17.0.5)
|
|
16
|
+
lint_roller (1.1.0)
|
|
17
|
+
minitar (1.1.0)
|
|
18
|
+
parallel (1.27.0)
|
|
19
|
+
parser (3.3.10.0)
|
|
18
20
|
ast (~> 2.4.1)
|
|
19
21
|
racc
|
|
20
|
-
|
|
22
|
+
prism (1.6.0)
|
|
23
|
+
racc (1.8.1)
|
|
21
24
|
rainbow (3.1.1)
|
|
22
|
-
rake (13.
|
|
23
|
-
regexp_parser (2.
|
|
24
|
-
|
|
25
|
-
strscan
|
|
26
|
-
rspec (3.13.0)
|
|
25
|
+
rake (13.3.1)
|
|
26
|
+
regexp_parser (2.11.3)
|
|
27
|
+
rspec (3.13.2)
|
|
27
28
|
rspec-core (~> 3.13.0)
|
|
28
29
|
rspec-expectations (~> 3.13.0)
|
|
29
30
|
rspec-mocks (~> 3.13.0)
|
|
30
|
-
rspec-core (3.13.
|
|
31
|
+
rspec-core (3.13.6)
|
|
31
32
|
rspec-support (~> 3.13.0)
|
|
32
|
-
rspec-expectations (3.13.
|
|
33
|
+
rspec-expectations (3.13.5)
|
|
33
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
34
35
|
rspec-support (~> 3.13.0)
|
|
35
|
-
rspec-mocks (3.13.
|
|
36
|
+
rspec-mocks (3.13.7)
|
|
36
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
38
|
rspec-support (~> 3.13.0)
|
|
38
|
-
rspec-support (3.13.
|
|
39
|
-
rubocop (1.
|
|
39
|
+
rspec-support (3.13.6)
|
|
40
|
+
rubocop (1.82.0)
|
|
40
41
|
json (~> 2.3)
|
|
42
|
+
language_server-protocol (~> 3.17.0.2)
|
|
43
|
+
lint_roller (~> 1.1.0)
|
|
41
44
|
parallel (~> 1.10)
|
|
42
|
-
parser (>= 3.
|
|
45
|
+
parser (>= 3.3.0.2)
|
|
43
46
|
rainbow (>= 2.2.2, < 4.0)
|
|
44
|
-
regexp_parser (>=
|
|
45
|
-
|
|
46
|
-
rubocop-ast (>= 1.28.0, < 2.0)
|
|
47
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
48
|
+
rubocop-ast (>= 1.48.0, < 2.0)
|
|
47
49
|
ruby-progressbar (~> 1.7)
|
|
48
|
-
unicode-display_width (>= 2.4.0, <
|
|
49
|
-
rubocop-ast (1.
|
|
50
|
-
parser (>= 3.
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
51
|
+
rubocop-ast (1.48.0)
|
|
52
|
+
parser (>= 3.3.7.2)
|
|
53
|
+
prism (~> 1.4)
|
|
54
|
+
rubocop-capybara (2.22.1)
|
|
55
|
+
lint_roller (~> 1.1)
|
|
56
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
57
|
+
rubocop-factory_bot (2.28.0)
|
|
58
|
+
lint_roller (~> 1.1)
|
|
59
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
53
60
|
rubocop-rake (0.6.0)
|
|
54
61
|
rubocop (~> 1.0)
|
|
55
|
-
rubocop-rspec (2.
|
|
56
|
-
rubocop (~> 1.
|
|
62
|
+
rubocop-rspec (2.31.0)
|
|
63
|
+
rubocop (~> 1.40)
|
|
57
64
|
rubocop-capybara (~> 2.17)
|
|
65
|
+
rubocop-factory_bot (~> 2.22)
|
|
66
|
+
rubocop-rspec_rails (~> 2.28)
|
|
67
|
+
rubocop-rspec_rails (2.29.1)
|
|
68
|
+
rubocop (~> 1.61)
|
|
58
69
|
ruby-progressbar (1.13.0)
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
unicode-display_width (3.2.0)
|
|
71
|
+
unicode-emoji (~> 4.1)
|
|
72
|
+
unicode-emoji (4.2.0)
|
|
61
73
|
|
|
62
74
|
PLATFORMS
|
|
63
|
-
|
|
75
|
+
x86_64-linux-gnu
|
|
64
76
|
|
|
65
77
|
DEPENDENCIES
|
|
66
78
|
bundler (~> 2.0)
|
|
@@ -72,4 +84,4 @@ DEPENDENCIES
|
|
|
72
84
|
zypper-upgraderepo!
|
|
73
85
|
|
|
74
86
|
BUNDLED WITH
|
|
75
|
-
2.4.
|
|
87
|
+
2.4.22
|
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Zypper-Upgraderepo
|
|
2
2
|
|
|
3
|
-
Zypper-Upgraderepo helps to check and upgrade the repositories
|
|
4
|
-
current, next or a custom valid version, reporting the errors and trying to find
|
|
3
|
+
Zypper-Upgraderepo helps to check and upgrade the configured repositories validating or looking for the
|
|
4
|
+
current, next or a custom valid version, reporting the errors and trying to find an alternative URL
|
|
5
5
|
when possible.
|
|
6
6
|
|
|
7
7
|
It can be also be installed as Zypper plugin using the [Zypper Upgraderepo Plugin][zypper_upgraderepo_plugin].
|
|
@@ -32,24 +32,24 @@ in the related [project page][project_page] at my blog.
|
|
|
32
32
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
RPM package installation introduces annoying copies of the same executable
|
|
37
|
-
(zypper-upgraderepo
|
|
35
|
+
**Warning!!! The executables name prior the 1.8.0 version was zypper-upgraderepo, unfortunately the
|
|
36
|
+
RPM package installation introduces annoying copies of the same executable with a Ruby version appended
|
|
37
|
+
(zypper-upgraderepo.*version*, zypper-upgraderepo.*rubyversion*, zypper-upgraderepo.*rubyversion*.*version*)
|
|
38
38
|
interpreted by zypper itself as different subcommands. So I considered more convenient to remove the
|
|
39
39
|
zypper prefix from the original executable and let the sole zypper-upgraderepo-plugin package install
|
|
40
|
-
it as a zypper plugin
|
|
40
|
+
it as a zypper plugin.**
|
|
41
41
|
|
|
42
|
-
To check the availability of the current repositories:
|
|
42
|
+
To check the availability of the **current** repositories:
|
|
43
43
|
```shell
|
|
44
44
|
$ upgraderepo
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
To check the availability of the next version repositories:
|
|
47
|
+
To check the availability of the **next** version repositories:
|
|
48
48
|
```shell
|
|
49
49
|
$ upgraderepo --check-next
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
To upgrade the repositories to the next version:
|
|
52
|
+
To **upgrade** the repositories to the next version:
|
|
53
53
|
```shell
|
|
54
54
|
$ sudo upgraderepo --upgrade
|
|
55
55
|
```
|
|
@@ -64,8 +64,8 @@ $ upgraderepo --help
|
|
|
64
64
|
## More Help:
|
|
65
65
|
|
|
66
66
|
More info is available at:
|
|
67
|
-
-
|
|
68
|
-
-
|
|
67
|
+
- The [Zypper-Upgraderepo GitHub wiki][zypper_upgraderepo_wiki];
|
|
68
|
+
- The [Upgrading with Zypper][upgrading_with_zypper] article on Freeaptitude blog.
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
[zypper_upgraderepo_plugin]: https://github.com/fabiomux/zypper-upgraderepo-plugin "Zypper-Upgraderepo Plugin GitHub page"
|
data/bin/console
CHANGED
data/exe/upgraderepo
CHANGED
|
@@ -10,14 +10,14 @@ module Zypper
|
|
|
10
10
|
:operation, :backup_path, :only_enabled, :alias, :name, :hint,
|
|
11
11
|
:overrides, :version, :sorting_by, :view, :only_repo, :timeout,
|
|
12
12
|
:exit_on_fail, :overrides_filename, :only_invalid, :only_protocols,
|
|
13
|
-
:allow_unstable
|
|
13
|
+
:allow_unstable, :only_used
|
|
14
14
|
)
|
|
15
15
|
|
|
16
16
|
#
|
|
17
17
|
# Parsing the input data.
|
|
18
18
|
#
|
|
19
19
|
class OptParseMain
|
|
20
|
-
def self.parse(
|
|
20
|
+
def self.parse(args)
|
|
21
21
|
options = CliOptions.new
|
|
22
22
|
options.operation = :check_current
|
|
23
23
|
options.backup_path = Dir.home
|
|
@@ -36,6 +36,7 @@ module Zypper
|
|
|
36
36
|
options.only_invalid = false
|
|
37
37
|
options.only_protocols = nil
|
|
38
38
|
options.allow_unstable = false
|
|
39
|
+
options.only_used = nil
|
|
39
40
|
|
|
40
41
|
opt_parser = OptionParser.new do |opt|
|
|
41
42
|
opt.banner = if ENV["ZYPPER_UPGRADEREPO"]
|
|
@@ -148,7 +149,7 @@ module Zypper
|
|
|
148
149
|
|
|
149
150
|
opt.on("--only-repo <NUMBER|NAME|@ALIAS|#URL|&ANY>[,NUMBER2|NAME2|@ALIAS2|#URL2|&ANY2,...]",
|
|
150
151
|
"Include only the repositories specified by a NUMBER or a string matching the NAME, " \
|
|
151
|
-
"@ALIAS, #URL, or
|
|
152
|
+
"@ALIAS, #URL, or ?ANY of them") do |o|
|
|
152
153
|
options.only_repo = o.split(",")
|
|
153
154
|
end
|
|
154
155
|
|
|
@@ -161,6 +162,10 @@ module Zypper
|
|
|
161
162
|
options.only_protocols = o
|
|
162
163
|
end
|
|
163
164
|
|
|
165
|
+
opt.on("--only-used", "Show only used repositories") do |_o|
|
|
166
|
+
options.only_used = true
|
|
167
|
+
end
|
|
168
|
+
|
|
164
169
|
opt.separator ""
|
|
165
170
|
opt.separator "View options:"
|
|
166
171
|
|
|
@@ -208,11 +213,11 @@ module Zypper
|
|
|
208
213
|
end
|
|
209
214
|
end
|
|
210
215
|
|
|
211
|
-
if
|
|
216
|
+
if args.empty?
|
|
212
217
|
puts opt_parser
|
|
213
218
|
exit
|
|
214
219
|
else
|
|
215
|
-
opt_parser.parse!(
|
|
220
|
+
opt_parser.parse!(args)
|
|
216
221
|
end
|
|
217
222
|
|
|
218
223
|
options
|
|
@@ -10,10 +10,6 @@ module Zypper
|
|
|
10
10
|
class OsRelease
|
|
11
11
|
attr_reader :custom, :unstable
|
|
12
12
|
|
|
13
|
-
OS_VERSIONS = ["13.1", "13.2",
|
|
14
|
-
"42.1", "42.2", "42.3",
|
|
15
|
-
"15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6"].freeze
|
|
16
|
-
|
|
17
13
|
UNSTABLE_VERSION = "16.0"
|
|
18
14
|
|
|
19
15
|
OS_RELEASE_FILE = "/etc/os-release"
|
|
@@ -21,67 +17,60 @@ module Zypper
|
|
|
21
17
|
SUSE_RELEASE_FILE = "/etc/SuSE-release"
|
|
22
18
|
|
|
23
19
|
def initialize(options)
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
@os_versions = ["13.1", "13.2",
|
|
21
|
+
"42.1", "42.2", "42.3",
|
|
22
|
+
"15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6",
|
|
23
|
+
"16.0"]
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
@unstable = true
|
|
29
|
-
end
|
|
25
|
+
load_unstable if options.allow_unstable
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
elsif File.exist? self.class::SUSE_RELEASE_FILE
|
|
34
|
-
self.class::SUSE_RELEASE_FILE
|
|
35
|
-
else
|
|
36
|
-
raise ReleaseFileNotFound
|
|
37
|
-
end
|
|
38
|
-
@release = IniParse.parse(File.read(fname))
|
|
39
|
-
@current_idx = OS_VERSIONS.index(@release["__anonymous__"]["VERSION"].delete('"'))
|
|
27
|
+
@release = IniParse.parse(File.read(release_filename))
|
|
28
|
+
@current_idx = @os_versions.index(@release["__anonymous__"]["VERSION"].delete('"'))
|
|
40
29
|
|
|
41
30
|
return unless options.version
|
|
42
|
-
raise InvalidVersion, options.version unless
|
|
31
|
+
raise InvalidVersion, options.version unless @os_versions.include?(options.version)
|
|
43
32
|
|
|
44
33
|
@custom = options.version
|
|
45
34
|
end
|
|
46
35
|
|
|
47
36
|
def current
|
|
48
|
-
|
|
37
|
+
@os_versions[@current_idx]
|
|
49
38
|
end
|
|
50
39
|
|
|
51
40
|
def last
|
|
52
|
-
|
|
41
|
+
@os_versions[-1]
|
|
53
42
|
end
|
|
54
43
|
|
|
55
44
|
def next
|
|
56
45
|
return if last?
|
|
57
46
|
|
|
58
|
-
|
|
47
|
+
@os_versions[@current_idx.next]
|
|
59
48
|
end
|
|
60
49
|
|
|
61
50
|
def previous
|
|
62
51
|
return if first?
|
|
63
52
|
|
|
64
|
-
|
|
53
|
+
@os_versions[@current_idx.pred]
|
|
65
54
|
end
|
|
66
55
|
|
|
67
56
|
def fullname
|
|
68
|
-
@release["__anonymous__"]["PRETTY_NAME"].gsub(
|
|
57
|
+
@release["__anonymous__"]["PRETTY_NAME"].gsub('"', "")
|
|
69
58
|
end
|
|
70
59
|
|
|
71
60
|
def seniority
|
|
72
|
-
|
|
61
|
+
@os_versions.count - @current_idx.next
|
|
73
62
|
end
|
|
74
63
|
|
|
75
64
|
def newer
|
|
76
65
|
if seniority.positive?
|
|
77
|
-
|
|
66
|
+
@os_versions[@current_idx.next..-1]
|
|
78
67
|
else
|
|
79
68
|
[]
|
|
80
69
|
end
|
|
81
70
|
end
|
|
82
71
|
|
|
83
72
|
def last?
|
|
84
|
-
@current_idx == (
|
|
73
|
+
@current_idx == (@os_versions.count - 1)
|
|
85
74
|
end
|
|
86
75
|
|
|
87
76
|
def first?
|
|
@@ -89,11 +78,45 @@ module Zypper
|
|
|
89
78
|
end
|
|
90
79
|
|
|
91
80
|
def valid?(version)
|
|
92
|
-
|
|
81
|
+
@os_versions.include? version
|
|
93
82
|
end
|
|
94
83
|
|
|
95
84
|
def current?(version)
|
|
96
|
-
|
|
85
|
+
@os_versions.index(version) == @current_idx
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def requires_v2?(version)
|
|
89
|
+
if `uname -m` =~ /x86_64/
|
|
90
|
+
@os_versions.index(version) > 11
|
|
91
|
+
else
|
|
92
|
+
false
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def v2?
|
|
97
|
+
flags = `cat /proc/cpuinfo`.split("\n").grep(/^flags.*:/).first.split
|
|
98
|
+
%w[cx16 lahf_lm popcnt sse4_1 sse4_2 ssse3].reduce(true) do |res, f|
|
|
99
|
+
flags.include?(f) && res
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def release_filename
|
|
106
|
+
if File.exist? self.class::OS_RELEASE_FILE
|
|
107
|
+
self.class::OS_RELEASE_FILE
|
|
108
|
+
elsif File.exist? self.class::SUSE_RELEASE_FILE
|
|
109
|
+
self.class::SUSE_RELEASE_FILE
|
|
110
|
+
else
|
|
111
|
+
raise ReleaseFileNotFound
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def load_unstable
|
|
116
|
+
raise NoUnstableVersionAvailable if UNSTABLE_VERSION.empty?
|
|
117
|
+
|
|
118
|
+
@os_versions << UNSTABLE_VERSION
|
|
119
|
+
@unstable = true
|
|
97
120
|
end
|
|
98
121
|
end
|
|
99
122
|
end
|
|
@@ -40,32 +40,22 @@ module Zypper
|
|
|
40
40
|
#
|
|
41
41
|
# Handle the repository collection.
|
|
42
42
|
#
|
|
43
|
+
# rubocop: disable Metrics/ClassLength
|
|
43
44
|
class RepositoryList
|
|
44
45
|
REPOSITORY_PATH = "/etc/zypp/repos.d"
|
|
45
46
|
|
|
46
47
|
attr_reader :list, :max_col
|
|
47
48
|
|
|
48
49
|
def initialize(options, variables)
|
|
49
|
-
|
|
50
|
-
@name = options.name
|
|
51
|
-
@only_repo = options.only_repo
|
|
52
|
-
@only_enabled = options.only_enabled
|
|
53
|
-
@only_invalid = options.only_invalid
|
|
54
|
-
@only_protocols = options.only_protocols
|
|
55
|
-
@overrides = options.overrides
|
|
56
|
-
@upgrade_options = { alias: options.alias, name: options.name }
|
|
57
|
-
@list = []
|
|
50
|
+
initialize_options(options)
|
|
58
51
|
|
|
59
52
|
@variables = variables
|
|
60
|
-
Dir.glob(File.join(self.class::REPOSITORY_PATH, "*.repo")).each do |i|
|
|
61
|
-
r = Request.build(Repository.new(i, @variables), options.timeout)
|
|
62
|
-
@list << r
|
|
63
|
-
end
|
|
64
|
-
@max_col = @list.max_by { |r| r.name.length }.name.length
|
|
65
53
|
|
|
66
|
-
|
|
54
|
+
initialize_list(options)
|
|
67
55
|
|
|
68
|
-
@list.
|
|
56
|
+
@max_col = @list.max_by { |r| r.name.length }.name.length
|
|
57
|
+
|
|
58
|
+
sort_list(options)
|
|
69
59
|
|
|
70
60
|
@only_repo = select_repos(@only_repo) unless @only_repo.nil?
|
|
71
61
|
|
|
@@ -84,64 +74,145 @@ module Zypper
|
|
|
84
74
|
end
|
|
85
75
|
|
|
86
76
|
def each_with_number(options = {})
|
|
87
|
-
|
|
88
|
-
only_enabled = options[:only_enabled].nil? ? @only_enabled : options[:only_enabled]
|
|
89
|
-
only_invalid = options[:only_invalid].nil? ? @only_invalid : options[:only_invalid]
|
|
90
|
-
only_protocols = options[:only_protocols].nil? ? @only_protocols : options[:only_protocols]
|
|
77
|
+
f_o = filter_options(options)
|
|
91
78
|
|
|
92
79
|
@list.each do |x|
|
|
93
|
-
next if
|
|
94
|
-
next if only_enabled && !x[:repo].enabled?
|
|
95
|
-
next if only_invalid && x[:repo].available?
|
|
96
|
-
next if only_protocols && !only_protocols.include?(x[:repo].protocol)
|
|
80
|
+
next if next_repo? x[:repo], x[:num], f_o
|
|
97
81
|
|
|
98
82
|
yield x[:repo], x[:num] if block_given?
|
|
99
83
|
end
|
|
100
84
|
end
|
|
101
85
|
|
|
102
86
|
def save
|
|
103
|
-
|
|
104
|
-
|
|
87
|
+
each_with_number do |repo, _num|
|
|
88
|
+
repo.save
|
|
105
89
|
end
|
|
106
90
|
end
|
|
107
91
|
|
|
92
|
+
def duplicates
|
|
93
|
+
group_for_url.delete_if { |_, v| v.length < 2 }
|
|
94
|
+
end
|
|
95
|
+
|
|
108
96
|
private
|
|
109
97
|
|
|
98
|
+
def initialize_list(options)
|
|
99
|
+
@list = []
|
|
100
|
+
Dir.glob(File.join(self.class::REPOSITORY_PATH, "*.repo")).each do |i|
|
|
101
|
+
r = Request.build(Repository.new(i, @variables), options.timeout)
|
|
102
|
+
@list << r
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def sort_list(options)
|
|
107
|
+
@list = @list.sort_by(&:alias).map.with_index(1) { |r, i| { num: i, repo: r } }
|
|
108
|
+
@list.sort_by! { |x| x[:repo].send(options.sorting_by) } if options.sorting_by != :alias
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def initialize_options(options)
|
|
112
|
+
@alias = options.alias
|
|
113
|
+
@name = options.name
|
|
114
|
+
@only_repo = options.only_repo
|
|
115
|
+
@only_enabled = options.only_enabled
|
|
116
|
+
@only_invalid = options.only_invalid
|
|
117
|
+
@only_protocols = options.only_protocols
|
|
118
|
+
@only_used = options.only_used
|
|
119
|
+
@overrides = options.overrides
|
|
120
|
+
@upgrade_options = { alias: options.alias, name: options.name }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def filter_options(options)
|
|
124
|
+
{
|
|
125
|
+
only_repo: options[:only_repo].nil? ? @only_repo : options[:only_repo],
|
|
126
|
+
only_enabled: options[:only_enabled].nil? ? @only_enabled : options[:only_enabled],
|
|
127
|
+
only_invalid: options[:only_invalid].nil? ? @only_invalid : options[:only_invalid],
|
|
128
|
+
only_protocols: options[:only_protocols].nil? ? @only_protocols : options[:only_protocols],
|
|
129
|
+
only_used: options[:only_used].nil? ? @only_used : options[:only_used]
|
|
130
|
+
}
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# rubocop: disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
|
134
|
+
def next_repo?(repo, num, options)
|
|
135
|
+
(options[:only_repo] && !options[:only_repo].include?(num)) ||
|
|
136
|
+
(options[:only_enabled] && !repo.enabled?) ||
|
|
137
|
+
(options[:only_invalid] && repo.available?) ||
|
|
138
|
+
(options[:only_protocols] && !options[:only_protocols].include?(repo.protocol)) ||
|
|
139
|
+
(options[:only_used] && repo.unused?)
|
|
140
|
+
end
|
|
141
|
+
# rubocop: enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
|
142
|
+
|
|
143
|
+
def group_for_url
|
|
144
|
+
dups = {}
|
|
145
|
+
each_with_number do |repo, num|
|
|
146
|
+
uri = URI.parse(repo.url)
|
|
147
|
+
hostname = uri.hostname.split(".")[-2..-1].join(".")
|
|
148
|
+
idx = URI::HTTP.build(path: uri.path, host: hostname).to_s.gsub(%r{^http://}, "").gsub(%r{/$}, "")
|
|
149
|
+
dups[idx] ||= []
|
|
150
|
+
dups[idx] << { num: num, repo: repo }
|
|
151
|
+
end
|
|
152
|
+
dups
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def select_for_name(str)
|
|
156
|
+
regexp = Regexp.new(str.strip, "i")
|
|
157
|
+
@list.select do |x|
|
|
158
|
+
yield x[:repo], x[:num] if x[:repo].name.match?(regexp) && block_given?
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def select_for_alias(str)
|
|
163
|
+
regexp = Regexp.new(str.gsub("@", "").strip, "i")
|
|
164
|
+
@list.select do |x|
|
|
165
|
+
yield x[:repo], x[:num] if x[:repo].alias.match?(regexp)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def select_for_url(str)
|
|
170
|
+
regexp = Regexp.new(str.gsub("#", "").strip, "i")
|
|
171
|
+
@list.select do |x|
|
|
172
|
+
yield x[:repo], x[:num] if x[:repo].url.match?(regexp)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def select_for_any(str)
|
|
177
|
+
regexp = Regexp.new(str.gsub("?", "").strip, "i")
|
|
178
|
+
@list.select do |x|
|
|
179
|
+
yield x[:repo], x[:num] if x[:repo].name.match?(regexp) ||
|
|
180
|
+
x[:repo].alias.match?(regexp) ||
|
|
181
|
+
x[:repo].url.match?(regexp)
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# rubocop: disable Metrics/AbcSize, Metrics/MethodLength
|
|
110
186
|
def select_repos(repos)
|
|
111
187
|
res = []
|
|
112
188
|
repos.each do |r|
|
|
113
189
|
if r.to_i.positive?
|
|
114
190
|
res.push r.to_i
|
|
115
191
|
elsif r =~ /^\ *@.*/
|
|
116
|
-
|
|
117
|
-
@list.select { |x| x[:repo].alias.match?(Regexp.new(a, "i")) }.each do |l|
|
|
118
|
-
res.push l[:num]
|
|
119
|
-
end
|
|
192
|
+
select_for_alias(r) { |_, num| res.push num }
|
|
120
193
|
elsif r =~ /^\ *\#.*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
end
|
|
125
|
-
elsif r =~ /^\ *&.*/
|
|
126
|
-
s = r.gsub(/&/, "").strip
|
|
127
|
-
sel = @list.select do |x|
|
|
128
|
-
x[:repo].alias.match?(Regexp.new(s, "i")) ||
|
|
129
|
-
x[:repo].name.match?(Regexp.new(s, "i")) ||
|
|
130
|
-
x[:repo].url.match?(Regexp.new(s, "i"))
|
|
131
|
-
end
|
|
132
|
-
sel.each do |l|
|
|
133
|
-
res.push l[:num]
|
|
134
|
-
end
|
|
194
|
+
select_for_url(r) { |_, num| res.push num }
|
|
195
|
+
elsif r =~ /^\ *\?.*/
|
|
196
|
+
select_for_any(r) { |_, num| res.push num }
|
|
135
197
|
else
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
res.push l[:num]
|
|
139
|
-
end
|
|
198
|
+
puts r
|
|
199
|
+
select_for_name(r) { |_, num| res.push num }
|
|
140
200
|
end
|
|
141
201
|
end
|
|
142
202
|
|
|
143
203
|
res.uniq
|
|
144
204
|
end
|
|
205
|
+
# rubocop: enable Metrics/AbcSize, Metrics/MethodLength
|
|
206
|
+
|
|
207
|
+
def check_for_override(repo, num, ini)
|
|
208
|
+
raise UnmatchingOverrides, { num: num, ini: ini, repo: repo } if repo.url != ini["old_url"]
|
|
209
|
+
|
|
210
|
+
if only_enabled?
|
|
211
|
+
raise MissingOverride, { num: num, ini: ini } unless ini["url"] || ini["enabled"] =~ /no|false|0/i
|
|
212
|
+
else
|
|
213
|
+
raise MissingOverride, { num: num, ini: ini } unless ini["url"]
|
|
214
|
+
end
|
|
215
|
+
end
|
|
145
216
|
|
|
146
217
|
def load_overrides(filename)
|
|
147
218
|
raise FileNotFound, filename unless File.exist?(filename)
|
|
@@ -151,17 +222,12 @@ module Zypper
|
|
|
151
222
|
next unless (x = ini["repository_#{num}"])
|
|
152
223
|
|
|
153
224
|
repo.enable!(x["enabled"])
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if only_enabled?
|
|
157
|
-
raise MissingOverride, { num: num, ini: x } unless x["url"] || x["enabled"] =~ /no|false|0/i
|
|
158
|
-
else
|
|
159
|
-
raise MissingOverride, { num: num, ini: x } unless x["url"]
|
|
160
|
-
end
|
|
225
|
+
check_for_override(repo, num, x)
|
|
161
226
|
@overrides[num] = x["url"] if x["url"]
|
|
162
227
|
end
|
|
163
228
|
end
|
|
164
229
|
end
|
|
230
|
+
# rubocop: enable Metrics/ClassLength
|
|
165
231
|
|
|
166
232
|
#
|
|
167
233
|
# Single repository class.
|
|
@@ -232,6 +298,7 @@ module Zypper
|
|
|
232
298
|
@key = read_key
|
|
233
299
|
end
|
|
234
300
|
|
|
301
|
+
# rubocop: disable Metrics/AbcSize
|
|
235
302
|
def upgrade!(version, args = {})
|
|
236
303
|
@old_url ||= url
|
|
237
304
|
@old_alias ||= self.alias
|
|
@@ -242,6 +309,7 @@ module Zypper
|
|
|
242
309
|
self.alias = self.alias.gsub(/\d\d\.\d/, version) if args[:alias]
|
|
243
310
|
self.name = name.gsub(/\d\d\.\d/, version) if args[:name]
|
|
244
311
|
end
|
|
312
|
+
# rubocop: enable Metrics/AbcSize
|
|
245
313
|
|
|
246
314
|
def upgraded?(item = :url)
|
|
247
315
|
!send("old_#{item}").nil? && (send("old_#{item}") != send(item))
|
|
@@ -256,6 +324,14 @@ module Zypper
|
|
|
256
324
|
@repo.save(@filename)
|
|
257
325
|
end
|
|
258
326
|
|
|
327
|
+
def unused?
|
|
328
|
+
`zypper -q pa -i -r "#{name}" 2>/dev/null|grep -c "^i"`.strip.to_i.zero?
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
def used?
|
|
332
|
+
!unused?
|
|
333
|
+
end
|
|
334
|
+
|
|
259
335
|
private
|
|
260
336
|
|
|
261
337
|
def resolve_variables!(variables)
|
|
@@ -12,6 +12,7 @@ module Zypper
|
|
|
12
12
|
# achieve the request..
|
|
13
13
|
#
|
|
14
14
|
class Request
|
|
15
|
+
# rubocop: disable Style/ClassVars
|
|
15
16
|
def self.build(repo, timeout)
|
|
16
17
|
@@registry ||= load_requests
|
|
17
18
|
|
|
@@ -19,6 +20,7 @@ module Zypper
|
|
|
19
20
|
|
|
20
21
|
Object.const_get(find_class(repo)).new(repo, timeout)
|
|
21
22
|
end
|
|
23
|
+
# rubocop: enable Style/ClassVars
|
|
22
24
|
|
|
23
25
|
def self.protocols
|
|
24
26
|
load_requests.keys
|
|
@@ -14,7 +14,7 @@ module Zypper
|
|
|
14
14
|
USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0"
|
|
15
15
|
|
|
16
16
|
def initialize(obj, timeout = 60)
|
|
17
|
-
super
|
|
17
|
+
super(obj)
|
|
18
18
|
@timeout = timeout
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -68,6 +68,7 @@ module Zypper
|
|
|
68
68
|
http.request(request)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# rubocop: disable Metrics/MethodLength
|
|
71
72
|
def ping(uri = nil, head: true, cache: true)
|
|
72
73
|
begin
|
|
73
74
|
if @page.nil? || uri
|
|
@@ -84,6 +85,7 @@ module Zypper
|
|
|
84
85
|
end
|
|
85
86
|
cache ? @page : unpage
|
|
86
87
|
end
|
|
88
|
+
# rubocop: enable Metrics/MethodLength
|
|
87
89
|
end
|
|
88
90
|
|
|
89
91
|
module Requests
|
|
@@ -118,7 +120,7 @@ module Zypper
|
|
|
118
120
|
|
|
119
121
|
def get_request(uri, head)
|
|
120
122
|
# super uri || URI(url), head
|
|
121
|
-
super
|
|
123
|
+
super(uri || repodata_uri, head)
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
def repodata?(uri)
|
|
@@ -11,7 +11,7 @@ module Zypper
|
|
|
11
11
|
attr_reader :dir_path
|
|
12
12
|
|
|
13
13
|
def initialize(obj, _timeout)
|
|
14
|
-
super
|
|
14
|
+
super(obj)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def available?
|
|
@@ -48,13 +48,15 @@ module Zypper
|
|
|
48
48
|
|
|
49
49
|
private
|
|
50
50
|
|
|
51
|
+
# rubocop: disable Lint/UnusedMethodArgument
|
|
51
52
|
def ping(uri = nil, head: true)
|
|
52
53
|
@dir_path ||= URI(url).path
|
|
53
54
|
|
|
54
55
|
@dir_path = uri.to_s =~ %r{^/} ? uri.to_s : URI(uri.to_s).path if uri
|
|
55
56
|
|
|
56
|
-
URI.unescape(@dir_path)
|
|
57
|
+
URI::DEFAULT_PARSER.unescape(@dir_path)
|
|
57
58
|
end
|
|
59
|
+
# rubocop: enable Lint/UnusedMethodArgument
|
|
58
60
|
end
|
|
59
61
|
|
|
60
62
|
module Requests
|
|
@@ -88,12 +90,12 @@ module Zypper
|
|
|
88
90
|
private
|
|
89
91
|
|
|
90
92
|
def repodata?(uri)
|
|
91
|
-
File.exist? URI.unescape(repodata_uri(uri).path)
|
|
93
|
+
File.exist? URI::DEFAULT_PARSER.unescape(repodata_uri(uri).path)
|
|
92
94
|
end
|
|
93
95
|
|
|
94
96
|
def subfolders
|
|
95
97
|
Dir.glob("#{ping.gsub(%r{/$}, "")}/*/").map do |x|
|
|
96
|
-
URI.escape(x.gsub(%r{/$}, "").gsub(ping, "").gsub(%r{^/}, ""))
|
|
98
|
+
URI::DEFAULT_PARSER.escape(x.gsub(%r{/$}, "").gsub(ping, "").gsub(%r{^/}, ""))
|
|
97
99
|
end
|
|
98
100
|
end
|
|
99
101
|
end
|
|
@@ -111,6 +111,7 @@ module Zypper
|
|
|
111
111
|
# Color the error message.
|
|
112
112
|
#
|
|
113
113
|
class Messages
|
|
114
|
+
# rubocop: disable Metrics/AbcSize
|
|
114
115
|
def self.error(err)
|
|
115
116
|
if err.instance_of?(String)
|
|
116
117
|
puts " [E] ".bold.red + err
|
|
@@ -120,6 +121,7 @@ module Zypper
|
|
|
120
121
|
warn "Error! ".bold.red + err.message
|
|
121
122
|
end
|
|
122
123
|
end
|
|
124
|
+
# rubocop: enable Metrics/AbcSize
|
|
123
125
|
|
|
124
126
|
def self.ok(msg)
|
|
125
127
|
puts " [V] ".bold.green + msg
|
|
@@ -135,7 +137,7 @@ module Zypper
|
|
|
135
137
|
#
|
|
136
138
|
class FileNotFound < StandardError
|
|
137
139
|
def initialize(filename)
|
|
138
|
-
super
|
|
140
|
+
super("The File #{filename} doesn't exist.")
|
|
139
141
|
end
|
|
140
142
|
end
|
|
141
143
|
|
|
@@ -144,7 +146,7 @@ module Zypper
|
|
|
144
146
|
#
|
|
145
147
|
class ReleaseFileNotFound < StandardError
|
|
146
148
|
def initialize
|
|
147
|
-
super
|
|
149
|
+
super("The release file is not found.")
|
|
148
150
|
end
|
|
149
151
|
end
|
|
150
152
|
|
|
@@ -153,7 +155,7 @@ module Zypper
|
|
|
153
155
|
#
|
|
154
156
|
class InvalidProtocol < StandardError
|
|
155
157
|
def initialize(repo)
|
|
156
|
-
super
|
|
158
|
+
super("The repository #{repo.name} has an unknown protocol: #{repo.protocol}; disable it to continue.")
|
|
157
159
|
end
|
|
158
160
|
end
|
|
159
161
|
|
|
@@ -162,7 +164,7 @@ module Zypper
|
|
|
162
164
|
#
|
|
163
165
|
class InvalidVersion < StandardError
|
|
164
166
|
def initialize(version)
|
|
165
|
-
super
|
|
167
|
+
super("The version #{version} is not valid")
|
|
166
168
|
end
|
|
167
169
|
end
|
|
168
170
|
|
|
@@ -171,7 +173,7 @@ module Zypper
|
|
|
171
173
|
#
|
|
172
174
|
class InvalidWritePermissions < StandardError
|
|
173
175
|
def initialize(filename)
|
|
174
|
-
super
|
|
176
|
+
super("Don't have the permissions to write #{filename}")
|
|
175
177
|
end
|
|
176
178
|
|
|
177
179
|
def error_code
|
|
@@ -184,7 +186,7 @@ module Zypper
|
|
|
184
186
|
#
|
|
185
187
|
class SystemUpdateRunning < StandardError
|
|
186
188
|
def initialize(args)
|
|
187
|
-
super
|
|
189
|
+
super("The application #{args[:process].bold} with pid #{args[:pid].bold} is running a system update!")
|
|
188
190
|
end
|
|
189
191
|
|
|
190
192
|
def error_code
|
|
@@ -197,8 +199,8 @@ module Zypper
|
|
|
197
199
|
#
|
|
198
200
|
class UnableToUpgrade < StandardError
|
|
199
201
|
def initialize(args)
|
|
200
|
-
super
|
|
201
|
-
"can't be upgraded, a manual check is required!"
|
|
202
|
+
super("The repository n.#{args[:num].to_s.bold.red} named #{args[:repo].name.bold.red} " \
|
|
203
|
+
"can't be upgraded, a manual check is required!")
|
|
202
204
|
end
|
|
203
205
|
|
|
204
206
|
def error_code
|
|
@@ -211,8 +213,8 @@ module Zypper
|
|
|
211
213
|
#
|
|
212
214
|
class MissingOverride < StandardError
|
|
213
215
|
def initialize(args)
|
|
214
|
-
super
|
|
215
|
-
"doesn't contain the URL key!"
|
|
216
|
+
super("The repository n.#{args[:num].to_s.bold.red} named #{args[:ini]["name"].bold.red} " \
|
|
217
|
+
"doesn't contain the URL key!")
|
|
216
218
|
end
|
|
217
219
|
|
|
218
220
|
def error_code
|
|
@@ -225,8 +227,8 @@ module Zypper
|
|
|
225
227
|
#
|
|
226
228
|
class UnmatchingOverrides < StandardError
|
|
227
229
|
def initialize(args)
|
|
228
|
-
super
|
|
229
|
-
"the repository named #{args[:ini]["name"].bold.red} in the ini file"
|
|
230
|
+
super("The repository n.#{args[:num]} named #{args[:repo].name.bold.red} doesn't match with " \
|
|
231
|
+
"the repository named #{args[:ini]["name"].bold.red} in the ini file")
|
|
230
232
|
end
|
|
231
233
|
|
|
232
234
|
def error_code
|
|
@@ -239,7 +241,7 @@ module Zypper
|
|
|
239
241
|
#
|
|
240
242
|
class AlreadyUpgraded < StandardError
|
|
241
243
|
def initialize(version)
|
|
242
|
-
super
|
|
244
|
+
super("The system is already upgraded to the #{version} version")
|
|
243
245
|
end
|
|
244
246
|
|
|
245
247
|
def error_code
|
|
@@ -252,7 +254,7 @@ module Zypper
|
|
|
252
254
|
#
|
|
253
255
|
class NoUnstableVersionAvailable < StandardError
|
|
254
256
|
def initialize
|
|
255
|
-
super
|
|
257
|
+
super("No unstable version is available, remove the --allow-unstable switch to continue")
|
|
256
258
|
end
|
|
257
259
|
|
|
258
260
|
def error_code
|
|
@@ -262,9 +264,10 @@ module Zypper
|
|
|
262
264
|
|
|
263
265
|
#
|
|
264
266
|
# No internet connection.
|
|
267
|
+
#
|
|
265
268
|
class NoConnection < StandardError
|
|
266
269
|
def initialize
|
|
267
|
-
super
|
|
270
|
+
super("Internet connection has some trouble")
|
|
268
271
|
end
|
|
269
272
|
|
|
270
273
|
def error_code
|
|
@@ -272,12 +275,25 @@ module Zypper
|
|
|
272
275
|
end
|
|
273
276
|
end
|
|
274
277
|
|
|
278
|
+
#
|
|
279
|
+
# No support for x86_64-v2 instructions.
|
|
280
|
+
#
|
|
281
|
+
class UnsupportedV2 < StandardError
|
|
282
|
+
def initialize
|
|
283
|
+
super("The CPU doesn't support the x86_64-v2 instruction set required by openSUSE 16.0 and sup.")
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def error_code
|
|
287
|
+
16
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
|
|
275
291
|
#
|
|
276
292
|
# Ctrl + C message error.
|
|
277
293
|
#
|
|
278
294
|
class Interruption < StandardError
|
|
279
295
|
def initialize
|
|
280
|
-
super
|
|
296
|
+
super("Ok ok... Exiting!")
|
|
281
297
|
end
|
|
282
298
|
end
|
|
283
299
|
|
|
@@ -61,7 +61,7 @@ module Zypper
|
|
|
61
61
|
puts (char * (max_col + 20)).send(color)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
def self.header(
|
|
64
|
+
def self.header(*)
|
|
65
65
|
puts " # | Report"
|
|
66
66
|
end
|
|
67
67
|
|
|
@@ -83,8 +83,11 @@ module Zypper
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
def self.info(repo)
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
old_name = repo.upgraded?(:name) ? "(#{repo.old_name.yellow})" : ""
|
|
87
|
+
old_alias = repo.upgraded?(:alias) ? "(#{repo.old_alias.yellow})" : ""
|
|
88
|
+
|
|
89
|
+
puts " #{" " * 2} | Name: #{repo.name} #{old_name}"
|
|
90
|
+
puts " #{" " * 2} | Alias: #{repo.alias} #{old_alias}"
|
|
88
91
|
puts " #{" " * 2} | Url: #{repo.url}"
|
|
89
92
|
puts " #{" " * 2} | (#{repo.old_url.yellow})" if repo.upgraded?
|
|
90
93
|
puts " #{" " * 2} | Priority: #{repo.priority}"
|
|
@@ -345,7 +348,6 @@ module Zypper
|
|
|
345
348
|
end
|
|
346
349
|
|
|
347
350
|
def self.info(num, status, repo, valid: true, suggested: "")
|
|
348
|
-
@@number = num
|
|
349
351
|
puts "[repository_#{num}]"
|
|
350
352
|
puts "name=#{repo.name}"
|
|
351
353
|
puts "alias=#{repo.alias}"
|
|
@@ -424,7 +426,6 @@ module Zypper
|
|
|
424
426
|
end
|
|
425
427
|
|
|
426
428
|
def self.info(num, status, repo, valid: true, suggested: "")
|
|
427
|
-
@@number = num
|
|
428
429
|
puts "[repository_#{num}]"
|
|
429
430
|
puts "name=#{repo.name}"
|
|
430
431
|
puts "alias=#{repo.alias}"
|
data/lib/zypper/upgraderepo.rb
CHANGED
|
@@ -60,26 +60,12 @@ module Zypper
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def duplicates
|
|
63
|
-
dups = {}
|
|
64
|
-
dcount = 0
|
|
65
63
|
@view_class.duplicates_header(@repos.max_col)
|
|
66
64
|
@view_class.separator(@repos.max_col, "=", :yellow)
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
65
|
+
dcount = 0
|
|
66
|
+
@repos.duplicates.each_value do |list|
|
|
77
67
|
dcount += list.count.pred
|
|
78
|
-
list
|
|
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)
|
|
68
|
+
print_duplicates list
|
|
83
69
|
end
|
|
84
70
|
@view_class.duplicates_footer(dcount, @repos.list.count)
|
|
85
71
|
end
|
|
@@ -89,8 +75,7 @@ module Zypper
|
|
|
89
75
|
@view_class.unused_header(@repos.max_col)
|
|
90
76
|
@view_class.separator(@repos.max_col)
|
|
91
77
|
@repos.each_with_number do |repo, num|
|
|
92
|
-
|
|
93
|
-
next unless packs.zero?
|
|
78
|
+
next unless repo.unused?
|
|
94
79
|
|
|
95
80
|
ucount += 1
|
|
96
81
|
@view_class.unused_item(num, ucount, repo, @repos.max_col)
|
|
@@ -135,7 +120,38 @@ module Zypper
|
|
|
135
120
|
|
|
136
121
|
private
|
|
137
122
|
|
|
123
|
+
def print_duplicates(list)
|
|
124
|
+
list.each_with_index do |l, i|
|
|
125
|
+
@view_class.duplicates_item(l[:num], i.next, list.count, l[:repo], @repos.max_col)
|
|
126
|
+
@view_class.separator(@repos.max_col) unless i == list.count.pred
|
|
127
|
+
end
|
|
128
|
+
@view_class.separator(@repos.max_col, "=", :yellow)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# rubocop: disable Metrics/AbcSize, Metrics/MethodLength
|
|
132
|
+
def print_checked_repo(num, repo, version)
|
|
133
|
+
if repo.redirected?
|
|
134
|
+
@view_class.redirected num, repo, @repos.max_col, repo.redirected_to
|
|
135
|
+
elsif repo.not_found?
|
|
136
|
+
if @print_hint
|
|
137
|
+
@view_class.alternative num, repo, @repos.max_col, repo.evaluate_alternative(version)
|
|
138
|
+
else
|
|
139
|
+
@view_class.not_found num, repo, @repos.max_col
|
|
140
|
+
end
|
|
141
|
+
elsif repo.forbidden?
|
|
142
|
+
@view_class.forbidden num, repo, @repos.max_col
|
|
143
|
+
elsif repo.timeout?
|
|
144
|
+
@view_class.timeout num, repo, @repos.max_col
|
|
145
|
+
else
|
|
146
|
+
@view_class.server_error num, repo, @repos.max_col
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
# rubocop: enable Metrics/AbcSize, Metrics/MethodLength
|
|
150
|
+
|
|
151
|
+
# rubocop: disable Metrics/MethodLength
|
|
138
152
|
def check_repos(version)
|
|
153
|
+
check_requirements(version)
|
|
154
|
+
|
|
139
155
|
@view_class.header(@repos.max_col)
|
|
140
156
|
|
|
141
157
|
@repos.each_with_number do |repo, num|
|
|
@@ -146,28 +162,17 @@ module Zypper
|
|
|
146
162
|
else
|
|
147
163
|
raise UnableToUpgrade, { num: num, repo: repo } if @exit_on_fail
|
|
148
164
|
|
|
149
|
-
|
|
150
|
-
@view_class.redirected num, repo, @repos.max_col, repo.redirected_to
|
|
151
|
-
elsif repo.not_found?
|
|
152
|
-
if @print_hint
|
|
153
|
-
@view_class.alternative num, repo, @repos.max_col, repo.evaluate_alternative(version)
|
|
154
|
-
else
|
|
155
|
-
@view_class.not_found num, repo, @repos.max_col
|
|
156
|
-
end
|
|
157
|
-
elsif repo.forbidden?
|
|
158
|
-
@view_class.forbidden num, repo, @repos.max_col
|
|
159
|
-
elsif repo.timeout?
|
|
160
|
-
@view_class.timeout num, repo, @repos.max_col
|
|
161
|
-
else
|
|
162
|
-
@view_class.server_error num, repo, @repos.max_col
|
|
163
|
-
end
|
|
165
|
+
print_checked_repo num, repo, version
|
|
164
166
|
end
|
|
165
167
|
end
|
|
166
|
-
|
|
167
168
|
@view_class.footer @repos.max_col
|
|
168
169
|
end
|
|
170
|
+
# rubocop: enable Metrics/MethodLength
|
|
171
|
+
|
|
172
|
+
# rubocop: disable Metrics/MethodLength
|
|
173
|
+
def upgrade_repos(version)
|
|
174
|
+
check_requirements(version)
|
|
169
175
|
|
|
170
|
-
def upgrade_repos(_version)
|
|
171
176
|
@view_class.header(@repos.max_col, upgrade: true)
|
|
172
177
|
|
|
173
178
|
@repos.each_with_number do |repo, num|
|
|
@@ -185,6 +190,13 @@ module Zypper
|
|
|
185
190
|
@repos.save
|
|
186
191
|
Messages.ok "Repositories upgraded!"
|
|
187
192
|
end
|
|
193
|
+
# rubocop: enable Metrics/MethodLength
|
|
194
|
+
|
|
195
|
+
def check_requirements(version)
|
|
196
|
+
return unless @os_release.requires_v2?(version)
|
|
197
|
+
|
|
198
|
+
raise UnsupportedV2 unless @os_release.v2?
|
|
199
|
+
end
|
|
188
200
|
end
|
|
189
201
|
end
|
|
190
202
|
end
|
data/zypper-upgraderepo.gemspec
CHANGED
|
@@ -29,10 +29,6 @@ Gem::Specification.new do |spec|
|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
30
|
spec.require_paths = ["lib"]
|
|
31
31
|
|
|
32
|
-
spec.
|
|
33
|
-
spec.
|
|
34
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
-
|
|
36
|
-
spec.add_runtime_dependency "iniparse"
|
|
37
|
-
spec.add_runtime_dependency "minitar"
|
|
32
|
+
spec.add_dependency "iniparse"
|
|
33
|
+
spec.add_dependency "minitar"
|
|
38
34
|
end
|
metadata
CHANGED
|
@@ -1,57 +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.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fabio Mucciante
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.0'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '13.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '13.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
55
12
|
- !ruby/object:Gem::Dependency
|
|
56
13
|
name: iniparse
|
|
57
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,7 +77,6 @@ metadata:
|
|
|
120
77
|
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog
|
|
121
78
|
wiki_uri: https://github.com/fabiomux/zypper-upgraderepo/wiki
|
|
122
79
|
rubygems_mfa_required: 'true'
|
|
123
|
-
post_install_message:
|
|
124
80
|
rdoc_options: []
|
|
125
81
|
require_paths:
|
|
126
82
|
- lib
|
|
@@ -135,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
135
91
|
- !ruby/object:Gem::Version
|
|
136
92
|
version: '0'
|
|
137
93
|
requirements: []
|
|
138
|
-
rubygems_version: 3.
|
|
139
|
-
signing_key:
|
|
94
|
+
rubygems_version: 3.6.7
|
|
140
95
|
specification_version: 4
|
|
141
96
|
summary: Zypper addon to check and upgrade local repositories.
|
|
142
97
|
test_files: []
|