zypper-upgraderepo 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,143 +1,165 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Zypper
2
4
  module Upgraderepo
3
-
4
5
  module View
5
-
6
+ #
7
+ # Report style output.
8
+ #
6
9
  class Report
10
+ def self.available(num, repo, _max_col)
11
+ puts " #{num.to_s.rjust(2).bold.green} | Status: #{"Ok".bold.green}"
12
+ puts " #{" " * 2} | Hint: Unversioned repository" if repo.unversioned? && repo.old_url
13
+ info(repo)
14
+ end
7
15
 
8
- def self.available(num, repo, max_col)
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
11
- self.info(repo)
16
+ def self.redirected(num, repo, _max_col, redirected)
17
+ puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Redirected".bold.yellow}"
18
+ puts " #{" " * 2} | #{"To:".bold.yellow} #{redirected}"
19
+ info(repo)
12
20
  end
13
21
 
14
- def self.redirected(num, repo, max_col, redirected)
15
- puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{'Redirected'.bold.yellow}"
16
- puts " #{' ' * 2} | #{'To:'.bold.yellow} #{redirected}"
17
- self.info(repo)
22
+ def self.not_found(num, repo, _max_col)
23
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
24
+ info(repo)
18
25
  end
19
26
 
20
- def self.not_found(num, repo, max_col)
21
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Not Found'.bold.red}"
22
- self.info(repo)
27
+ def self.forbidden(num, repo, _max_col)
28
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Forbidden Path".bold.red}"
29
+ info(repo)
23
30
  end
24
31
 
25
- def self.forbidden(num, repo, max_col)
26
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Forbidden Path'.bold.red}"
27
- self.info(repo)
32
+ def self.alternative(num, repo, _max_col, alt)
33
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Not Found".bold.red}"
34
+ puts " #{" " * 2} | Hint: #{alt[:message].bold.yellow}"
35
+ puts " #{" " * 2} | #{"Suggested:".bold.yellow} #{alt[:url]}" unless alt[:url].to_s.empty?
36
+ info(repo)
28
37
  end
29
38
 
30
- def self.alternative(num, repo, max_col, alt)
31
- puts " #{num.to_s.rjust(2).bold.red} | Status: #{'Not Found'.bold.red}"
32
- puts " #{' ' * 2} | Hint: #{alt[:message].bold.yellow}"
33
- puts " #{' ' * 2} | #{'Suggested:'.bold.yellow} #{alt[:url]}" unless alt[:url].to_s.empty?
34
- self.info(repo)
39
+ def self.timeout(num, repo, _max_col)
40
+ puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{"Server Timeout".bold.yellow}"
41
+ info(repo)
35
42
  end
36
43
 
37
- def self.timeout(num, repo, max_col)
38
- puts " #{num.to_s.rjust(2).bold.yellow} | Status: #{'Server Timeout'.bold.yellow}"
39
- self.info(repo)
44
+ def self.upgraded(num, repo, _max_col)
45
+ puts " #{num.to_s.rjust(2).bold.green} | #{"Upgraded".bold.green}"
46
+ info(repo)
40
47
  end
41
48
 
42
- def self.upgraded(num, repo, max_col)
43
- puts " #{num.to_s.rjust(2).bold.green} | #{'Upgraded'.bold.green}"
44
- self.info(repo)
49
+ def self.untouched(num, repo, _max_col)
50
+ puts " #{num.to_s.rjust(2).bold.yellow} | #{"Untouched".bold.yellow}"
51
+ info(repo)
45
52
  end
46
53
 
47
- def self.untouched(num, repo, max_col)
48
- puts " #{num.to_s.rjust(2).bold.yellow} | #{'Untouched'.bold.yellow}"
49
- self.info(repo)
54
+ def self.server_error(num, repo, _max_col)
55
+ puts " #{num.to_s.rjust(2).bold.red} | Status: #{"Server Error".bold.red}"
56
+ puts " #{" " * 2} | Hint: #{repo.status}"
57
+ info(repo)
50
58
  end
51
59
 
52
- def self.separator
53
- puts '-' * 90
60
+ def self.separator(max_col)
61
+ puts "-" * (max_col + 20)
54
62
  end
55
63
 
56
- def self.header(max_col, upgrade = false)
64
+ def self.header(_max_col, _upgrade: false)
57
65
  puts " # | Report"
58
66
  end
59
67
 
60
- def self.footer
61
- self.separator
68
+ def self.footer(max_col)
69
+ separator max_col
62
70
  end
63
71
 
64
72
  def self.status(os_release)
65
- color = os_release.seniority == 0 ? :green : :yellow
66
- puts '----------------------------------------------'
73
+ color = os_release.seniority.zero? ? :green : :yellow
74
+ puts "----------------------------------------------"
67
75
  puts "Full name | #{os_release.fullname.bold}"
68
- puts '----------------------------------------------'
76
+ puts "----------------------------------------------"
69
77
  puts "Current release | #{os_release.current.send(color)}"
70
- puts "Next release | #{os_release.seniority > 0 ? os_release.next.bold.green : '-'}"
71
- puts "Last release | #{os_release.last.send(os_release.unstable ? :red : :clean)} (#{os_release.unstable ? 'Unstable'.bold.red : 'Stable'.bold.green})"
72
- puts "Available | #{os_release.seniority > 0 ? os_release.newer.map{ |i| i.bold }.join(', ') : '-' }"
73
- puts '----------------------------------------------'
78
+ puts "Next release | #{os_release.seniority.positive? ? os_release.next.bold.green : "-"}"
79
+ puts "Last release | #{os_release.last.send(os_release.unstable ? :red : :clean)} " \
80
+ "(#{os_release.unstable ? "Unstable".bold.red : "Stable".bold.green})"
81
+ puts "Available | #{os_release.seniority.positive? ? os_release.newer.map(&:bold).join(", ") : "-"}"
82
+ puts "----------------------------------------------"
74
83
  end
75
84
 
76
- private
77
-
78
85
  def self.info(repo)
79
- puts " #{ ' ' * 2 } | Name: #{repo.name} #{repo.upgraded?(:name) ? '(' + repo.old_name.yellow + ')' : '' }"
80
- puts " #{ ' ' * 2 } | Alias: #{repo.alias} #{repo.upgraded?(:alias) ? '(' + repo.old_alias.yellow + ')' : ''}"
81
- puts " #{ ' ' * 2 } | Url: #{repo.url}"
82
- puts " #{ ' ' * 2 } | (#{repo.old_url.yellow})" if repo.upgraded?
83
- puts " #{ ' ' * 2 } | Priority: #{repo.priority}"
84
- puts " #{ ' ' * 2 } | #{repo.enabled? ? 'Enabled: Yes' : 'Enabled: No'.yellow}"
85
- puts " #{ ' ' * 2 } | Filename: #{repo.filename}"
86
+ puts " #{" " * 2} | Name: #{repo.name} #{repo.upgraded?(:name) ? "(#{repo.old_name.yellow})" : ""}"
87
+ puts " #{" " * 2} | Alias: #{repo.alias} #{repo.upgraded?(:alias) ? "(#{repo.old_alias.yellow})" : ""}"
88
+ puts " #{" " * 2} | Url: #{repo.url}"
89
+ puts " #{" " * 2} | (#{repo.old_url.yellow})" if repo.upgraded?
90
+ puts " #{" " * 2} | Priority: #{repo.priority}"
91
+ puts " #{" " * 2} | #{repo.enabled? ? "Enabled: Yes" : "Enabled: No".yellow}"
92
+ puts " #{" " * 2} | Filename: #{repo.filename}"
86
93
  end
87
94
  end
88
95
 
89
-
96
+ #
97
+ # Table style output.
98
+ #
90
99
  class Table
91
-
92
100
  def self.available(num, repo, max_col)
93
101
  if repo.unversioned? && repo.old_url
94
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | Unversioned repository")
102
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
103
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | Unversioned repository")
95
104
  else
96
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} |")
105
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
106
+ "| #{repo.enabled? ? " Y " : " N ".yellow} |")
97
107
  end
98
108
  end
99
109
 
100
110
  def self.redirected(num, repo, max_col, redirected)
101
- Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Redirection'.bold.yellow} of #{repo.url} ")
102
- puts " #{' ' * 3} | #{' ' * 2} | #{ ' ' * max_col} | #{ ' ' * 3 } | #{'To:'.bold.yellow} #{redirected}"
111
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
112
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Redirection".bold.yellow} of #{repo.url} ")
113
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.yellow} #{redirected}"
103
114
  end
104
115
 
105
116
  def self.not_found(num, repo, max_col)
106
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Not Found'.bold.red}")
117
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
118
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Not Found".bold.red}")
107
119
  end
108
120
 
109
121
  def self.forbidden(num, repo, max_col)
110
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Forbidden path'.bold.red}")
122
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
123
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Forbidden path".bold.red}")
111
124
  end
112
125
 
113
126
  def self.alternative(num, repo, max_col, alt)
114
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{alt[:message].bold.yellow}")
115
- puts " #{' ' * 3} | #{' ' * 2} | #{' ' * max_col} | #{' ' * 3} | #{alt[:url]}" unless alt[:url].to_s.empty?
127
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
128
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{alt[:message].bold.yellow}")
129
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{alt[:url]}" unless alt[:url].to_s.empty?
116
130
  end
117
131
 
118
132
  def self.timeout(num, repo, max_col)
119
- Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Server Timeout'.bold.yellow}")
133
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
134
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Server Timeout".bold.yellow}")
120
135
  end
121
136
 
122
- def self.upgraded(num, repo, max_col) #, old_data)
123
- Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'From:'.bold.green} #{repo.old_url}")
124
- puts " #{' ' * 3} | #{' ' * 2} | #{' ' * max_col} | #{' ' * 3} | #{'To:'.bold.green} #{repo.url}"
137
+ def self.upgraded(num, repo, max_col)
138
+ Messages.ok("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
139
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"From:".bold.green} #{repo.old_url}")
140
+ puts " #{" " * 3} | #{" " * 2} | #{" " * max_col} | #{" " * 3} | #{"To:".bold.green} #{repo.url}"
125
141
  end
126
142
 
127
143
  def self.untouched(num, repo, max_col)
128
- Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, ' ')} | #{repo.enabled? ? ' Y ' : ' N '.yellow} | #{'Untouched:'.bold.yellow} #{repo.old_url}")
144
+ Messages.warning("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
145
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Untouched:".bold.yellow} #{repo.old_url}")
146
+ end
147
+
148
+ def self.server_error(num, repo, max_col)
149
+ Messages.error("| #{num.to_s.rjust(2)} | #{repo.name.ljust(max_col, " ")} " \
150
+ "| #{repo.enabled? ? " Y " : " N ".yellow} | #{"Error:".bold.red} #{repo.status}")
129
151
  end
130
152
 
131
- def self.separator
132
- puts '-' * 90
153
+ def self.separator(max_col)
154
+ puts "-" * (max_col + 20)
133
155
  end
134
156
 
135
- def self.header(max_col, upgrade = false)
136
- puts " St. | # | #{'Name'.ljust(max_col, ' ')} | En. | #{upgrade ? 'Details' : 'Hint' }"
157
+ def self.header(max_col, upgrade: false)
158
+ puts " St. | # | #{"Name".ljust(max_col, " ")} | En. | #{upgrade ? "Details" : "Hint"}"
137
159
  end
138
160
 
139
- def self.footer
140
- self.separator
161
+ def self.footer(max_col)
162
+ separator max_col
141
163
  end
142
164
 
143
165
  def self.status(os_release)
@@ -146,123 +168,121 @@ module Zypper
146
168
  puts "---------------------------------------------------"
147
169
  puts " Current | Next | Last | Available"
148
170
  puts "--------------------------------------------------"
149
- puts " #{os_release.current} | #{os_release.seniority > 0 ? os_release.next.bold.green : ' - ' } | #{os_release.last.send(os_release.unstable ? :red : :clean)} | #{os_release.seniority > 0 ? os_release.newer.join(', ') : '-'}"
171
+ puts " #{os_release.current} " \
172
+ "| #{os_release.seniority.positive? ? os_release.next.bold.green : " - "} " \
173
+ "| #{os_release.last.send(os_release.unstable ? :red : :clean)} " \
174
+ "| #{os_release.seniority.positive? ? os_release.newer.join(", ") : "-"}"
150
175
  puts "--------------------------------------------------"
151
- Messages.warning "The #{'last'.bold.red} version should be considered #{'Unstable'.bold.red}" if os_release.unstable
176
+ return unless os_release.unstable
177
+
178
+ Messages.warning "The #{"last".bold.red} version should be considered #{"Unstable".bold.red}"
152
179
  end
153
180
  end
154
181
 
155
-
182
+ #
183
+ # Quiet style output.
184
+ #
156
185
  class Quiet
186
+ def self.available(num, repo, max_col); end
157
187
 
158
- def self.available(num, repo, max_col)
159
- end
188
+ def self.redirected(num, repo, max_col, redirected); end
160
189
 
161
- def self.redirected(num, repo, max_col, redirected)
162
- end
190
+ def self.not_found(num, repo, max_col); end
163
191
 
164
- def self.not_found(num, repo, max_col)
165
- end
192
+ def self.forbidden(num, repo, max_col); end
166
193
 
167
- def self.forbidden(num, repo, max_col)
168
- end
194
+ def self.alternative(num, repo, max_col, alt); end
169
195
 
170
- def self.alternative(num, repo, max_col, alt)
171
- end
196
+ def self.timeout(num, repo, max_col); end
172
197
 
173
- def self.timeout(num, repo, max_col)
174
- end
198
+ def self.upgraded(num, repo, max_col); end
175
199
 
176
- def self.upgraded(num, repo, max_col) #, old_data)
177
- end
200
+ def self.untouched(num, repo, max_col); end
178
201
 
179
- def self.untouched(num, repo, max_col)
180
- end
202
+ def self.server_error(num, repo, max_col); end
181
203
 
182
- def self.separator
183
- end
204
+ def self.separator(_max_col); end
184
205
 
185
- def self.header(max_col, upgrade = false)
186
- end
206
+ def self.header(max_col, upgrade: false); end
187
207
 
188
- def self.footer
189
- end
208
+ def self.footer(_max_col); end
190
209
 
191
210
  def self.status(os_release)
192
- puts os_release.seniority.to_s + ' ' + os_release.newer.join(' ')
211
+ puts "#{os_release.seniority} #{os_release.newer.join(" ")}"
193
212
  end
194
-
195
213
  end
196
214
 
197
-
215
+ #
216
+ # Ini style output.
217
+ #
198
218
  class Ini
199
-
200
- def self.available(num, repo, max_col)
201
- self.info num, 'Ok', repo
219
+ def self.available(num, repo, _max_col)
220
+ info num, "Ok", repo
202
221
  end
203
222
 
204
- def self.redirected(num, repo, max_col, redirected)
205
- self.info num, 'Redirected', repo, false
223
+ def self.redirected(num, repo, _max_col, redirected)
224
+ info num, "Redirected", repo, false
206
225
  puts "redirected_to=#{redirected}"
207
226
  end
208
227
 
209
- def self.not_found(num, repo, max_col)
210
- self.info num, 'Not Found', repo, false
228
+ def self.not_found(num, repo, _max_col)
229
+ info num, "Not Found", repo, valid: false
211
230
  end
212
231
 
213
- def self.forbidden(num, repo, max_col)
214
- self.info num, 'Forbidden Path', repo, false
232
+ def self.forbidden(num, repo, _max_col)
233
+ info num, "Forbidden Path", repo, valid: false
215
234
  end
216
235
 
217
- def self.alternative(num, repo, max_col, alt)
218
- self.info num, 'Not Found', repo, false, alt[:url]
236
+ def self.alternative(num, repo, _max_col, alt)
237
+ info num, "Not Found", repo, valid: false, suggested: alt[:url]
219
238
  puts "hint=#{alt[:message]}"
220
239
  puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
221
240
  end
222
241
 
223
- def self.timeout(num, repo, max_col)
224
- self.info num, 'Server Timeout', repo, false
242
+ def self.timeout(num, repo, _max_col)
243
+ info num, "Server Timeout", repo, valid: false
225
244
  end
226
245
 
227
- def self.upgraded(num, repo, max_col)
228
- self.info num, 'Upgraded', repo
246
+ def self.upgraded(num, repo, _max_col)
247
+ info num, "Upgraded", repo
229
248
  end
230
249
 
231
- def self.untouched(num, repo, max_col)
232
- self.info num, 'Untouched', repo
250
+ def self.untouched(num, repo, _max_col)
251
+ info num, "Untouched", repo
233
252
  end
234
253
 
235
- def self.separator
236
- puts ''
254
+ def self.server_error(num, repo, _max_col)
255
+ info num, "Server Error", repo
256
+ puts "error=#{repo.status}"
237
257
  end
238
258
 
239
- def self.header(max_col, upgrade = false)
259
+ def self.separator(_max_col)
260
+ puts ""
240
261
  end
241
262
 
242
- def self.footer
243
- end
263
+ def self.header(max_col, upgrade: false); end
264
+
265
+ def self.footer(_max_col); end
244
266
 
245
267
  def self.status(os_release)
246
- puts '[os_release]'
268
+ puts "[os_release]"
247
269
  puts "name=#{os_release.fullname}"
248
270
  puts "current=#{os_release.current}"
249
271
  puts "next=#{os_release.next}"
250
272
  puts "last=#{os_release.last}"
251
- puts "available=#{os_release.newer.join(' ')}"
273
+ puts "available=#{os_release.newer.join(" ")}"
252
274
  puts "allow_unstable=#{os_release.unstable}"
253
275
  end
254
276
 
255
- private
256
-
257
- def self.info(num, status, repo, valid = true, suggested = '')
277
+ def self.info(num, status, repo, valid: true, suggested: "")
258
278
  @@number = num
259
279
  puts "[repository_#{num}]"
260
280
  puts "name=#{repo.name}"
261
281
  puts "alias=#{repo.alias}"
262
- puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
282
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || !suggested.empty?
263
283
  if valid
264
284
  if repo.unversioned? && repo.old_url
265
- puts <<-'HEADER'.gsub(/^ +/, '')
285
+ puts <<-HEADER.gsub(/^ +/, "")
266
286
  # The repository is unversioned: its packages should be perfectly
267
287
  # working regardless the distribution version, that because all the
268
288
  # required dependencies are included in the repository itself and
@@ -271,7 +291,7 @@ module Zypper
271
291
  end
272
292
  puts "url=#{repo.url}"
273
293
  elsif repo.enabled?
274
- puts <<-'HEADER'.gsub(/^ +/, '')
294
+ puts <<-HEADER.gsub(/^ +/, "")
275
295
  # The interpolated URL is invalid, try overriding with the one suggested
276
296
  # in the field below or find it manually starting from the old_url.
277
297
  # The alternatives are:
@@ -282,7 +302,7 @@ module Zypper
282
302
  url=
283
303
  HEADER
284
304
  else
285
- puts <<-'HEADER'.gsub(/^ +/, '')
305
+ puts <<-HEADER.gsub(/^ +/, "")
286
306
  # The interpolated URL is invalid, but being the repository disabled you can
287
307
  # keep the old_url in the field below, it will be ignored anyway during the
288
308
  # normal update and upgrade process.
@@ -290,32 +310,30 @@ module Zypper
290
310
  puts "url=#{repo.old_url}"
291
311
  end
292
312
  puts "priority=#{repo.priority}"
293
- puts "enabled=#{repo.enabled? ? 'Yes' : 'No'}"
313
+ puts "enabled=#{repo.enabled? ? "Yes" : "No"}"
294
314
  puts "status=#{status}"
295
315
  end
296
316
  end
297
317
 
298
-
318
+ #
319
+ # Ini style output with inferred solution.
320
+ #
299
321
  class Solved < Ini
300
-
301
- def self.alternative(num, repo, max_col, alt)
302
- self.info num, 'Not Found', repo, false, alt[:url]
322
+ def self.alternative(num, repo, _max_col, alt)
323
+ info num, "Not Found", repo, valid: false, suggested: alt[:url]
303
324
  puts "hint=#{alt[:message]}"
304
325
  puts "suggested_url=#{alt[:url]}" unless alt[:url].to_s.empty?
305
326
  end
306
327
 
307
-
308
- private
309
-
310
- def self.info(num, status, repo, valid = true, suggested = '')
328
+ def self.info(num, status, repo, valid: true, suggested: "")
311
329
  @@number = num
312
330
  puts "[repository_#{num}]"
313
331
  puts "name=#{repo.name}"
314
332
  puts "alias=#{repo.alias}"
315
- puts "old_url=#{repo.old_url}" if repo.upgraded? || (!suggested.empty?)
333
+ puts "old_url=#{repo.old_url}" if repo.upgraded? || !suggested.empty?
316
334
  if valid
317
335
  if repo.unversioned? && repo.old_url
318
- puts <<-'HEADER'.gsub(/^ +/, '')
336
+ puts <<-HEADER.gsub(/^ +/, "")
319
337
  # The repository is unversioned: its packages should be perfectly
320
338
  # working regardless the distribution version, that because all the
321
339
  # required dependencies are included in the repository itself and
@@ -324,19 +342,8 @@ module Zypper
324
342
  end
325
343
  puts "url=#{repo.url}"
326
344
  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(/^ +/, '')
345
+ if suggested.empty?
346
+ puts <<-HEADER.gsub(/^ +/, "")
340
347
  # The interpolated URL is invalid, and the script has not been able to find
341
348
  # an alternative. The best thing to do here is to disable the repository.
342
349
  # In case a valid alternative will be discovered, just replace its URL in
@@ -345,13 +352,24 @@ module Zypper
345
352
  #
346
353
  HEADER
347
354
  puts "url=#{repo.old_url}"
348
- puts 'enabled=No'
355
+ puts "enabled=No"
356
+ else
357
+ puts <<-HEADER.gsub(/^ +/, "")
358
+ # The interpolated URL is invalid, but the script found an alternative
359
+ # URL which will be used to override the old value.
360
+ # Unfortunately the script is not able to know if the found URL is exact,
361
+ # so review the result before accepting any change, and in case want
362
+ # to disable it, just turn the "enabled" field below to "No".
363
+ #
364
+ HEADER
365
+ puts "url=#{suggested}"
366
+ puts "enabled=Yes"
349
367
  end
350
368
  else
351
- puts <<-'HEADER'.gsub(/^ +/, '')
369
+ puts <<-HEADER.gsub(/^ +/, "")
352
370
  # The interpolated URL is invalid, but being the repository disabled you can
353
371
  # 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.
372
+ # system update and the upgrade process until the repository is enabled again.
355
373
  HEADER
356
374
  puts "url=#{suggested.empty? ? repo.old_url : suggested}"
357
375
  end
@@ -359,7 +377,6 @@ module Zypper
359
377
  puts "status=#{status}"
360
378
  end
361
379
  end
362
-
363
380
  end
364
381
  end
365
382
  end