polisher 0.9.1 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gem_dependency_checker.rb +55 -25
- data/bin/git_gem_updater.rb +18 -7
- data/lib/polisher/bodhi.rb +11 -10
- data/lib/polisher/component.rb +43 -0
- data/lib/polisher/config.rb +32 -0
- data/lib/polisher/core.rb +59 -34
- data/lib/polisher/errata.rb +56 -56
- data/lib/polisher/fedora.rb +33 -33
- data/lib/polisher/gem.rb +316 -281
- data/lib/polisher/gem_state.rb +86 -0
- data/lib/polisher/gemfile.rb +85 -87
- data/lib/polisher/git/pkg.rb +232 -175
- data/lib/polisher/git/repo.rb +74 -61
- data/lib/polisher/koji.rb +136 -83
- data/lib/polisher/logger.rb +23 -0
- data/lib/polisher/rhn.rb +6 -5
- data/lib/polisher/rpm/requirement.rb +186 -177
- data/lib/polisher/rpm/spec.rb +420 -356
- data/lib/polisher/tag_mapper.rb +27 -0
- data/lib/polisher/version.rb +1 -1
- data/lib/polisher/version_checker.rb +86 -17
- data/lib/polisher/yum.rb +26 -19
- data/spec/component_spec.rb +53 -0
- data/spec/core_spec.rb +6 -0
- data/spec/gem_spec.rb +230 -47
- data/spec/git_spec.rb +63 -27
- data/spec/koji_spec.rb +60 -3
- data/spec/rpm/spec_spec.rb +7 -3
- data/spec/spec_helper.rb +2 -1
- data/spec/version_checker_spec.rb +97 -0
- data/spec/yum_spec.rb +5 -0
- metadata +34 -28
- data/lib/polisher/missing.rb +0 -12
data/lib/polisher/git/repo.rb
CHANGED
@@ -3,72 +3,85 @@
|
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'awesome_spawn'
|
7
6
|
require 'polisher/core'
|
8
7
|
require 'polisher/git_cache'
|
8
|
+
require 'polisher/component'
|
9
9
|
|
10
10
|
module Polisher
|
11
11
|
module Git
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
12
|
+
Component.verify("Git::Repo", 'awesome_spawn') do
|
13
|
+
# Git Repository
|
14
|
+
class Repo
|
15
|
+
include ConfHelpers
|
16
|
+
|
17
|
+
# TODO use ruby git api
|
18
|
+
conf_attr :git_cmd, '/usr/bin/git'
|
19
|
+
|
20
|
+
attr_accessor :url
|
21
|
+
attr_accessor :path
|
22
|
+
|
23
|
+
def initialize(args={})
|
24
|
+
@url = args[:url]
|
25
|
+
@path = args[:path]
|
26
|
+
end
|
27
|
+
|
28
|
+
def path
|
29
|
+
@path || GitCache.path_for(@url)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Clobber the git repo
|
33
|
+
def clobber!
|
34
|
+
FileUtils.rm_rf path
|
35
|
+
end
|
36
|
+
|
37
|
+
def clone
|
38
|
+
require_cmd! git_cmd
|
39
|
+
AwesomeSpawn.run! "#{git_cmd} clone #{url} #{path}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def cloned?
|
43
|
+
File.directory?(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def in_repo
|
47
|
+
Dir.chdir path do
|
48
|
+
yield
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def file_paths
|
53
|
+
in_repo { Dir['**/*'] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def include?(file)
|
57
|
+
file_paths.include?(file)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Note be careful when invoking:
|
61
|
+
def reset!
|
62
|
+
require_cmd! git_cmd
|
63
|
+
in_repo { AwesomeSpawn.run! "#{git_cmd} reset HEAD~ --hard" }
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
def pull
|
68
|
+
require_cmd! git_cmd
|
69
|
+
in_repo { AwesomeSpawn.run! "#{git_cmd} pull" }
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
def checkout(tgt)
|
74
|
+
require_cmd! git_cmd
|
75
|
+
in_repo { AwesomeSpawn.run! "#{git_cmd} checkout #{tgt}" }
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
79
|
+
def commit(msg)
|
80
|
+
require_cmd! git_cmd
|
81
|
+
in_repo { AwesomeSpawn.run! "#{git_cmd} commit -m '#{msg}'" }
|
82
|
+
self
|
45
83
|
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def file_paths
|
49
|
-
in_repo { Dir['**/*'] }
|
50
|
-
end
|
51
|
-
|
52
|
-
# Note be careful when invoking:
|
53
|
-
def reset!
|
54
|
-
in_repo { AwesomeSpawn.run "#{git_cmd} reset HEAD~ --hard" }
|
55
|
-
self
|
56
|
-
end
|
57
|
-
|
58
|
-
def pull
|
59
|
-
in_repo { AwesomeSpawn.run "#{git_cmd} pull" }
|
60
|
-
self
|
61
|
-
end
|
62
|
-
|
63
|
-
def checkout(tgt)
|
64
|
-
in_repo { AwesomeSpawn.run "#{git_cmd} checkout #{tgt}" }
|
65
|
-
self
|
66
|
-
end
|
67
|
-
|
68
|
-
def commit(msg)
|
69
|
-
in_repo { AwesomeSpawn.run "#{git_cmd} commit -m '#{msg}'" }
|
70
|
-
self
|
71
|
-
end
|
72
|
-
end # class Repo
|
84
|
+
end # class Repo
|
85
|
+
end # Component.verify("Git::Repo")
|
73
86
|
end # module Git
|
74
87
|
end # module Polisher
|
data/lib/polisher/koji.rb
CHANGED
@@ -3,104 +3,157 @@
|
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'xmlrpc/client'
|
7
|
-
require 'active_support/core_ext/kernel/reporting'
|
8
|
-
silence_warnings do
|
9
|
-
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
10
|
-
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
11
|
-
end
|
12
|
-
|
13
6
|
require 'polisher/core'
|
7
|
+
require 'polisher/component'
|
14
8
|
|
15
9
|
module Polisher
|
16
|
-
|
17
|
-
|
10
|
+
deps = ['awesome_spawn', 'xmlrpc/client', 'active_support',
|
11
|
+
'active_support/core_ext/kernel/reporting']
|
12
|
+
Component.verify("Koji", *deps) do
|
13
|
+
silence_warnings do
|
14
|
+
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
15
|
+
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
16
|
+
end
|
18
17
|
|
19
|
-
|
18
|
+
class Koji
|
19
|
+
include ConfHelpers
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
conf_attr :koji_url, 'koji.fedoraproject.org/kojihub'
|
22
|
+
conf_attr :koji_tag, 'f21'
|
23
|
+
conf_attr :package_prefix, 'rubygem-'
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
# XXX don't like having to shell out to koji but quickest
|
26
|
+
# way to get an authenticated session so as to launch builds
|
27
|
+
conf_attr :build_cmd, '/usr/bin/koji'
|
28
|
+
conf_attr :build_tgt, 'rawhide'
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
@client ||= begin
|
32
|
-
url = koji_url.split('/')
|
33
|
-
XMLRPC::Client.new(url[0..-2].join('/'),
|
34
|
-
"/#{url.last}")
|
30
|
+
def self.koji_tags
|
31
|
+
[koji_tag].flatten
|
35
32
|
end
|
36
|
-
end
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
versions = self.versions_for name
|
42
|
-
versions.include?(version)
|
43
|
-
end
|
34
|
+
def self.package_prefixes
|
35
|
+
[package_prefix].flatten
|
36
|
+
end
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
# Retrieve shared instance of xmlrpc client to use
|
39
|
+
def self.client
|
40
|
+
@client ||= begin
|
41
|
+
url = koji_url.split('/')
|
42
|
+
XMLRPC::Client.new(url[0..-2].join('/'),
|
43
|
+
"/#{url.last}")
|
44
|
+
end
|
45
|
+
end
|
53
46
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
# tagid userid pkgid prefix inherit with_dups
|
61
|
-
pkgs = client.call('listPackages', nil, nil, "rubygem-#{name}", nil, false, true)
|
62
|
-
pkgs.collect { |pkg| pkg['tag_name'] }
|
63
|
-
end
|
47
|
+
# Return bool indiciating if koji has a build exactly
|
48
|
+
# matching the specified version
|
49
|
+
def self.has_build?(name, version)
|
50
|
+
versions = versions_for name
|
51
|
+
versions.include?(version)
|
52
|
+
end
|
64
53
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
# koji xmlrpc call
|
72
|
-
builds =
|
73
|
-
koji_tags.collect do |tag|
|
74
|
-
client.call('listTagged', tag, nil, false, nil, false,
|
75
|
-
"#{package_prefix}#{name}")
|
76
|
-
end.flatten
|
77
|
-
versions = builds.collect { |b| b['version'] }
|
78
|
-
bl.call(:koji, name, versions) unless(bl.nil?)
|
79
|
-
versions
|
80
|
-
end
|
54
|
+
# Return bool indicating if koji has a build which
|
55
|
+
# satisfies the specified ruby dependency
|
56
|
+
def self.has_build_satisfying?(name, version)
|
57
|
+
dep = ::Gem::Dependency.new name, version
|
58
|
+
versions_for(name).any? { |v| dep.match?(name, v) }
|
59
|
+
end
|
81
60
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
version2 = build2 && build2['version']
|
92
|
-
builds[name] = {tag1 => version1, tag2 => version2}
|
61
|
+
# Return list of tags for which a package exists
|
62
|
+
#
|
63
|
+
# @param [String] name of package to lookup
|
64
|
+
# @return [Hash<String,String>] hash of tag names to package versions for tags
|
65
|
+
# which package was found in
|
66
|
+
def self.tagged_in(name)
|
67
|
+
# tagid userid pkgid prefix inherit with_dups
|
68
|
+
pkgs = client.call('listPackages', nil, nil, "rubygem-#{name}", nil, false, true)
|
69
|
+
pkgs.collect { |pkg| pkg['tag_name'] }
|
93
70
|
end
|
94
71
|
|
95
|
-
|
96
|
-
|
97
|
-
|
72
|
+
# Retrieve list of the versions of the specified package in koji
|
73
|
+
#
|
74
|
+
# @param [String] name name of package to lookup
|
75
|
+
# @param [Callable] bl optional block to invoke with versions retrieved
|
76
|
+
# @return [Array<String>] versions retrieved, empty array if none found
|
77
|
+
def self.versions_for(name, &bl)
|
78
|
+
# koji xmlrpc call
|
79
|
+
versions = tagged_versions_for(name).values.flatten.uniq
|
80
|
+
bl.call(:koji, name, versions) unless bl.nil?
|
81
|
+
versions
|
82
|
+
end
|
98
83
|
|
99
|
-
|
100
|
-
|
84
|
+
def self.tagged_versions_for(name)
|
85
|
+
versions = {}
|
86
|
+
koji_tags.each do |tag|
|
87
|
+
versions[tag] = versions_for_tag(name, tag).flatten.uniq
|
88
|
+
end
|
89
|
+
versions
|
101
90
|
end
|
102
91
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
92
|
+
def self.tagged_version_for(name)
|
93
|
+
versions = {}
|
94
|
+
tagged_versions_for(name).each do |tag, tagged_versions|
|
95
|
+
versions[tag] = tagged_versions.first
|
96
|
+
end
|
97
|
+
versions
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.versions_for_tag(name, tag)
|
101
|
+
metadata =
|
102
|
+
package_prefixes.collect do |prefix|
|
103
|
+
# tag event inherit prefix latest
|
104
|
+
client.call('listTagged', tag, nil, true, nil, false,
|
105
|
+
"#{prefix}#{name}")
|
106
|
+
end
|
107
|
+
|
108
|
+
metadata.flatten.collect { |b| b['version'] }.uniq
|
109
|
+
end
|
110
|
+
|
111
|
+
# Run a build against the specified target using the specified rpm
|
112
|
+
def self.build(args = {})
|
113
|
+
require_cmd! build_cmd
|
114
|
+
|
115
|
+
target = args[:target] || build_tgt
|
116
|
+
srpm = args[:srpm]
|
117
|
+
scratch = args[:scratch] ? '--scratch' : ''
|
118
|
+
|
119
|
+
cmd = "#{build_cmd} build #{scratch} #{target} #{srpm}"
|
120
|
+
result = AwesomeSpawn.run(cmd)
|
121
|
+
url = parse_url(result.output)
|
122
|
+
raise url if result.exit_status != 0
|
123
|
+
url
|
124
|
+
end
|
125
|
+
|
126
|
+
# Parse a koji build url from output
|
127
|
+
def self.parse_url(output)
|
128
|
+
task_info = output.lines.detect { |l| l =~ /Task info:.*/ }
|
129
|
+
task_info ? task_info.split.last : ''
|
130
|
+
end
|
131
|
+
|
132
|
+
# def self.build_logs(url) # TODO
|
133
|
+
|
134
|
+
# Return diff between list of packages in two tags in koji
|
135
|
+
def self.diff(tag1, tag2)
|
136
|
+
builds1 = client.call('listTagged', tag1, nil, false, nil, false)
|
137
|
+
builds2 = client.call('listTagged', tag2, nil, false, nil, false)
|
138
|
+
builds = {}
|
139
|
+
builds1.each do |build|
|
140
|
+
name = build['package_name']
|
141
|
+
build2 = builds2.detect { |b| b['name'] == name }
|
142
|
+
version1 = build['version']
|
143
|
+
version2 = build2 && build2['version']
|
144
|
+
builds[name] = {tag1 => version1, tag2 => version2}
|
145
|
+
end
|
146
|
+
|
147
|
+
builds2.each do |build|
|
148
|
+
name = build['package_name']
|
149
|
+
next if builds.key?(name)
|
150
|
+
|
151
|
+
version = build['version']
|
152
|
+
builds[name] = {tag1 => nil, tag2 => version}
|
153
|
+
end
|
154
|
+
|
155
|
+
builds
|
156
|
+
end
|
157
|
+
end # class Koji
|
158
|
+
end # Component.verify("Koji")
|
159
|
+
end # module Polisher
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Polisher Logging Module
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
module Polisher
|
7
|
+
module Logging
|
8
|
+
# This is the magical bit that gets mixed into your classes
|
9
|
+
def logger
|
10
|
+
Logging.logger
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set the log level
|
14
|
+
def self.level=(level)
|
15
|
+
logger.level = Logger.const_get(level.to_s.upcase)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Global, memoized, lazy initialized instance of a logger
|
19
|
+
def self.logger
|
20
|
+
@logger ||= Logger.new(STDOUT)
|
21
|
+
end
|
22
|
+
end # module Logging
|
23
|
+
end # module Polisher
|
data/lib/polisher/rhn.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
-
|
6
|
-
require 'pkgwat'
|
5
|
+
require 'polisher/component'
|
7
6
|
|
8
7
|
module Polisher
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
Component.verify("RHN", "pkgwat") do
|
9
|
+
class RHN
|
10
|
+
def self.version_for(name)
|
11
|
+
# TODO
|
12
|
+
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -3,186 +3,195 @@
|
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'gem2rpm'
|
7
|
-
require 'versionomy'
|
8
|
-
require 'active_support/core_ext'
|
9
|
-
|
10
|
-
require 'polisher/core'
|
11
6
|
require 'polisher/gem'
|
7
|
+
require 'polisher/core'
|
8
|
+
require 'polisher/component'
|
12
9
|
|
13
10
|
module Polisher
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
condition
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
11
|
+
deps = ['gem2rpm', 'versionomy', 'active_support/core_ext']
|
12
|
+
Component.verify("RPM::Requirement", *deps) do
|
13
|
+
module RPM
|
14
|
+
class Requirement
|
15
|
+
include ConfHelpers
|
16
|
+
|
17
|
+
conf_attr :rubygem_prefix, 'rubygem'
|
18
|
+
conf_attr :scl_prefix, '' # set to %{?scl_prefix} to enable scl's
|
19
|
+
|
20
|
+
def self.prefix
|
21
|
+
"#{scl_prefix}#{rubygem_prefix}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Bool indiciating if req is a BR
|
25
|
+
attr_accessor :br
|
26
|
+
|
27
|
+
# Name of requirement
|
28
|
+
attr_accessor :name
|
29
|
+
|
30
|
+
# Condition, eg >=, =, etc
|
31
|
+
attr_accessor :condition
|
32
|
+
|
33
|
+
# Version number
|
34
|
+
attr_accessor :version
|
35
|
+
|
36
|
+
# Requirement string
|
37
|
+
def str
|
38
|
+
sp = self.specifier
|
39
|
+
sp.nil? ? "#{@name}" : "#{@name} #{sp}"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Specified string
|
43
|
+
def specifier
|
44
|
+
@version.nil? ? nil : "#{@condition} #{@version}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# Instantiate / return new rpm spec requirements from string
|
48
|
+
def self.parse(str, opts={})
|
49
|
+
stra = str.split
|
50
|
+
br = str.include?('BuildRequires')
|
51
|
+
name = condition = version = nil
|
52
|
+
|
53
|
+
if str.include?('Requires')
|
54
|
+
name = stra[1]
|
55
|
+
condition = stra[2]
|
56
|
+
version = stra[3]
|
57
|
+
|
58
|
+
else
|
59
|
+
name = stra[0]
|
60
|
+
condition = stra[1]
|
61
|
+
version = stra[2]
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
req = self.new({:name => name,
|
66
|
+
:condition => condition,
|
67
|
+
:version => version,
|
68
|
+
:br => br}.merge(opts))
|
69
|
+
req
|
70
|
+
end
|
71
|
+
|
72
|
+
# Instantiate / return new rpm spec requirements from gem dependency.
|
73
|
+
#
|
74
|
+
# Because a gem dependency may result in multiple spec requirements
|
75
|
+
# this will always return an array of Requirement instances
|
76
|
+
def self.from_gem_dep(gem_dep, br=false)
|
77
|
+
gem_dep.requirement.to_s.split(',').collect { |req|
|
78
|
+
expanded = Gem2Rpm::Helpers.expand_requirement [req.split]
|
79
|
+
expanded.collect { |e|
|
80
|
+
new :name => "#{prefix}(#{gem_dep.name})",
|
81
|
+
:condition => e.first.to_s,
|
82
|
+
:version => e.last.to_s,
|
83
|
+
:br => br
|
84
|
+
}
|
85
|
+
}.flatten
|
86
|
+
end
|
54
87
|
|
88
|
+
def initialize(args={})
|
89
|
+
@br = args[:br] || false
|
90
|
+
@name = args[:name]
|
91
|
+
@condition = args[:condition]
|
92
|
+
@version = args[:version]
|
93
|
+
|
94
|
+
@name.strip! unless @name.nil?
|
95
|
+
@condition.strip! unless @condition.nil?
|
96
|
+
@version.strip! unless @version.nil?
|
97
|
+
end
|
98
|
+
|
99
|
+
def ==(other)
|
100
|
+
@br == other.br &&
|
101
|
+
@name == other.name &&
|
102
|
+
@condition == other.condition &&
|
103
|
+
@version == other.version
|
104
|
+
end
|
105
|
+
|
106
|
+
# Greatest Common Denominator,
|
107
|
+
# Max version in list that is less than the local version
|
108
|
+
def gcd(versions)
|
109
|
+
lversion = Versionomy.parse(self.version)
|
110
|
+
versions.collect { |v| Versionomy.parse(v) }.
|
111
|
+
sort { |a,b| a <=> b }.reverse.
|
112
|
+
find { |v| v < lversion }.to_s
|
113
|
+
end
|
114
|
+
|
115
|
+
# Minimum gem version which satisfies this dependency
|
116
|
+
def min_satisfying_version
|
117
|
+
return "0.0" if self.version.nil? ||
|
118
|
+
self.condition == '<' ||
|
119
|
+
self.condition == '<='
|
120
|
+
return self.version if self.condition == '=' ||
|
121
|
+
self.condition == '>='
|
122
|
+
Versionomy.parse(self.version).bump(:tiny).to_s # self.condition == '>'
|
123
|
+
end
|
124
|
+
|
125
|
+
# Max gem version which satisfies this dependency
|
126
|
+
#
|
127
|
+
# Can't automatically deduce in '<' case, so if that is the conditional
|
128
|
+
# we require a version list, and will return the gcd from it
|
129
|
+
def max_satisfying_version(versions=nil)
|
130
|
+
return Float::INFINITY if self.version.nil? ||
|
131
|
+
self.condition == '>' ||
|
132
|
+
self.condition == '>='
|
133
|
+
return self.version if self.condition == '=' ||
|
134
|
+
self.condition == '<='
|
135
|
+
|
136
|
+
raise ArgumentError if versions.nil?
|
137
|
+
self.gcd(versions)
|
55
138
|
end
|
56
139
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
# Max gem version which satisfies this dependency
|
118
|
-
#
|
119
|
-
# Can't automatically deduce in '<' case, so if that is the conditional
|
120
|
-
# we require a version list, and will return the gcd from it
|
121
|
-
def max_satisfying_version(versions=nil)
|
122
|
-
return Float::INFINITY if self.version.nil? ||
|
123
|
-
self.condition == '>' ||
|
124
|
-
self.condition == '>='
|
125
|
-
return self.version if self.condition == '=' ||
|
126
|
-
self.condition == '<='
|
127
|
-
|
128
|
-
raise ArgumentError if versions.nil?
|
129
|
-
self.gcd(versions)
|
130
|
-
end
|
131
|
-
|
132
|
-
# Minimum gem version for which this dependency fails
|
133
|
-
def min_failing_version
|
134
|
-
raise ArgumentError if self.version.nil?
|
135
|
-
return "0.0" if self.condition == '>' ||
|
136
|
-
self.condition == '>='
|
137
|
-
return self.version if self.condition == '<'
|
138
|
-
Versionomy.parse(self.version).bump(:tiny).to_s # self.condition == '<=' and '='
|
139
|
-
end
|
140
|
-
|
141
|
-
# Max gem version for which this dependency fails
|
142
|
-
#
|
143
|
-
# Can't automatically deduce in '>=', and '=' cases, so if that is the
|
144
|
-
# conditional we require a version list, and will return the gcd from it
|
145
|
-
def max_failing_version(versions=nil)
|
146
|
-
raise ArgumentError if self.version.nil? ||
|
147
|
-
self.condition == '<=' ||
|
148
|
-
self.condition == '<'
|
149
|
-
return self.version if self.condition == '>'
|
150
|
-
|
151
|
-
raise ArgumentError if versions.nil?
|
152
|
-
self.gcd(versions)
|
153
|
-
end
|
154
|
-
|
155
|
-
# Return bool indicating if requirement matches specified
|
156
|
-
# depedency.
|
157
|
-
#
|
158
|
-
# Comparison mechanism will depend on type of class
|
159
|
-
# passed to this. Valid types include
|
160
|
-
# - Polisher::RPM::Requirements
|
161
|
-
# - ::Gem::Dependency
|
162
|
-
def matches?(dep)
|
163
|
-
return self == dep if dep.is_a?(self.class)
|
164
|
-
raise ArgumentError unless dep.is_a?(::Gem::Dependency)
|
165
|
-
|
166
|
-
return false if !self.gem? || self.gem_name != dep.name
|
167
|
-
return true if self.version.nil?
|
168
|
-
|
169
|
-
Gem2Rpm::Helpers.expand_requirement([dep.requirement.to_s.split]).
|
170
|
-
any?{ |req|
|
171
|
-
req.first == self.condition && req.last.to_s == self.version
|
172
|
-
}
|
173
|
-
end
|
174
|
-
|
175
|
-
# Whether or not this requirement specified a ruby gem dependency
|
176
|
-
def gem?
|
177
|
-
!!(self.str =~ RPM::Spec::SPEC_GEM_REQ_MATCHER)
|
178
|
-
end
|
179
|
-
|
180
|
-
# Return the name of the gem which this requirement is for.
|
181
|
-
# Returns nil if this is not a gem requirement
|
182
|
-
def gem_name
|
183
|
-
# XXX need to explicitly run regex here to get $1
|
184
|
-
!!(self.str =~ RPM::Spec::SPEC_GEM_REQ_MATCHER) ? $1 : nil
|
185
|
-
end
|
186
|
-
end # class Requirement
|
187
|
-
end # module RPM
|
188
|
-
end
|
140
|
+
# Minimum gem version for which this dependency fails
|
141
|
+
def min_failing_version
|
142
|
+
raise ArgumentError if self.version.nil?
|
143
|
+
return "0.0" if self.condition == '>' ||
|
144
|
+
self.condition == '>='
|
145
|
+
return self.version if self.condition == '<'
|
146
|
+
Versionomy.parse(self.version).bump(:tiny).to_s # self.condition == '<=' and '='
|
147
|
+
end
|
148
|
+
|
149
|
+
# Max gem version for which this dependency fails
|
150
|
+
#
|
151
|
+
# Can't automatically deduce in '>=', and '=' cases, so if that is the
|
152
|
+
# conditional we require a version list, and will return the gcd from it
|
153
|
+
def max_failing_version(versions=nil)
|
154
|
+
raise ArgumentError if self.version.nil? ||
|
155
|
+
self.condition == '<=' ||
|
156
|
+
self.condition == '<'
|
157
|
+
return self.version if self.condition == '>'
|
158
|
+
|
159
|
+
raise ArgumentError if versions.nil?
|
160
|
+
self.gcd(versions)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Return bool indicating if requirement matches specified
|
164
|
+
# depedency.
|
165
|
+
#
|
166
|
+
# Comparison mechanism will depend on type of class
|
167
|
+
# passed to this. Valid types include
|
168
|
+
# - Polisher::RPM::Requirements
|
169
|
+
# - ::Gem::Dependency
|
170
|
+
def matches?(dep)
|
171
|
+
return self == dep if dep.is_a?(self.class)
|
172
|
+
raise ArgumentError unless dep.is_a?(::Gem::Dependency)
|
173
|
+
|
174
|
+
return false if !self.gem? || self.gem_name != dep.name
|
175
|
+
return true if self.version.nil?
|
176
|
+
|
177
|
+
Gem2Rpm::Helpers.expand_requirement([dep.requirement.to_s.split]).
|
178
|
+
any?{ |req|
|
179
|
+
req.first == self.condition && req.last.to_s == self.version
|
180
|
+
}
|
181
|
+
end
|
182
|
+
|
183
|
+
# Whether or not this requirement specified a ruby gem dependency
|
184
|
+
def gem?
|
185
|
+
!!(self.str =~ RPM::Spec::SPEC_GEM_REQ_MATCHER)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Return the name of the gem which this requirement is for.
|
189
|
+
# Returns nil if this is not a gem requirement
|
190
|
+
def gem_name
|
191
|
+
# XXX need to explicitly run regex here to get $1
|
192
|
+
!!(self.str =~ RPM::Spec::SPEC_GEM_REQ_MATCHER) ? $1 : nil
|
193
|
+
end
|
194
|
+
end # class Requirement
|
195
|
+
end # module RPM
|
196
|
+
end # Component.verify("RPM::Requirement")
|
197
|
+
end # module Polisher
|