zypper-upgraderepo 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zypper/upgraderepo.rb +1 -1
- data/lib/zypper/upgraderepo/cli.rb +5 -0
- data/lib/zypper/upgraderepo/os_release.rb +1 -1
- data/lib/zypper/upgraderepo/repository.rb +28 -1
- data/lib/zypper/upgraderepo/request.rb +17 -175
- data/lib/zypper/upgraderepo/requests/http.rb +131 -0
- data/lib/zypper/upgraderepo/requests/local.rb +94 -0
- data/lib/zypper/upgraderepo/traversable.rb +93 -0
- data/lib/zypper/upgraderepo/utils.rb +6 -0
- data/lib/zypper/upgraderepo/version.rb +1 -1
- data/lib/zypper/upgraderepo/view.rb +15 -2
- data/zypper-upgraderepo.gemspec +19 -19
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44bef40acdc725f7422911297413011d47e967d568497f74770ae162494a60dd
|
4
|
+
data.tar.gz: 4fa8b988dc188ee5deb97671ee31e99db1cf64efde819b8be2b5fef630b0b352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6385cf9e04fcdd33ee544b64d64e16c123f750493d1a9b3b67eac84d167006debb05fada54488eaa7d5cbb414378d1ffd14e528d086cbe5b93af680ac643aa13
|
7
|
+
data.tar.gz: ca6a79d5387b76704b93994ff3e11bf0170f1950bbccad3335ff1564cde32d97edf55388c686858c75e594a3e46ac758ba2a66c1fadfba0b5b24157459240d31
|
data/Gemfile.lock
CHANGED
data/lib/zypper/upgraderepo.rb
CHANGED
@@ -13,7 +13,7 @@ module Zypper
|
|
13
13
|
class Builder
|
14
14
|
def initialize(options)
|
15
15
|
@os_release = OsRelease.new(options)
|
16
|
-
@repos = RepositoryList.new(options)
|
16
|
+
@repos = RepositoryList.new(options).resolve_variables!(@os_release.current)
|
17
17
|
@print_hint = options.hint
|
18
18
|
@view_class = Zypper::Upgraderepo::View.const_get options.view.to_s.capitalize
|
19
19
|
|
@@ -26,6 +26,7 @@ module Zypper
|
|
26
26
|
options.exit_on_fail = false
|
27
27
|
options.overrides_filename = nil
|
28
28
|
options.only_invalid = false
|
29
|
+
options.only_protocols = nil
|
29
30
|
|
30
31
|
opt_parser = OptionParser.new do |opt|
|
31
32
|
|
@@ -116,6 +117,10 @@ module Zypper
|
|
116
117
|
options.only_invalid = true
|
117
118
|
end
|
118
119
|
|
120
|
+
opt.on('--only-protocols <PROTOCOL>[,<PROTOCOL2>,...]', Array, "Show only from protocols (supported: #{Request.protocols.join(',')})") do |o|
|
121
|
+
options.only_protocols = o
|
122
|
+
end
|
123
|
+
|
119
124
|
opt.separator ''
|
120
125
|
opt.separator 'View options:'
|
121
126
|
|
@@ -16,12 +16,13 @@ module Zypper
|
|
16
16
|
@only_repo = options.only_repo
|
17
17
|
@only_enabled = options.only_enabled
|
18
18
|
@only_invalid = options.only_invalid
|
19
|
+
@only_protocols = options.only_protocols
|
19
20
|
@overrides = options.overrides
|
20
21
|
@upgrade_options = {alias: options.alias, name: options.name}
|
21
22
|
@list = []
|
22
23
|
|
23
24
|
Dir.glob(File.join(REPOSITORY_PATH, '*.repo')).each do |i|
|
24
|
-
r =
|
25
|
+
r = Request.build(Repository.new(i), options.timeout)
|
25
26
|
@list << r
|
26
27
|
end
|
27
28
|
@max_col = @list.max_by { |r| r.name.length }.name.length
|
@@ -48,16 +49,30 @@ module Zypper
|
|
48
49
|
only_repo = options[:only_repo].nil? ? @only_repo : options[:only_repo]
|
49
50
|
only_enabled = options[:only_enabled].nil? ? @only_enabled : options[:only_enabled]
|
50
51
|
only_invalid = options[:only_invalid].nil? ? @only_invalid : options[:only_invalid]
|
52
|
+
only_protocols = options[:only_protocols].nil? ? @only_protocols : options[:only_protocols]
|
51
53
|
|
52
54
|
@list.each do |x|
|
53
55
|
next if only_repo && !only_repo.include?(x[:num])
|
54
56
|
next if only_enabled && !x[:repo].enabled?
|
55
57
|
next if only_invalid && x[:repo].available?
|
58
|
+
next if only_protocols && (!only_protocols.include?(x[:repo].protocol))
|
56
59
|
|
57
60
|
yield x[:repo], x[:num] if block_given?
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
64
|
+
def resolve_variables!(version)
|
65
|
+
each_with_number do |r|
|
66
|
+
if r.url =~ /\$/
|
67
|
+
r.url = r.url.gsub(/\$releasever_major/, version.split('.')[0])
|
68
|
+
.gsub(/\$releasever_minor/, version.split('.')[1])
|
69
|
+
.gsub(/\$releasever/, version)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
61
76
|
def save
|
62
77
|
@list.each do |i|
|
63
78
|
i.save
|
@@ -131,6 +146,18 @@ module Zypper
|
|
131
146
|
@repo[@key]['baseurl'] = value
|
132
147
|
end
|
133
148
|
|
149
|
+
def protocol
|
150
|
+
URI(url.to_s).scheme
|
151
|
+
end
|
152
|
+
|
153
|
+
def unversioned?
|
154
|
+
(url =~ /\d\d\.\d/).nil?
|
155
|
+
end
|
156
|
+
|
157
|
+
def versioned?
|
158
|
+
!unversioned?
|
159
|
+
end
|
160
|
+
|
134
161
|
def alias
|
135
162
|
@key
|
136
163
|
end
|
@@ -1,200 +1,42 @@
|
|
1
1
|
require 'delegate'
|
2
|
-
|
2
|
+
require_relative 'traversable.rb'
|
3
|
+
require_relative 'requests/local.rb'
|
4
|
+
require_relative 'requests/http.rb'
|
3
5
|
|
4
6
|
module Zypper
|
5
7
|
module Upgraderepo
|
6
8
|
|
7
9
|
|
8
|
-
class
|
10
|
+
class Request
|
9
11
|
|
10
|
-
|
12
|
+
def self.build(repo, timeout)
|
13
|
+
@@registry ||= self.load_requests
|
11
14
|
|
12
|
-
|
15
|
+
raise InvalidProtocol, repo unless @@registry.include? repo.protocol
|
13
16
|
|
14
|
-
|
15
|
-
super obj
|
16
|
-
@timeout = timeout
|
17
|
+
Object.const_get(@@registry[repo.protocol]).new(repo, timeout)
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
20
|
+
def self.protocols
|
21
|
+
self.load_requests.keys
|
21
22
|
end
|
22
23
|
|
23
|
-
def redirected?
|
24
|
-
ping.is_a?(Net::HTTPRedirection)
|
25
|
-
end
|
26
|
-
|
27
|
-
def redirected_to
|
28
|
-
ping['location']
|
29
|
-
end
|
30
|
-
|
31
|
-
def not_found?
|
32
|
-
ping.is_a?(Net::HTTPNotFound)
|
33
|
-
end
|
34
|
-
|
35
|
-
def forbidden?
|
36
|
-
ping.is_a?(Net::HTTPForbidden)
|
37
|
-
end
|
38
|
-
|
39
|
-
def timeout?
|
40
|
-
ping.is_a?(Net::HTTPRequestTimeOut)
|
41
|
-
end
|
42
|
-
|
43
|
-
def status
|
44
|
-
ping.class.to_s
|
45
|
-
end
|
46
|
-
|
47
|
-
def cache!
|
48
|
-
@page = nil
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def get_request(uri, head)
|
55
|
-
uri ||= repodata_uri
|
56
|
-
|
57
|
-
if head
|
58
|
-
request = Net::HTTP::Head.new(uri.request_uri)
|
59
|
-
else
|
60
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
61
|
-
end
|
62
|
-
|
63
|
-
request['User-Agent'] = USER_AGENT
|
64
|
-
|
65
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
66
|
-
http.use_ssl = (uri.scheme == "https")
|
67
|
-
http.open_timeout = @timeout
|
68
|
-
|
69
|
-
http.request(request)
|
70
|
-
end
|
71
|
-
|
72
|
-
def ping(uri = nil, head = true)
|
73
|
-
begin
|
74
|
-
if @page.nil? || uri
|
75
|
-
@page = get_request(uri, head)
|
76
|
-
end
|
77
|
-
rescue SocketError
|
78
|
-
raise NoConnection
|
79
|
-
rescue Net::OpenTimeout
|
80
|
-
@page = Net::HTTPRequestTimeOut.new('1.1', '', '')
|
81
|
-
end
|
82
|
-
@page
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
class RepositoryRequest < PageRequest
|
89
|
-
|
90
|
-
def evaluate_alternative(version)
|
91
|
-
|
92
|
-
if not_found?
|
93
|
-
return traverse_url(URI(url), version)
|
94
|
-
elsif redirected?
|
95
|
-
return { url: redirected_to, message: 'Redirected to:' }
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
24
|
private
|
101
25
|
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
elsif available? && uri.to_s =~ /#{version}/
|
108
|
-
res = traverse_url_forward(uri, version)
|
109
|
-
else
|
110
|
-
res = traverse_url_backward(uri, version)
|
111
|
-
end
|
112
|
-
|
113
|
-
res || { url: '', message: 'Can\'t find a valid alternative, try manually!' }
|
114
|
-
end
|
115
|
-
|
116
|
-
def traverse_url_backward(uri, version)
|
117
|
-
uri.path = File.dirname(uri.path)
|
118
|
-
|
119
|
-
return nil if uri.path == '/' || uri.path == '.'
|
120
|
-
|
121
|
-
uri.path += '/' if uri.path[-1] != '/'
|
122
|
-
ping(uri, false)
|
123
|
-
|
124
|
-
if not_found?
|
125
|
-
return traverse_url_backward(uri, version)
|
126
|
-
elsif available?
|
127
|
-
|
128
|
-
if uri.path =~ /#{version}/ && repodata?
|
129
|
-
return {url: uri.to_s, message: 'Override with this one' }
|
130
|
-
elsif res = traverse_url_forward(uri, version, !(uri.path =~ /#{version}/))
|
131
|
-
return res
|
132
|
-
else
|
133
|
-
return traverse_url_backward(uri, version)
|
26
|
+
def self.load_requests
|
27
|
+
res = {}
|
28
|
+
Requests.constants.each do |klass|
|
29
|
+
Object.const_get("Zypper::Upgraderepo::Requests::#{klass}").register_protocol.each do |protocol|
|
30
|
+
res[protocol] = "Zypper::Upgraderepo::Requests::#{klass}"
|
134
31
|
end
|
135
|
-
|
136
|
-
elsif forbidden?
|
137
|
-
return { url: uri.to_s, message: 'Try to replace with this one' } if repodata?(uri)
|
138
|
-
|
139
|
-
return traverse_url_backward(uri, version)
|
140
32
|
end
|
141
33
|
|
142
|
-
nil
|
143
|
-
end
|
144
|
-
|
145
|
-
def traverse_url_forward(uri, version, check_version = false)
|
146
|
-
uri.path += '/' if uri.path[-1] != '/'
|
147
|
-
ping(uri, false)
|
148
|
-
|
149
|
-
subfolders(version, check_version).each do |dir|
|
150
|
-
u = URI(uri.to_s)
|
151
|
-
u.path += dir
|
152
|
-
|
153
|
-
if repodata?(u)
|
154
|
-
return {url: u.to_s, message: 'Override with this one' }
|
155
|
-
else
|
156
|
-
res = traverse_url_forward(u, version)
|
157
|
-
return res if res.class == Hash
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
nil
|
162
|
-
end
|
163
|
-
|
164
|
-
def repodata_uri(uri = nil)
|
165
|
-
if uri
|
166
|
-
uri = URI(uri.to_s)
|
167
|
-
else
|
168
|
-
uri = URI(url)
|
169
|
-
end
|
170
|
-
|
171
|
-
uri.path = uri.path.gsub(/\/$/, '') + '/repodata/repomd.xml'
|
172
|
-
|
173
|
-
uri
|
174
|
-
end
|
175
|
-
|
176
|
-
def repodata?(uri = nil)
|
177
|
-
if uri.nil?
|
178
|
-
return ping.body.to_s.scan(Regexp.new("href=\"repodata/")).empty?
|
179
|
-
else
|
180
|
-
ping(repodata_uri(uri))
|
181
|
-
return available?
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def subfolders(version, check_version)
|
186
|
-
res = ping.body.to_s.scan(Regexp.new('href=[\'\"][^\/\"]+\/[\'\"]')).delete_if do |x|
|
187
|
-
x =~ /^\// || x =~ /^\.\./ || x =~ /\:\/\// || x =~ /href=[\"\'](media\.1|boot|EFI)\/[\"\']/
|
188
|
-
end.uniq.map do |d|
|
189
|
-
d.scan(/href=[\"\']([^"]+)[\'\"]/).pop.pop
|
190
|
-
end
|
191
|
-
|
192
|
-
res = res.delete_if { |x| !(x =~ /#{version}/) } if check_version
|
193
|
-
|
194
34
|
res
|
195
35
|
end
|
36
|
+
|
196
37
|
end
|
197
38
|
|
198
39
|
|
40
|
+
|
199
41
|
end
|
200
42
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Zypper
|
5
|
+
module Upgraderepo
|
6
|
+
|
7
|
+
class PageRequest < SimpleDelegator
|
8
|
+
|
9
|
+
attr_reader :page
|
10
|
+
|
11
|
+
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0'
|
12
|
+
|
13
|
+
def initialize(obj, timeout = 60)
|
14
|
+
super obj
|
15
|
+
@timeout = timeout
|
16
|
+
end
|
17
|
+
|
18
|
+
def available?
|
19
|
+
ping.is_a?(Net::HTTPSuccess)
|
20
|
+
end
|
21
|
+
|
22
|
+
def redirected?
|
23
|
+
ping.is_a?(Net::HTTPRedirection)
|
24
|
+
end
|
25
|
+
|
26
|
+
def redirected_to
|
27
|
+
ping['location']
|
28
|
+
end
|
29
|
+
|
30
|
+
def not_found?
|
31
|
+
ping.is_a?(Net::HTTPNotFound)
|
32
|
+
end
|
33
|
+
|
34
|
+
def forbidden?
|
35
|
+
ping.is_a?(Net::HTTPForbidden)
|
36
|
+
end
|
37
|
+
|
38
|
+
def timeout?
|
39
|
+
ping.is_a?(Net::HTTPRequestTimeOut)
|
40
|
+
end
|
41
|
+
|
42
|
+
def status
|
43
|
+
ping.class.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
def cache!
|
47
|
+
@page = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def get_request(uri, head)
|
54
|
+
|
55
|
+
if head
|
56
|
+
request = Net::HTTP::Head.new(uri.request_uri)
|
57
|
+
else
|
58
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
59
|
+
end
|
60
|
+
|
61
|
+
request['User-Agent'] = USER_AGENT
|
62
|
+
|
63
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
64
|
+
http.use_ssl = (uri.scheme == 'https')
|
65
|
+
http.open_timeout = @timeout
|
66
|
+
|
67
|
+
http.request(request)
|
68
|
+
end
|
69
|
+
|
70
|
+
def ping(uri = nil, head = true)
|
71
|
+
begin
|
72
|
+
if @page.nil? || uri
|
73
|
+
@page = get_request(uri, head)
|
74
|
+
end
|
75
|
+
rescue SocketError
|
76
|
+
raise NoConnection
|
77
|
+
rescue Net::OpenTimeout
|
78
|
+
@page = Net::HTTPRequestTimeOut.new('1.1', '', '')
|
79
|
+
end
|
80
|
+
@page
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
module Requests
|
87
|
+
|
88
|
+
class HttpRequest < PageRequest
|
89
|
+
|
90
|
+
include Traversable
|
91
|
+
|
92
|
+
def max_drop_back; 0; end
|
93
|
+
|
94
|
+
def self.register_protocol; ['https', 'http'] end
|
95
|
+
|
96
|
+
def evaluate_alternative(version)
|
97
|
+
if not_found?
|
98
|
+
return traverse_url(URI(url), version)
|
99
|
+
elsif redirected?
|
100
|
+
return { url: redirected_to, message: 'Redirected to:' }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def get_request(uri, head)
|
108
|
+
#super uri || URI(url), head
|
109
|
+
super uri || repodata_uri, head
|
110
|
+
end
|
111
|
+
|
112
|
+
def has_repodata?(uri)
|
113
|
+
ping(repodata_uri(uri))
|
114
|
+
available?
|
115
|
+
end
|
116
|
+
|
117
|
+
def subfolders
|
118
|
+
res = ping.body.to_s.scan(Regexp.new('href=[\'\"][^\/\"]+\/[\'\"]')).delete_if do |x|
|
119
|
+
x =~ /^\// || x =~ /^\.\./ || x =~ /\:\/\// || x =~ /href=[\"\'](media\.1|boot|EFI)\/[\"\']/
|
120
|
+
end.uniq.map do |d|
|
121
|
+
d.scan(/href=[\"\']([^"]+)[\'\"]/).pop.pop
|
122
|
+
end
|
123
|
+
|
124
|
+
res
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
module Zypper
|
4
|
+
module Upgraderepo
|
5
|
+
|
6
|
+
|
7
|
+
class DirRequest < SimpleDelegator
|
8
|
+
|
9
|
+
attr_reader :dir_path
|
10
|
+
|
11
|
+
def initialize(obj, timeout)
|
12
|
+
super obj
|
13
|
+
end
|
14
|
+
|
15
|
+
def available?
|
16
|
+
Dir.exist? ping
|
17
|
+
end
|
18
|
+
|
19
|
+
def redirected?
|
20
|
+
File.symlink? ping
|
21
|
+
end
|
22
|
+
|
23
|
+
def redirected_to
|
24
|
+
File.realpath ping
|
25
|
+
end
|
26
|
+
|
27
|
+
def not_found?
|
28
|
+
!available?
|
29
|
+
end
|
30
|
+
|
31
|
+
def forbidden?
|
32
|
+
File.readable? ping
|
33
|
+
end
|
34
|
+
|
35
|
+
def timeout?
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def status
|
40
|
+
File.stat ping
|
41
|
+
end
|
42
|
+
|
43
|
+
def cache!
|
44
|
+
@dir_path = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def ping(uri = nil, head = true)
|
51
|
+
@dir_path ||= URI(url).path
|
52
|
+
|
53
|
+
@dir_path = uri.to_s =~ /^\// ? uri.to_s : URI(uri.to_s).path if uri
|
54
|
+
|
55
|
+
URI.unescape(@dir_path)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
module Requests
|
62
|
+
|
63
|
+
class LocalRequest < DirRequest
|
64
|
+
|
65
|
+
include Traversable
|
66
|
+
|
67
|
+
def max_drop_back; 1 end
|
68
|
+
|
69
|
+
def self.register_protocol; ['dir'] end
|
70
|
+
|
71
|
+
def evaluate_alternative(version)
|
72
|
+
if not_found?
|
73
|
+
return traverse_url(URI(url), version)
|
74
|
+
elsif redirected?
|
75
|
+
return { url: redirected_to, message: 'Linked to' }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def has_repodata?(uri)
|
83
|
+
File.exist? URI.unescape(repodata_uri(uri).path)
|
84
|
+
end
|
85
|
+
|
86
|
+
def subfolders
|
87
|
+
Dir.glob(ping.gsub(/\/$/, '') + '/*/').map { |x| URI.escape(x.gsub(/\/$/, '').gsub(ping, '').gsub(/^\//, '')) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Zypper
|
2
|
+
module Upgraderepo
|
3
|
+
|
4
|
+
module Traversable
|
5
|
+
|
6
|
+
def traverse_url(uri, version)
|
7
|
+
ping(uri)
|
8
|
+
|
9
|
+
if forbidden?
|
10
|
+
res = { url: url, message: 'Can\'t navigate through the repository!' }
|
11
|
+
elsif available? && uri.to_s =~ /#{version}/
|
12
|
+
res = traverse_url_forward(uri, version)
|
13
|
+
else
|
14
|
+
res = traverse_url_backward(uri, version)
|
15
|
+
end
|
16
|
+
|
17
|
+
res || { url: '', message: 'Can\'t find a valid alternative, try manually!' }
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def traverse_url_backward(uri, version)
|
24
|
+
uri.path = File.dirname(uri.path)
|
25
|
+
|
26
|
+
return nil if uri.path == '/' || uri.path == '.' || (versioned? && (drop_back_level(uri) > max_drop_back))
|
27
|
+
|
28
|
+
uri.path += '/' if uri.path[-1] != '/'
|
29
|
+
ping(uri, false)
|
30
|
+
|
31
|
+
if not_found?
|
32
|
+
return traverse_url_backward(uri, version)
|
33
|
+
elsif available?
|
34
|
+
if res = traverse_url_forward(uri, version)
|
35
|
+
return res
|
36
|
+
else
|
37
|
+
return traverse_url_backward(uri, version)
|
38
|
+
end
|
39
|
+
elsif forbidden?
|
40
|
+
return { url: uri.to_s, message: 'Try to replace with this one' } if has_repodata?(uri)
|
41
|
+
|
42
|
+
return traverse_url_backward(uri, version)
|
43
|
+
end
|
44
|
+
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def traverse_url_forward(uri, version)
|
49
|
+
uri.path += '/' if uri.path[-1] != '/'
|
50
|
+
ping(uri, false)
|
51
|
+
|
52
|
+
subfolders.each do |dir|
|
53
|
+
u = URI(uri.to_s)
|
54
|
+
u.path += dir
|
55
|
+
|
56
|
+
if has_repodata?(u)
|
57
|
+
if (versioned?) && (u.to_s =~ /#{version}/)
|
58
|
+
return { url: u.to_s, message: 'Override with this one' }
|
59
|
+
end
|
60
|
+
else
|
61
|
+
res = traverse_url_forward(u, version)
|
62
|
+
return res if res.class == Hash
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def repodata_uri(uri = nil)
|
70
|
+
if uri
|
71
|
+
uri = URI(uri.to_s)
|
72
|
+
else
|
73
|
+
uri = URI(url)
|
74
|
+
end
|
75
|
+
|
76
|
+
uri.path = uri.path.gsub(/\/$/, '') + '/repodata/repomd.xml'
|
77
|
+
|
78
|
+
uri
|
79
|
+
end
|
80
|
+
|
81
|
+
def drop_back_level(uri)
|
82
|
+
URI(url).path.split('/').index { |x| x =~ /\d\d.\d/ } - uri.path.split('/').count
|
83
|
+
end
|
84
|
+
|
85
|
+
# to implement on each repository type class
|
86
|
+
#
|
87
|
+
# def has_repodata?(uri)
|
88
|
+
#
|
89
|
+
# def subfolders
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -65,6 +65,12 @@ module Zypper
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
class InvalidProtocol < StandardError
|
69
|
+
def initialize(repo)
|
70
|
+
super "The repository #{repo.name} has an unknown protocol: #{repo.protocol}; disable it to continue."
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
68
74
|
class InvalidVersion < StandardError
|
69
75
|
def initialize(version)
|
70
76
|
super "The version #{version} is not valid"
|
@@ -7,6 +7,7 @@ module Zypper
|
|
7
7
|
|
8
8
|
def self.available(num, repo, max_col)
|
9
9
|
puts " #{num.to_s.rjust(2).bold.green} | Status: #{'Ok'.bold.green}"
|
10
|
+
puts " #{' ' * 2} | Hint: Unversioned repository" if repo.unversioned? && repo.old_url
|
10
11
|
self.info(repo)
|
11
12
|
end
|
12
13
|
|
@@ -73,7 +74,11 @@ module Zypper
|
|
73
74
|
class Table
|
74
75
|
|
75
76
|
def self.available(num, repo, max_col)
|
76
|
-
|
77
|
+
if repo.unversioned? && repo.old_url
|
78
|
+
Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | Unversioned repository")
|
79
|
+
else
|
80
|
+
Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} |")
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
def self.redirected(num, repo, max_col, redirected)
|
@@ -203,8 +208,16 @@ module Zypper
|
|
203
208
|
puts "[repository_#{num}]"
|
204
209
|
puts "name=#{repo.name}"
|
205
210
|
puts "alias=#{repo.alias}"
|
206
|
-
puts "old_url=#{repo.old_url}"
|
211
|
+
puts "old_url=#{repo.old_url}" if repo.upgraded?
|
207
212
|
if valid
|
213
|
+
if repo.unversioned? && repo.old_url
|
214
|
+
puts <<-'HEADER'.gsub(/^ +/, '')
|
215
|
+
# The repository is unversioned: its packages should be perfectly
|
216
|
+
# working regardless the distribution version, that because all the
|
217
|
+
# required dependencies are included in the repository itself and
|
218
|
+
# automatically picked up.
|
219
|
+
HEADER
|
220
|
+
end
|
208
221
|
puts "url=#{repo.url}"
|
209
222
|
elsif repo.enabled?
|
210
223
|
puts <<-'HEADER'.gsub(/^ +/, '')
|
data/zypper-upgraderepo.gemspec
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require 'zypper/upgraderepo/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'zypper-upgraderepo'
|
8
8
|
spec.version = Zypper::Upgraderepo::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Fabio Mucciante']
|
10
|
+
spec.email = ['fabio.mucciante@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = %q{Zypper addon to check and upgrade local repositories.}
|
13
13
|
spec.description = %q{This is just a complement to zypper command which helps to upgrade the local repositories before executing zypper dup.}
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/fabiomux/zypper-upgraderepo'
|
15
|
+
spec.license = 'GPL-3.0'
|
16
16
|
|
17
17
|
spec.metadata = {
|
18
|
-
"bug_tracker_uri" =>
|
19
|
-
|
18
|
+
"bug_tracker_uri" => 'https://github.com/fabiomux/zypper-upgraderepo/issues',
|
19
|
+
"changelog_uri" => 'https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelogs',
|
20
20
|
"documentation_uri" => "https://www.rubydoc.info/gems/zypper-upgraderepo/#{spec.version}",
|
21
|
-
"homepage_uri" =>
|
22
|
-
#"mailing_list_uri" =>
|
23
|
-
"source_code_uri" =>
|
24
|
-
"wiki_uri" =>
|
21
|
+
"homepage_uri" => 'https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html',
|
22
|
+
#"mailing_list_uri" => '',
|
23
|
+
"source_code_uri" => 'https://github.com/fabiomux/zypper-upgraderepo',
|
24
|
+
"wiki_uri" => 'https://github.com/fabiomux/zypper-upgraderepo/wiki'
|
25
25
|
}
|
26
26
|
|
27
27
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
28
28
|
f.match(%r{^(test|spec|features)/})
|
29
29
|
end
|
30
|
-
spec.bindir =
|
30
|
+
spec.bindir = 'exe'
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = [
|
32
|
+
spec.require_paths = ['lib']
|
33
33
|
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
34
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
35
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
37
|
|
38
|
-
spec.add_runtime_dependency
|
39
|
-
spec.add_runtime_dependency
|
38
|
+
spec.add_runtime_dependency 'iniparse'
|
39
|
+
spec.add_runtime_dependency 'minitar'
|
40
40
|
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.5.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: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,9 @@ files:
|
|
107
107
|
- lib/zypper/upgraderepo/os_release.rb
|
108
108
|
- lib/zypper/upgraderepo/repository.rb
|
109
109
|
- lib/zypper/upgraderepo/request.rb
|
110
|
+
- lib/zypper/upgraderepo/requests/http.rb
|
111
|
+
- lib/zypper/upgraderepo/requests/local.rb
|
112
|
+
- lib/zypper/upgraderepo/traversable.rb
|
110
113
|
- lib/zypper/upgraderepo/utils.rb
|
111
114
|
- lib/zypper/upgraderepo/version.rb
|
112
115
|
- lib/zypper/upgraderepo/view.rb
|
@@ -116,8 +119,9 @@ licenses:
|
|
116
119
|
- GPL-3.0
|
117
120
|
metadata:
|
118
121
|
bug_tracker_uri: https://github.com/fabiomux/zypper-upgraderepo/issues
|
119
|
-
|
120
|
-
|
122
|
+
changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelogs
|
123
|
+
documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.5.0
|
124
|
+
homepage_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html
|
121
125
|
source_code_uri: https://github.com/fabiomux/zypper-upgraderepo
|
122
126
|
wiki_uri: https://github.com/fabiomux/zypper-upgraderepo/wiki
|
123
127
|
post_install_message:
|