zypper-upgraderepo 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c70f8e680b1c6c86d0c556a6761cb0738dc3b39422109a679ccaeee34d1a0d26
4
- data.tar.gz: edc57ec51daa46b5443f4cf928af1884b5cbdbd5779b687eec38dd98d021f9ef
3
+ metadata.gz: 3f063f691c5f780a94c2016e4be62f636c4e70e6f21377993b3a2b6c57d7ca59
4
+ data.tar.gz: 68b13bc527f0f87456a4613c2ed7c3ab23214991a6a8eea09c0d94b8da7c7c73
5
5
  SHA512:
6
- metadata.gz: 15495fdd8f2619194293bc2ab113043c343c11f5aada78d8db338937f65365b9b475f4f7725dbcfe4f207df452705e80b8a8dd991338003982784db7154a4251
7
- data.tar.gz: 6de4b17c55d6693f7c020eeb7226524e738be9ef1ca1e1e166cb0cfd14ecef53eef32952c371e75cd5d20c15fa1de88894b6dc63d12a1c1871f7f481489122be
6
+ metadata.gz: 78c01cb2796e0ada9252bccbbcf027b2e9f81e09d593f6b2f682c86d717e348c02ee58ba2008696edccc441288bb8ad569dc90d42d362c5acd94945d8580f82e
7
+ data.tar.gz: b406a9567d05634b2c4f906e5fb925b6d9ae78275f9f4fd42c920b1ea2bac696d14db2ac081b2f40ed7bd331eeb87e38a6ceec8563c0a2a6103985d8dd79d662
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zypper-upgraderepo (1.7.0)
4
+ zypper-upgraderepo (1.7.1)
5
5
  iniparse
6
6
  minitar
7
7
 
@@ -65,12 +65,10 @@ module Zypper
65
65
  def resolve_variables!(version)
66
66
  each_with_number do |r|
67
67
  if r.url =~ /\$/
68
- r.url = r.url.gsub(/\$releasever_major/, version.split('.')[0])
69
- .gsub(/\$releasever_minor/, version.split('.')[1])
70
- .gsub(/\$releasever/, version)
71
- .gsub(/\$basearch/, @arch)
72
- .gsub(/\$arch/, @cpu_arch)
68
+ r.url = expand_variables(r.url, version)
73
69
  end
70
+ r.name = expand_variables(r.name, version)
71
+ r.alias = expand_variables(r.alias, version)
74
72
  end
75
73
 
76
74
  self
@@ -85,6 +83,14 @@ module Zypper
85
83
 
86
84
  private
87
85
 
86
+ def expand_variables(str, version)
87
+ str.gsub(/\$releasever_major/, version.split('.')[0])
88
+ .gsub(/\$releasever_minor/, version.split('.')[1])
89
+ .gsub(/\$releasever/, version)
90
+ .gsub(/\$basearch/, @arch)
91
+ .gsub(/\$arch/, @cpu_arch)
92
+ end
93
+
88
94
  def load_overrides(filename)
89
95
  raise FileNotFound, filename unless File.exist?(filename)
90
96
  ini = IniParse.parse(File.read(filename))
@@ -6,7 +6,6 @@ require_relative 'requests/http.rb'
6
6
  module Zypper
7
7
  module Upgraderepo
8
8
 
9
-
10
9
  class Request
11
10
 
12
11
  def self.build(repo, timeout)
@@ -14,7 +13,7 @@ module Zypper
14
13
 
15
14
  raise InvalidProtocol, repo unless @@registry.include? repo.protocol
16
15
 
17
- Object.const_get(@@registry[repo.protocol]).new(repo, timeout)
16
+ Object.const_get(self.find_class(repo)).new(repo, timeout)
18
17
  end
19
18
 
20
19
  def self.protocols
@@ -26,17 +25,26 @@ module Zypper
26
25
  def self.load_requests
27
26
  res = {}
28
27
  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}"
28
+ obj = Object.const_get("Zypper::Upgraderepo::Requests::#{klass}")
29
+ obj.register_protocol.each do |protocol|
30
+ res[protocol] ||= {}
31
+ res[protocol][obj.domain] = "Zypper::Upgraderepo::Requests::#{klass}"
31
32
  end
32
33
  end
33
34
 
34
35
  res
35
36
  end
36
37
 
37
- end
38
-
38
+ def self.find_class(repo)
39
+ domain = URI(repo.url).hostname
39
40
 
41
+ if @@registry[repo.protocol].has_key? domain
42
+ return @@registry[repo.protocol][domain]
43
+ else
44
+ return @@registry[repo.protocol]['default']
45
+ end
46
+ end
47
+ end
40
48
 
41
49
  end
42
50
  end
@@ -93,6 +93,8 @@ module Zypper
93
93
 
94
94
  def self.register_protocol; ['https', 'http'] end
95
95
 
96
+ def self.domain; 'default' end
97
+
96
98
  def evaluate_alternative(version)
97
99
  if not_found?
98
100
  return traverse_url(URI(url), version)
@@ -114,14 +116,25 @@ module Zypper
114
116
  available?
115
117
  end
116
118
 
117
- def subfolders
118
- res = ping.body.to_s.scan(Regexp.new('href=[\'\"][^\/\"]+\/[\'\"]')).delete_if do |x|
119
+ def subfolders(uri)
120
+ ping.body.to_s.scan(Regexp.new('href=[\'\"][^\/\"]+\/[\'\"]')).delete_if do |x|
119
121
  x =~ /^\// || x =~ /^\.\./ || x =~ /\:\/\// || x =~ /href=[\"\'](media\.1|boot|EFI)\/[\"\']/
120
122
  end.uniq.map do |d|
121
123
  d.scan(/href=[\"\']([^"]+)[\'\"]/).pop.pop
122
124
  end
125
+ end
126
+ end
127
+
128
+ class DownloadOpensuseOrgRequest < HttpRequest
129
+
130
+ def self.domain; 'download.opensuse.org' end
123
131
 
124
- res
132
+ def subfolders(uri)
133
+ u = URI(uri.to_s)
134
+ u.path = "/download#{u.path}"
135
+ u.query = 'jsontable'
136
+ require 'json'
137
+ JSON.parse(ping(u, false).body.to_s)["data"].map { |x| x["name"] }
125
138
  end
126
139
  end
127
140
 
@@ -68,6 +68,8 @@ module Zypper
68
68
 
69
69
  def self.register_protocol; ['dir'] end
70
70
 
71
+ def self.domain; 'default' end
72
+
71
73
  def evaluate_alternative(version)
72
74
  if not_found?
73
75
  return traverse_url(URI(url), version)
@@ -49,7 +49,7 @@ module Zypper
49
49
  uri.path += '/' if uri.path[-1] != '/'
50
50
  ping(uri, false)
51
51
 
52
- subfolders.each do |dir|
52
+ subfolders(uri).each do |dir|
53
53
  u = URI(uri.to_s)
54
54
  u.path += dir
55
55
 
@@ -1,5 +1,5 @@
1
1
  module Zypper
2
2
  module Upgraderepo
3
- VERSION = "1.7.0"
3
+ VERSION = "1.7.1"
4
4
  end
5
5
  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.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Mucciante
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,7 +116,7 @@ licenses:
116
116
  metadata:
117
117
  bug_tracker_uri: https://github.com/fabiomux/zypper-upgraderepo/issues
118
118
  changelog_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html#changelog
119
- documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.7.0
119
+ documentation_uri: https://www.rubydoc.info/gems/zypper-upgraderepo/1.7.1
120
120
  homepage_uri: https://freeaptitude.altervista.org/projects/zypper-upgraderepo.html
121
121
  source_code_uri: https://github.com/fabiomux/zypper-upgraderepo
122
122
  wiki_uri: https://github.com/fabiomux/zypper-upgraderepo/wiki