polisher 0.8.1 → 0.9.1
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/README.md +45 -24
- data/Rakefile +3 -5
- data/bin/gem_dependency_checker.rb +86 -17
- data/lib/polisher/core.rb +4 -12
- data/lib/polisher/errata.rb +38 -18
- data/lib/polisher/gem.rb +3 -1
- data/lib/polisher/gemfile.rb +2 -1
- data/lib/polisher/git/pkg.rb +3 -1
- data/lib/polisher/koji.rb +51 -9
- data/lib/polisher/missing.rb +12 -0
- data/lib/polisher/version.rb +1 -1
- data/lib/polisher/version_checker.rb +16 -17
- data/spec/errata_spec.rb +21 -12
- data/spec/git_spec.rb +4 -1
- data/spec/koji_spec.rb +31 -1
- data/spec/{rpmspec_spec.rb → rpm/requirement_spec.rb} +7 -200
- data/spec/rpm/spec_spec.rb +204 -0
- data/spec/spec_helper.rb +12 -0
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407eada91bec23c5a2cbd22754e8b726be64a761
|
4
|
+
data.tar.gz: 0de716cd95ae868f6800743752b59a537aedef9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae609d0fd5197edd33fdef131c8d142f6b0ab5667f823232d457c84a1ab68e7cd99c358a582b45de25d2c95c020889cecf6dc5f005e0fa3b66f8a642006b3111
|
7
|
+
data.tar.gz: 74548b607ed70c04d835ecf254d7bde099b849f2d54471f12ff88f2737270c725e02ea191b242b62da44716e4d2d99687084ea4122252f24972bc826bfdc0d7a
|
data/README.md
CHANGED
@@ -1,25 +1,32 @@
|
|
1
|
-
Polisher
|
2
|
-
|
1
|
+
# Polisher
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/polisher)
|
4
|
+
[](https://travis-ci.org/ManageIQ/polisher)
|
5
|
+
[](https://codeclimate.com/github/ManageIQ/polisher)
|
6
|
+
[](https://coveralls.io/r/ManageIQ/polisher)
|
7
|
+
[](https://gemnasium.com/ManageIQ/polisher)
|
8
|
+
|
9
|
+
|
3
10
|
Ruby Post-Publishing Processor - Polish your Ruby projects with ease!
|
4
11
|
|
5
12
|
<pre>
|
6
|
-
.77 7.
|
7
|
-
+$ =~
|
8
|
-
+?ZZZII .Z$$$$$$
|
9
|
-
$~~:,.$Z $~~:,.7
|
10
|
-
?~:,, .......................................redmine...............=~:,,.
|
11
|
-
~::,..rails.......................................................~~:,.
|
12
|
-
~~:,, .........rack................json...........................=~:,,
|
13
|
-
=~::,.....................sass............activerecord..............~::,.
|
14
|
-
~~:,.=....eruby...................................................~~:,.~
|
15
|
-
+~:,,.................haml......................eventmachine.......?~::,.
|
16
|
-
~::,. ........................rspec................................~~:,.:
|
17
|
-
=~:,,:.........................................bundler.............~~:,,
|
18
|
-
~I7I..........rvm..................rake...........................,~7?II
|
19
|
-
$$$$$$$O $$$$$$$$
|
20
|
-
.ZO7Z, .+ZIZ.
|
21
|
-
7 7
|
22
|
-
$I ZI
|
13
|
+
.77 7.
|
14
|
+
+$ =~
|
15
|
+
+?ZZZII .Z$$$$$$
|
16
|
+
$~~:,.$Z $~~:,.7
|
17
|
+
?~:,, .......................................redmine...............=~:,,.
|
18
|
+
~::,..rails.......................................................~~:,.
|
19
|
+
~~:,, .........rack................json...........................=~:,,
|
20
|
+
=~::,.....................sass............activerecord..............~::,.
|
21
|
+
~~:,.=....eruby...................................................~~:,.~
|
22
|
+
+~:,,.................haml......................eventmachine.......?~::,.
|
23
|
+
~::,. ........................rspec................................~~:,.:
|
24
|
+
=~:,,:.........................................bundler.............~~:,,
|
25
|
+
~I7I..........rvm..................rake...........................,~7?II
|
26
|
+
$$$$$$$O $$$$$$$$
|
27
|
+
.ZO7Z, .+ZIZ.
|
28
|
+
7 7
|
29
|
+
$I ZI
|
23
30
|
</pre>
|
24
31
|
|
25
32
|
Polisher is a Ruby module and set of utilities aimed to assisting the post-publishing
|
@@ -55,7 +62,6 @@ Various polisher subcomponents depend on various command line utilities, these i
|
|
55
62
|
* /usr/bin/git - to checkout git repos
|
56
63
|
* /usr/bin/koji - to query and build against koji
|
57
64
|
* /usr/bin/yum - to query yum
|
58
|
-
* /usr/bin/sed - to manipulated metadata
|
59
65
|
* /usr/bin/md5sum - to generate required metadata
|
60
66
|
* /usr/bin/fedpkg - to query fedora
|
61
67
|
|
@@ -70,7 +76,7 @@ To install the latest release and all ruby dependencies simply run:
|
|
70
76
|
gem install polisher
|
71
77
|
|
72
78
|
See the bin/ directory for all executables available, pass '-h' to any to
|
73
|
-
see specific command line options. To run any command from a local git checkout
|
79
|
+
see specific command line options. To run any command from a local git checkout
|
74
80
|
of polisher, run the following beforehand:
|
75
81
|
|
76
82
|
export RUBYLIB='lib'
|
@@ -100,6 +106,16 @@ Simply specify the name of the gem to update like so:
|
|
100
106
|
Alternatively if "-u" is specified with a Fedora username, all the packages the
|
101
107
|
user owns will be checked out and updated.
|
102
108
|
|
109
|
+
### git_gem_diff
|
110
|
+
|
111
|
+
A script that does a source comparison between a gem maintained in git against
|
112
|
+
its corresponding rubygems.org gem.
|
113
|
+
|
114
|
+
Simply specify the url to the git repo and the tool will automatically detect
|
115
|
+
the version of the gem to retrieve and run the diff on
|
116
|
+
|
117
|
+
git_gem_diff.rb -g https://github.com/ManageIQ/polisher.git
|
118
|
+
|
103
119
|
### ruby_rpm_spec_updater
|
104
120
|
|
105
121
|
A tool to update a given ruby gem or application based rpm spec to the specified
|
@@ -111,10 +127,15 @@ to STDOUT.
|
|
111
127
|
|
112
128
|
ruby_rpm_spec_updater.rb ~/rpmbuild/SPECS/rubygem-rails.spec rails-5.0.0.gem
|
113
129
|
|
114
|
-
###
|
130
|
+
### check_ruby_spec
|
131
|
+
|
132
|
+
A tool to compare the given ruby based rpm spec against the specified source
|
133
|
+
and/or the corresponding gem retrieved from rubygems.org
|
134
|
+
|
135
|
+
check_ruby_spec.rb ~/rpmbuild/SPECS/rubygem-polisher.spec
|
115
136
|
|
116
|
-
|
117
|
-
|
137
|
+
This will retrieve the gem and check the spec for consistency, reporting
|
138
|
+
any discrepancies.
|
118
139
|
|
119
140
|
### polisher
|
120
141
|
|
data/Rakefile
CHANGED
@@ -5,11 +5,9 @@
|
|
5
5
|
|
6
6
|
begin
|
7
7
|
require "rspec/core/rake_task"
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
spec.rspec_opts = ['--backtrace', '-fd', '-c']
|
12
|
-
end
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
task :test => :spec
|
10
|
+
task :default => :spec
|
13
11
|
rescue LoadError
|
14
12
|
end
|
15
13
|
|
@@ -21,20 +21,21 @@ require 'polisher/gemfile'
|
|
21
21
|
|
22
22
|
##########################################################
|
23
23
|
|
24
|
-
conf = {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
conf = {:format => nil,
|
25
|
+
:gemfile => './Gemfile',
|
26
|
+
:gemspec => nil,
|
27
|
+
:gemname => nil,
|
28
|
+
:groups => [],
|
29
|
+
:devel_deps => false,
|
30
|
+
:highlight_missing => false,
|
31
|
+
:check_fedora => false,
|
32
|
+
:check_git => false,
|
33
|
+
:check_koji => false,
|
34
|
+
:check_rhn => false,
|
35
|
+
:check_yum => false,
|
36
|
+
:check_bugzilla => false,
|
37
|
+
:check_errata => false,
|
38
|
+
:check_bodhi => false}
|
38
39
|
|
39
40
|
optparse = OptionParser.new do |opts|
|
40
41
|
opts.on('-h', '--help', 'Display this help screen') do
|
@@ -42,6 +43,10 @@ optparse = OptionParser.new do |opts|
|
|
42
43
|
exit
|
43
44
|
end
|
44
45
|
|
46
|
+
opts.on("--format val", 'Format which to render output') do |f|
|
47
|
+
conf[:format] = f
|
48
|
+
end
|
49
|
+
|
45
50
|
opts.on('--gemfile file', 'Location of the gemfile to parse') do |g|
|
46
51
|
conf[:gemfile] = g
|
47
52
|
end
|
@@ -127,22 +132,83 @@ targets << Polisher::VersionChecker::BODHI_TARGET if conf[:check_bodhi]
|
|
127
132
|
targets = Polisher::VersionChecker::ALL_TARGETS if targets.empty?
|
128
133
|
Polisher::VersionChecker.check targets
|
129
134
|
|
135
|
+
@format = conf[:format]
|
136
|
+
|
137
|
+
def format_dep(dep)
|
138
|
+
if @format.nil?
|
139
|
+
dep.to_s.blue.bold
|
140
|
+
elsif @format == 'xml'
|
141
|
+
"<#{dep}>"
|
142
|
+
elsif @format == 'json'
|
143
|
+
"'#{dep}':{"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def format_end_dep(dep)
|
148
|
+
if @format.nil?
|
149
|
+
"\n"
|
150
|
+
elsif @format == 'xml'
|
151
|
+
"\n</#{dep}>"
|
152
|
+
elsif @format == 'json'
|
153
|
+
"\n}"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def format_tgt(tgt)
|
158
|
+
if @format.nil?
|
159
|
+
"#{tgt.to_s.red.bold} "
|
160
|
+
elsif @format == 'xml'
|
161
|
+
"<#{tgt}/>"
|
162
|
+
elsif @format == 'json'
|
163
|
+
"'#{tgt}':null,"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def format_tgt_with_versions(tgt, versions)
|
168
|
+
if @format.nil?
|
169
|
+
"#{tgt.to_s.green.bold}: #{versions.join(', ').yellow} "
|
170
|
+
elsif @format == 'xml'
|
171
|
+
"<#{tgt}>#{versions.join(', ')}</#{tgt}>"
|
172
|
+
elsif @format == 'json'
|
173
|
+
"'#{tgt}':['#{versions.join('\', \'')}'],"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def print_header
|
178
|
+
if @format == 'xml'
|
179
|
+
puts '<dependencies>'
|
180
|
+
elsif @format == 'json'
|
181
|
+
puts '{'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def print_footer
|
186
|
+
if @format == 'xml'
|
187
|
+
puts "</dependencies>"
|
188
|
+
elsif @format == 'json'
|
189
|
+
puts "}"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
130
193
|
def print_dep(tgt, dep, versions)
|
131
194
|
# XXX little bit hacky but works for now
|
132
195
|
@last_dep ||= nil
|
133
196
|
if @last_dep != dep
|
134
|
-
puts
|
197
|
+
puts format_end_dep(@last_dep) unless @last_dep.nil?
|
198
|
+
puts format_dep(dep)
|
135
199
|
@last_dep = dep
|
136
200
|
end
|
137
201
|
|
138
202
|
if versions.nil? || versions.empty? ||
|
139
203
|
versions.size == 1 && versions[0].nil?
|
140
|
-
print
|
204
|
+
print format_tgt(tgt)
|
141
205
|
else
|
142
|
-
print
|
206
|
+
print format_tgt_with_versions(tgt, versions)
|
143
207
|
end
|
144
208
|
end
|
145
209
|
|
210
|
+
print_header
|
211
|
+
|
146
212
|
if conf[:gemname]
|
147
213
|
gem = Polisher::Gem.retrieve(conf[:gemname])
|
148
214
|
gem.versions(:recursive => true, :dev_deps => true) do |tgt, dep, versions|
|
@@ -169,3 +235,6 @@ elsif conf[:gemfile]
|
|
169
235
|
print_dep(tgt, dep, versions)
|
170
236
|
end
|
171
237
|
end
|
238
|
+
|
239
|
+
puts format_end_dep(@last_dep) unless @last_dep.nil? # XXX
|
240
|
+
print_footer
|
data/lib/polisher/core.rb
CHANGED
@@ -3,14 +3,6 @@
|
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
class Object
|
7
|
-
def eigenclass
|
8
|
-
class << self
|
9
|
-
self
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
6
|
module ConfHelpers
|
15
7
|
# Defines a 'config attribute' or attribute on the class
|
16
8
|
# which this is defined in. Accessors to the single shared
|
@@ -33,8 +25,8 @@ module ConfHelpers
|
|
33
25
|
nvar = "@#{name}".intern
|
34
26
|
current = self.instance_variable_get(nvar)
|
35
27
|
envk = "POLISHER_#{name.to_s.upcase}"
|
36
|
-
|
37
|
-
|
28
|
+
instance_variable_set(nvar, default) unless current
|
29
|
+
instance_variable_set(nvar, ENV[envk]) if ENV.key?(envk)
|
38
30
|
# TODO also allow vars to be able to be set from a conf file
|
39
31
|
self.instance_variable_set(nvar, args.first) unless args.empty?
|
40
32
|
self.instance_variable_get(nvar)
|
@@ -46,8 +38,6 @@ module ConfHelpers
|
|
46
38
|
end
|
47
39
|
end
|
48
40
|
|
49
|
-
require 'polisher/rpm/spec'
|
50
|
-
|
51
41
|
class String
|
52
42
|
# Return bool indicating if self is a path to a gem
|
53
43
|
def gem?
|
@@ -68,6 +58,7 @@ class String
|
|
68
58
|
# macro correspondents. If no rpm macro is specified macro will
|
69
59
|
# simply be removed
|
70
60
|
def unrpmize
|
61
|
+
require 'polisher/rpm/spec'
|
71
62
|
fmm = Polisher::RPM::Spec::FILE_MACRO_MATCHERS
|
72
63
|
fmr = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS
|
73
64
|
f = fmm.inject(self) { |file, matcher| file.gsub(matcher, '') }
|
@@ -78,6 +69,7 @@ class String
|
|
78
69
|
# Replace all occurrances of non-rpm macro strings in self
|
79
70
|
# with their macro correspondences
|
80
71
|
def rpmize
|
72
|
+
require 'polisher/rpm/spec'
|
81
73
|
fmr = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS.invert
|
82
74
|
fmr.keys.inject(self) { |file, r| file.gsub(r, fmr[r]) }
|
83
75
|
end
|
data/lib/polisher/errata.rb
CHANGED
@@ -6,30 +6,50 @@
|
|
6
6
|
require 'json'
|
7
7
|
require 'curb'
|
8
8
|
|
9
|
+
require 'polisher/core'
|
10
|
+
|
9
11
|
module Polisher
|
10
12
|
class Errata
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
extend ConfHelpers
|
14
|
+
|
15
|
+
conf_attr :advisory_url, ''
|
16
|
+
conf_attr :package_prefix, 'rubygem-'
|
17
|
+
|
18
|
+
# Initialize/return singleton curl handle to query errata
|
19
|
+
def self.client
|
14
20
|
@curl ||= begin
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
curl = Curl::Easy.new
|
22
|
+
curl.ssl_verify_peer = false
|
23
|
+
curl.ssl_verify_host = false
|
24
|
+
curl.http_auth_types = :negotiate
|
25
|
+
curl.userpwd = ':'
|
26
|
+
curl
|
20
27
|
end
|
28
|
+
end
|
21
29
|
|
22
|
-
|
23
|
-
@
|
30
|
+
def self.clear!
|
31
|
+
@cached_url = nil
|
32
|
+
@cached_builds = nil
|
33
|
+
self
|
24
34
|
end
|
25
35
|
|
26
|
-
def self.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
36
|
+
def self.builds
|
37
|
+
@cached_url ||= advisory_url
|
38
|
+
@cached_builds ||= nil
|
39
|
+
|
40
|
+
if @cached_url != advisory_url || @cached_builds.nil?
|
41
|
+
client.url = "#{advisory_url}/builds"
|
42
|
+
@cached_builds = client.get
|
43
|
+
@cached_builds = JSON.parse(client.body_str)
|
44
|
+
end
|
45
|
+
|
46
|
+
@cached_builds
|
47
|
+
end
|
32
48
|
|
49
|
+
def self.versions_for(name, &bl)
|
50
|
+
versions = builds.collect do |tag, builds|
|
51
|
+
ErrataBuild.builds_matching(builds, name)
|
52
|
+
end.flatten
|
33
53
|
bl.call(:errata, name, versions) unless(bl.nil?)
|
34
54
|
versions
|
35
55
|
end
|
@@ -44,12 +64,12 @@ module Polisher
|
|
44
64
|
|
45
65
|
def self.build_matches?(build, name)
|
46
66
|
pkg,meta = *build.flatten
|
47
|
-
pkg =~
|
67
|
+
pkg =~ /^#{Errata.package_prefix}#{name}-([^-]*)-.*$/
|
48
68
|
end
|
49
69
|
|
50
70
|
def self.build_version(build, name)
|
51
71
|
pkg,meta = *build.flatten
|
52
|
-
pkg.split('-')[
|
72
|
+
pkg.gsub(Errata.package_prefix, '').split('-')[1]
|
53
73
|
end
|
54
74
|
end
|
55
75
|
end
|
data/lib/polisher/gem.rb
CHANGED
@@ -61,7 +61,9 @@ module Polisher
|
|
61
61
|
# @param [Callable] bl optional block to invoke with versions retrieved
|
62
62
|
# @return [Array<String>] list of versions of gem installed locally
|
63
63
|
def self.local_versions_for(name, &bl)
|
64
|
-
|
64
|
+
silence_warnings do
|
65
|
+
@local_db ||= ::Gem::Specification.all
|
66
|
+
end
|
65
67
|
versions = @local_db.select { |s| s.name == name }.collect { |s| s.version }
|
66
68
|
bl.call(:local_gem, name, versions) unless(bl.nil?)
|
67
69
|
versions
|
data/lib/polisher/gemfile.rb
CHANGED
@@ -22,6 +22,8 @@ module Polisher
|
|
22
22
|
# always empty array, for interface compatability
|
23
23
|
attr_accessor :file_paths
|
24
24
|
|
25
|
+
attr_accessor :definition
|
26
|
+
|
25
27
|
def initialize(args={})
|
26
28
|
@version = nil
|
27
29
|
@deps = args[:deps]
|
@@ -50,7 +52,6 @@ module Polisher
|
|
50
52
|
metadata = {}
|
51
53
|
metadata[:deps] =
|
52
54
|
definition.dependencies.select { |d|
|
53
|
-
d.groups.include?(:default) || # dep in all groups
|
54
55
|
groups.nil? || groups.empty? || # groups not specified
|
55
56
|
groups.any? { |g| d.groups.include?(g.intern) } # dep in any group
|
56
57
|
}.collect { |d| d.name }
|
data/lib/polisher/git/pkg.rb
CHANGED
@@ -123,7 +123,9 @@ module Polisher
|
|
123
123
|
# Update git ignore to ignore gem
|
124
124
|
def ignore(gem)
|
125
125
|
in_repo do
|
126
|
-
File.
|
126
|
+
nl = File.exists?('.gitignore') ? "\n" : ''
|
127
|
+
content = "#{nl}#{gem.name}-#{gem.version}.gem"
|
128
|
+
File.open(".gitignore", 'a') { |f| f.write content }
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
data/lib/polisher/koji.rb
CHANGED
@@ -4,8 +4,11 @@
|
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'xmlrpc/client'
|
7
|
-
|
8
|
-
|
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
|
9
12
|
|
10
13
|
require 'polisher/core'
|
11
14
|
|
@@ -15,10 +18,13 @@ module Polisher
|
|
15
18
|
|
16
19
|
# TODO Koji#build (on class or instance?)
|
17
20
|
|
18
|
-
# TODO Koji#diff(tag1, tag2)
|
19
|
-
|
20
21
|
conf_attr :koji_url, 'koji.fedoraproject.org/kojihub'
|
21
22
|
conf_attr :koji_tag, 'f21'
|
23
|
+
conf_attr :package_prefix, 'rubygem-'
|
24
|
+
|
25
|
+
def self.koji_tags
|
26
|
+
[koji_tag].flatten
|
27
|
+
end
|
22
28
|
|
23
29
|
# Retrieve shared instance of xmlrpc client to use
|
24
30
|
def self.client
|
@@ -45,20 +51,56 @@ module Polisher
|
|
45
51
|
}
|
46
52
|
end
|
47
53
|
|
48
|
-
#
|
54
|
+
# Return list of tags for which a package exists
|
55
|
+
#
|
56
|
+
# @param [String] name of package to lookup
|
57
|
+
# @return [Hash<String,String>] hash of tag names to package versions for tags
|
58
|
+
# which package was found in
|
59
|
+
def self.tagged_in(name)
|
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
|
64
|
+
|
65
|
+
# Retrieve list of the versions of the specified package in koji
|
49
66
|
#
|
50
67
|
# @param [String] name name of package to lookup
|
51
68
|
# @param [Callable] bl optional block to invoke with versions retrieved
|
52
|
-
# @return [String] versions retrieved,
|
69
|
+
# @return [Array<String>] versions retrieved, empty array if none found
|
53
70
|
def self.versions_for(name, &bl)
|
54
71
|
# koji xmlrpc call
|
55
72
|
builds =
|
56
|
-
|
57
|
-
|
58
|
-
|
73
|
+
koji_tags.collect do |tag|
|
74
|
+
client.call('listTagged', tag, nil, false, nil, false,
|
75
|
+
"#{package_prefix}#{name}")
|
76
|
+
end.flatten
|
59
77
|
versions = builds.collect { |b| b['version'] }
|
60
78
|
bl.call(:koji, name, versions) unless(bl.nil?)
|
61
79
|
versions
|
62
80
|
end
|
81
|
+
|
82
|
+
# Return diff between list of packages in two tags in koji
|
83
|
+
def self.diff(tag1, tag2)
|
84
|
+
builds1 = client.call('listTagged', tag1, nil, false, nil, false)
|
85
|
+
builds2 = client.call('listTagged', tag2, nil, false, nil, false)
|
86
|
+
builds = {}
|
87
|
+
builds1.each do |build|
|
88
|
+
name = build['package_name']
|
89
|
+
build2 = builds2.find { |b| b['name'] == name }
|
90
|
+
version1 = build['version']
|
91
|
+
version2 = build2 && build2['version']
|
92
|
+
builds[name] = {tag1 => version1, tag2 => version2}
|
93
|
+
end
|
94
|
+
|
95
|
+
builds2.each do |build|
|
96
|
+
name = build['package_name']
|
97
|
+
next if builds.key?(name)
|
98
|
+
|
99
|
+
version = build['version']
|
100
|
+
builds[name] = {tag1 => nil, tag2 => version}
|
101
|
+
end
|
102
|
+
|
103
|
+
builds
|
104
|
+
end
|
63
105
|
end
|
64
106
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Polisher "Missing" Component
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
module Polisher
|
7
|
+
class MissingComponent
|
8
|
+
def method_missing(method_id, *args, &bl)
|
9
|
+
raise "polisher is missing a dependency - cannot invoke #{method_id} on #{self}"
|
10
|
+
end
|
11
|
+
end # class MissingComponent
|
12
|
+
end # module Polisher
|
data/lib/polisher/version.rb
CHANGED
@@ -4,11 +4,6 @@
|
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/gem'
|
7
|
-
require 'polisher/fedora'
|
8
|
-
require 'polisher/koji'
|
9
|
-
require 'polisher/git/pkg'
|
10
|
-
require 'polisher/bodhi'
|
11
|
-
require 'polisher/yum'
|
12
7
|
|
13
8
|
module Polisher
|
14
9
|
class VersionChecker
|
@@ -17,19 +12,15 @@ module Polisher
|
|
17
12
|
FEDORA_TARGET = :fedora
|
18
13
|
GIT_TARGET = :git
|
19
14
|
YUM_TARGET = :yum
|
20
|
-
BODHI_TARGET = :bodhi
|
15
|
+
BODHI_TARGET = :bodhi # fedora dispatches to bodhi so not enabled by default
|
16
|
+
ERRATA_TARGET = :errata # not enabled by default
|
21
17
|
ALL_TARGETS = [GEM_TARGET, KOJI_TARGET, FEDORA_TARGET,
|
22
18
|
GIT_TARGET, YUM_TARGET]
|
23
19
|
|
24
20
|
# Enable the specified target(s) in the list of target to check
|
25
|
-
def self.check(target)
|
21
|
+
def self.check(*target)
|
26
22
|
@check_list ||= []
|
27
|
-
|
28
|
-
target.each { |t| self.check(t) }
|
29
|
-
return
|
30
|
-
end
|
31
|
-
|
32
|
-
@check_list << target
|
23
|
+
target.each { |t| @check_list << t }
|
33
24
|
end
|
34
25
|
|
35
26
|
def self.should_check?(target)
|
@@ -53,27 +44,34 @@ module Polisher
|
|
53
44
|
end
|
54
45
|
|
55
46
|
if should_check?(FEDORA_TARGET)
|
47
|
+
require 'polisher/fedora'
|
56
48
|
versions.merge! :fedora => Fedora.versions_for(name, &bl)
|
57
49
|
end
|
58
50
|
|
59
51
|
if should_check?(KOJI_TARGET)
|
52
|
+
require 'polisher/koji'
|
60
53
|
versions.merge! :koji => Koji.versions_for(name, &bl)
|
61
54
|
end
|
62
55
|
|
63
56
|
if should_check?(GIT_TARGET)
|
57
|
+
require 'polisher/git/pkg'
|
64
58
|
versions.merge! :git => [Git::Pkg.version_for(name, &bl)]
|
65
59
|
end
|
66
60
|
|
67
61
|
if should_check?(YUM_TARGET)
|
62
|
+
require 'polisher/yum'
|
68
63
|
versions.merge! :yum => [Yum.version_for(name, &bl)]
|
69
64
|
end
|
70
65
|
|
71
66
|
if should_check?(BODHI_TARGET)
|
67
|
+
require 'polisher/bodhi'
|
72
68
|
versions.merge! :bodhi => Bodhi.versions_for(name, &bl)
|
73
69
|
end
|
74
70
|
|
75
|
-
|
76
|
-
|
71
|
+
if should_check?(ERRATA_TARGET)
|
72
|
+
require 'polisher/errata'
|
73
|
+
versions.merge! :errata => Errata.versions_for(name, &bl)
|
74
|
+
end
|
77
75
|
|
78
76
|
versions
|
79
77
|
end
|
@@ -97,11 +95,12 @@ module Polisher
|
|
97
95
|
# of gem names representing component dependencies. List
|
98
96
|
# will be iterated over, versions will be looked up
|
99
97
|
# recursively and returned
|
100
|
-
def dependency_versions(&bl)
|
98
|
+
def dependency_versions(args = {}, &bl)
|
99
|
+
args = {:recursive => true, :dev_deps => true}.merge(args)
|
101
100
|
versions = {}
|
102
101
|
self.deps.each do |dep|
|
103
102
|
gem = Polisher::Gem.retrieve(dep)
|
104
|
-
versions.merge!(gem.versions(
|
103
|
+
versions.merge!(gem.versions(args, &bl))
|
105
104
|
end
|
106
105
|
versions
|
107
106
|
end
|
data/spec/errata_spec.rb
CHANGED
@@ -9,34 +9,43 @@ module Polisher
|
|
9
9
|
describe Errata do
|
10
10
|
describe "#versions_for" do
|
11
11
|
before(:each) do
|
12
|
-
@result =
|
13
|
-
@
|
12
|
+
@result = {'tag' => [['rubygem-rails-1.0.0-1']]}.to_json
|
13
|
+
@orig_url = described_class.advisory_url
|
14
|
+
end
|
15
|
+
|
16
|
+
after(:each) do
|
17
|
+
described_class.advisory_url @orig_url
|
18
|
+
described_class.clear!
|
14
19
|
end
|
15
20
|
|
16
21
|
it "uses curl to retreive updates" do
|
17
22
|
client = Curl::Easy.new
|
18
|
-
described_class.should_receive(:client).
|
19
|
-
client.should_receive(:
|
23
|
+
described_class.should_receive(:client).at_least(:once).and_return(client)
|
24
|
+
client.should_receive(:url=).with('http://errata.url/builds')
|
25
|
+
client.should_receive(:get)
|
26
|
+
client.should_receive(:body_str).and_return(@result)
|
20
27
|
|
21
|
-
described_class.
|
28
|
+
described_class.advisory_url 'http://errata.url'
|
29
|
+
described_class.versions_for('rails')
|
22
30
|
end
|
23
31
|
|
24
32
|
it "returns versions" do
|
25
33
|
client = Curl::Easy.new
|
26
|
-
described_class.should_receive(:client).and_return(client)
|
27
|
-
client.
|
28
|
-
|
29
|
-
described_class.versions_for('
|
34
|
+
described_class.should_receive(:client).at_least(:once).and_return(client)
|
35
|
+
client.stub(:get)
|
36
|
+
client.should_receive(:body_str).and_return(@result)
|
37
|
+
described_class.versions_for('rails').should == ['1.0.0']
|
30
38
|
end
|
31
39
|
|
32
40
|
it "invokes block with versions" do
|
33
41
|
client = Curl::Easy.new
|
34
|
-
described_class.should_receive(:client).and_return(client)
|
35
|
-
client.
|
42
|
+
described_class.should_receive(:client).at_least(:once).and_return(client)
|
43
|
+
client.stub(:get)
|
44
|
+
client.should_receive(:body_str).and_return(@result)
|
36
45
|
|
37
46
|
cb = proc {}
|
38
47
|
cb.should_receive(:call).with(:errata, 'rails', ['1.0.0'])
|
39
|
-
described_class.versions_for('
|
48
|
+
described_class.versions_for('rails', &cb)
|
40
49
|
end
|
41
50
|
end
|
42
51
|
end # describe Koji
|
data/spec/git_spec.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/git'
|
7
|
+
require 'pathname'
|
7
8
|
|
8
9
|
module Polisher
|
9
10
|
describe Git::Repo do
|
@@ -61,10 +62,12 @@ module Polisher
|
|
61
62
|
repo = described_class.new
|
62
63
|
Dir.mktmpdir do |dir|
|
63
64
|
repo.should_receive(:path).and_return(dir)
|
65
|
+
|
66
|
+
expected = Pathname.new(dir).realpath.to_s
|
64
67
|
invoked = false
|
65
68
|
orig = Dir.pwd
|
66
69
|
repo.in_repo do
|
67
|
-
Dir.pwd.should ==
|
70
|
+
Dir.pwd.should == expected
|
68
71
|
invoked = true
|
69
72
|
end
|
70
73
|
Dir.pwd.should == orig
|
data/spec/koji_spec.rb
CHANGED
@@ -39,12 +39,31 @@ module Polisher
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe "#
|
42
|
+
describe "#tagged_in" do
|
43
43
|
before(:each) do
|
44
44
|
@client = double(XMLRPC::Client)
|
45
45
|
described_class.should_receive(:client).and_return(@client)
|
46
46
|
end
|
47
47
|
|
48
|
+
it "uses xmlrpc client to retrieve packages" do
|
49
|
+
expected = ['listPackages', nil, nil, "rubygem-rails", nil, false, true]
|
50
|
+
@client.should_receive(:call).with(*expected).and_return([])
|
51
|
+
described_class.tagged_in 'rails'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns tags" do
|
55
|
+
tags = [{'tag_name' => 'tag1'}, {'tag_name' => 'tag2'}]
|
56
|
+
@client.should_receive(:call).and_return(tags)
|
57
|
+
described_class.tagged_in('rails').should == ['tag1', 'tag2']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#versions_for" do
|
62
|
+
before(:each) do
|
63
|
+
@client = double(XMLRPC::Client)
|
64
|
+
described_class.should_receive(:client).at_least(:once).and_return(@client)
|
65
|
+
end
|
66
|
+
|
48
67
|
it "uses xmlrpc client to retreive versions" do
|
49
68
|
expected = ['listTagged', described_class.koji_tag, nil, false,
|
50
69
|
nil, false, "rubygem-rails"]
|
@@ -52,6 +71,17 @@ module Polisher
|
|
52
71
|
described_class.versions_for 'rails'
|
53
72
|
end
|
54
73
|
|
74
|
+
it "handles multiple koji tags" do
|
75
|
+
described_class.should_receive(:koji_tags).and_return(['tag1', 'tag2'])
|
76
|
+
expected1 = ['listTagged', 'tag1', nil, false,
|
77
|
+
nil, false, "rubygem-rails"]
|
78
|
+
expected2 = ['listTagged', 'tag2', nil, false,
|
79
|
+
nil, false, "rubygem-rails"]
|
80
|
+
@client.should_receive(:call).with(*expected1).and_return([])
|
81
|
+
@client.should_receive(:call).with(*expected2).and_return([])
|
82
|
+
described_class.versions_for 'rails'
|
83
|
+
end
|
84
|
+
|
55
85
|
it "returns versions" do
|
56
86
|
versions = [{'version' => '1.0.0'}]
|
57
87
|
@client.should_receive(:call).and_return(versions)
|
@@ -1,15 +1,15 @@
|
|
1
|
-
# Polisher
|
1
|
+
# Polisher RPM Requirement Specs
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C)
|
4
|
+
# Copyright (C) 2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'spec_helper'
|
7
7
|
|
8
|
-
require 'polisher/rpm/
|
8
|
+
require 'polisher/rpm/requirement'
|
9
9
|
require 'polisher/gem'
|
10
10
|
|
11
|
-
module Polisher
|
12
|
-
describe
|
11
|
+
module Polisher::RPM
|
12
|
+
describe Requirement do
|
13
13
|
describe "#str" do
|
14
14
|
it "returns requirement in string format" do
|
15
15
|
req = described_class.new :name => 'rubygem(activesupport)'
|
@@ -343,198 +343,5 @@ module Polisher
|
|
343
343
|
end
|
344
344
|
end
|
345
345
|
end
|
346
|
-
end
|
347
|
-
|
348
|
-
describe RPM::Spec do
|
349
|
-
describe "#initialize" do
|
350
|
-
it "sets gem metadata" do
|
351
|
-
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
352
|
-
spec.metadata.should == {:version => '1.0.0'}
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
|
-
describe "#method_missing" do
|
357
|
-
it "proxies lookup to metadata" do
|
358
|
-
spec = Polisher::RPM::Spec.new :version => '1.0.0'
|
359
|
-
spec.version.should == '1.0.0'
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
describe "#has_check?" do
|
364
|
-
context "package spec has %check section" do
|
365
|
-
it "returns true" do
|
366
|
-
spec = described_class.new :has_check => true
|
367
|
-
spec.has_check?.should be_true
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
context "package spec does not have a %check section" do
|
372
|
-
it "returns false" do
|
373
|
-
spec = described_class.new
|
374
|
-
spec.has_check?.should be_false
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
|
380
|
-
describe "#requirements_for_gem" do
|
381
|
-
it "returns requirements for specified gem name" do
|
382
|
-
spec = Polisher::RPM::Spec.new :requires =>
|
383
|
-
[Polisher::RPM::Requirement.new(:name => 'rubygem(rake)')]
|
384
|
-
spec.requirements_for_gem('rake').should == [spec.requires.first]
|
385
|
-
end
|
386
|
-
|
387
|
-
context "spec has no requirement with specified name" do
|
388
|
-
it "returns empty array" do
|
389
|
-
spec = Polisher::RPM::Spec.new
|
390
|
-
spec.requirements_for_gem('rake').should be_empty
|
391
|
-
end
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
describe "#parse" do
|
396
|
-
before(:each) do
|
397
|
-
@spec = Polisher::Test::RPM_SPEC
|
398
|
-
end
|
399
|
-
|
400
|
-
it "returns new rpmspec instance" do
|
401
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
402
|
-
pspec.should be_an_instance_of(Polisher::RPM::Spec)
|
403
|
-
end
|
404
|
-
|
405
|
-
it "parses contents from spec" do
|
406
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
407
|
-
pspec.contents.should == @spec[:contents]
|
408
|
-
end
|
409
|
-
|
410
|
-
it "parses name from spec" do
|
411
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
412
|
-
pspec.gem_name.should == @spec[:name]
|
413
|
-
end
|
414
|
-
|
415
|
-
it "parses version from spec" do
|
416
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
417
|
-
pspec.version.should == @spec[:version]
|
418
|
-
end
|
419
|
-
|
420
|
-
it "parses release from spec" do
|
421
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
422
|
-
pspec.release.should == @spec[:release]
|
423
|
-
end
|
424
|
-
|
425
|
-
it "parses requires from spec" do
|
426
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
427
|
-
pspec.requires.should == @spec[:requires]
|
428
|
-
end
|
429
|
-
|
430
|
-
it "parses build requires from spec" do
|
431
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
432
|
-
pspec.build_requires.should == @spec[:build_requires]
|
433
|
-
end
|
434
|
-
|
435
|
-
it "parses changelog from spec"
|
436
|
-
|
437
|
-
it "parses unrpmized files from spec" do
|
438
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
439
|
-
pspec.files.should == @spec[:files]
|
440
|
-
end
|
441
|
-
|
442
|
-
it "parses %check from spec" do
|
443
|
-
pspec = Polisher::RPM::Spec.parse @spec[:contents]
|
444
|
-
pspec.has_check?.should be_true
|
445
|
-
|
446
|
-
pspec = Polisher::RPM::Spec.parse ""
|
447
|
-
pspec.has_check?.should be_false
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
describe "#update_to" do
|
452
|
-
it "updates dependencies from gem" do
|
453
|
-
spec = Polisher::RPM::Spec.new :requires => [Polisher::RPM::Requirement.parse('rubygem(rake)'),
|
454
|
-
Polisher::RPM::Requirement.parse('rubygem(activerecord)')],
|
455
|
-
:build_requires => []
|
456
|
-
gem = Polisher::Gem.new :deps => [::Gem::Dependency.new('rake'),
|
457
|
-
::Gem::Dependency.new('rails', '~> 10')],
|
458
|
-
:dev_deps => [::Gem::Dependency.new('rspec', :development)]
|
459
|
-
|
460
|
-
spec.should_receive(:update_files_from) # stub out files update
|
461
|
-
spec.update_to(gem)
|
462
|
-
spec.requires.should == [Polisher::RPM::Requirement.parse('rubygem(activerecord)'),
|
463
|
-
Polisher::RPM::Requirement.parse('rubygem(rake) >= 0'),
|
464
|
-
Polisher::RPM::Requirement.parse('rubygem(rails) => 10'),
|
465
|
-
Polisher::RPM::Requirement.parse('rubygem(rails) < 11')]
|
466
|
-
spec.build_requires.should == [Polisher::RPM::Requirement.parse('rubygem(rspec) >= 0', :br => true)]
|
467
|
-
end
|
468
|
-
|
469
|
-
it "adds new files from gem" do
|
470
|
-
spec = Polisher::RPM::Spec.new :files => {'pkg' => ['/foo']}
|
471
|
-
gem = Polisher::Gem.new
|
472
|
-
gem.should_receive(:file_paths).at_least(:once).
|
473
|
-
and_return(['/foo', '/foo/bar', '/baz'])
|
474
|
-
spec.update_to(gem)
|
475
|
-
spec.new_files.should == ['/baz']
|
476
|
-
end
|
477
|
-
|
478
|
-
it "updates metadata from gem" do
|
479
|
-
spec = Polisher::RPM::Spec.new
|
480
|
-
gem = Polisher::Gem.new :version => '1.0.0'
|
481
|
-
spec.should_receive(:update_files_from) # stub out files update
|
482
|
-
spec.update_to(gem)
|
483
|
-
spec.version.should == '1.0.0'
|
484
|
-
spec.release.should == '1%{?dist}'
|
485
|
-
end
|
486
|
-
|
487
|
-
it "adds changelog entry"
|
488
|
-
end
|
489
|
-
|
490
|
-
describe "#to_string" do
|
491
|
-
it "returns string representation of spec"
|
492
|
-
end
|
493
|
-
|
494
|
-
describe "#compare" do
|
495
|
-
it "returns requirements in spec but not in gem" do
|
496
|
-
req = Polisher::RPM::Requirement.parse 'rubygem(rails) > 3.0.0'
|
497
|
-
spec = Polisher::RPM::Spec.new :requires => [req]
|
498
|
-
gem = Polisher::Gem.new
|
499
|
-
|
500
|
-
spec.compare(gem).should ==
|
501
|
-
{:same => {}, :diff => {'rails' =>
|
502
|
-
{:spec => '> 3.0.0', :upstream => nil}}}
|
503
|
-
end
|
504
|
-
|
505
|
-
it "returns requirements in gem but not in spec" do
|
506
|
-
req = ::Gem::Dependency.new('rails', '> 3.0.0')
|
507
|
-
spec = Polisher::RPM::Spec.new
|
508
|
-
gem = Polisher::Gem.new :deps => [req]
|
509
|
-
|
510
|
-
spec.compare(gem).should ==
|
511
|
-
{:same => {}, :diff => {'rails' =>
|
512
|
-
{:spec => nil, :upstream => '> 3.0.0'}}}
|
513
|
-
end
|
514
|
-
|
515
|
-
it "returns shared requirements with different specifiers" do
|
516
|
-
greq = ::Gem::Dependency.new('rails', '< 5.0.0')
|
517
|
-
gem = Polisher::Gem.new :deps => [greq]
|
518
|
-
|
519
|
-
sreq = Polisher::RPM::Requirement.parse 'rubygem(rails) > 3.0.0'
|
520
|
-
spec = Polisher::RPM::Spec.new :requires => [sreq]
|
521
|
-
|
522
|
-
spec.compare(gem).should ==
|
523
|
-
{:same => {}, :diff => {'rails' =>
|
524
|
-
{:spec => '> 3.0.0', :upstream => '< 5.0.0'}}}
|
525
|
-
end
|
526
|
-
|
527
|
-
it "returns shared requirements" do
|
528
|
-
greq = ::Gem::Dependency.new('rails', '< 3.0.0')
|
529
|
-
gem = Polisher::Gem.new :deps => [greq]
|
530
|
-
|
531
|
-
sreq = Polisher::RPM::Requirement.parse 'rubygem(rails) < 3.0.0'
|
532
|
-
spec = Polisher::RPM::Spec.new :requires => [sreq]
|
533
|
-
|
534
|
-
spec.compare(gem).should ==
|
535
|
-
{:diff => {}, :same => {'rails' =>
|
536
|
-
{:spec => '< 3.0.0', :upstream => '< 3.0.0'}}}
|
537
|
-
end
|
538
|
-
end
|
539
|
-
end # describe RPM::Spec
|
540
|
-
end # module Polisher
|
346
|
+
end # describe Requirement
|
347
|
+
end # module Polisher::RPM
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# Polisher RPM Spec Specs
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
require 'polisher/rpm/spec'
|
9
|
+
require 'polisher/gem'
|
10
|
+
|
11
|
+
module Polisher::RPM
|
12
|
+
describe Spec do
|
13
|
+
describe "#initialize" do
|
14
|
+
it "sets gem metadata" do
|
15
|
+
spec = described_class.new :version => '1.0.0'
|
16
|
+
spec.metadata.should == {:version => '1.0.0'}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#method_missing" do
|
21
|
+
it "proxies lookup to metadata" do
|
22
|
+
spec = described_class.new :version => '1.0.0'
|
23
|
+
spec.version.should == '1.0.0'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#has_check?" do
|
28
|
+
context "package spec has %check section" do
|
29
|
+
it "returns true" do
|
30
|
+
spec = described_class.new :has_check => true
|
31
|
+
spec.has_check?.should be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "package spec does not have a %check section" do
|
36
|
+
it "returns false" do
|
37
|
+
spec = described_class.new
|
38
|
+
spec.has_check?.should be_false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
describe "#requirements_for_gem" do
|
45
|
+
it "returns requirements for specified gem name" do
|
46
|
+
spec = described_class.new :requires =>
|
47
|
+
[Requirement.new(:name => 'rubygem(rake)')]
|
48
|
+
spec.requirements_for_gem('rake').should == [spec.requires.first]
|
49
|
+
end
|
50
|
+
|
51
|
+
context "spec has no requirement with specified name" do
|
52
|
+
it "returns empty array" do
|
53
|
+
spec = described_class.new
|
54
|
+
spec.requirements_for_gem('rake').should be_empty
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#parse" do
|
60
|
+
before(:each) do
|
61
|
+
@spec = Polisher::Test::RPM_SPEC
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns new rpmspec instance" do
|
65
|
+
pspec = described_class.parse @spec[:contents]
|
66
|
+
pspec.should be_an_instance_of(described_class)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "parses contents from spec" do
|
70
|
+
pspec = described_class.parse @spec[:contents]
|
71
|
+
pspec.contents.should == @spec[:contents]
|
72
|
+
end
|
73
|
+
|
74
|
+
it "parses name from spec" do
|
75
|
+
pspec = described_class.parse @spec[:contents]
|
76
|
+
pspec.gem_name.should == @spec[:name]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "parses version from spec" do
|
80
|
+
pspec = described_class.parse @spec[:contents]
|
81
|
+
pspec.version.should == @spec[:version]
|
82
|
+
end
|
83
|
+
|
84
|
+
it "parses release from spec" do
|
85
|
+
pspec = described_class.parse @spec[:contents]
|
86
|
+
pspec.release.should == @spec[:release]
|
87
|
+
end
|
88
|
+
|
89
|
+
it "parses requires from spec" do
|
90
|
+
pspec = described_class.parse @spec[:contents]
|
91
|
+
pspec.requires.should == @spec[:requires]
|
92
|
+
end
|
93
|
+
|
94
|
+
it "parses build requires from spec" do
|
95
|
+
pspec = described_class.parse @spec[:contents]
|
96
|
+
pspec.build_requires.should == @spec[:build_requires]
|
97
|
+
end
|
98
|
+
|
99
|
+
it "parses changelog from spec"
|
100
|
+
|
101
|
+
it "parses unrpmized files from spec" do
|
102
|
+
pspec = described_class.parse @spec[:contents]
|
103
|
+
pspec.files.should == @spec[:files]
|
104
|
+
end
|
105
|
+
|
106
|
+
it "parses %check from spec" do
|
107
|
+
pspec = described_class.parse @spec[:contents]
|
108
|
+
pspec.has_check?.should be_true
|
109
|
+
|
110
|
+
pspec = described_class.parse ""
|
111
|
+
pspec.has_check?.should be_false
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#update_to" do
|
116
|
+
it "updates dependencies from gem" do
|
117
|
+
spec = described_class.new :requires => [Requirement.parse('rubygem(rake)'),
|
118
|
+
Requirement.parse('rubygem(activerecord)')],
|
119
|
+
:build_requires => []
|
120
|
+
gem = Polisher::Gem.new :deps => [::Gem::Dependency.new('rake'),
|
121
|
+
::Gem::Dependency.new('rails', '~> 10')],
|
122
|
+
:dev_deps => [::Gem::Dependency.new('rspec', :development)]
|
123
|
+
|
124
|
+
spec.should_receive(:update_files_from) # stub out files update
|
125
|
+
spec.update_to(gem)
|
126
|
+
spec.requires.should == [Requirement.parse('rubygem(activerecord)'),
|
127
|
+
Requirement.parse('rubygem(rake) >= 0'),
|
128
|
+
Requirement.parse('rubygem(rails) => 10'),
|
129
|
+
Requirement.parse('rubygem(rails) < 11')]
|
130
|
+
spec.build_requires.should == [Requirement.parse('rubygem(rspec) >= 0', :br => true)]
|
131
|
+
end
|
132
|
+
|
133
|
+
it "adds new files from gem" do
|
134
|
+
spec = described_class.new :files => {'pkg' => ['/foo']}
|
135
|
+
gem = Polisher::Gem.new
|
136
|
+
gem.should_receive(:file_paths).at_least(:once).
|
137
|
+
and_return(['/foo', '/foo/bar', '/baz'])
|
138
|
+
spec.update_to(gem)
|
139
|
+
spec.new_files.should == ['/baz']
|
140
|
+
end
|
141
|
+
|
142
|
+
it "updates metadata from gem" do
|
143
|
+
spec = described_class.new
|
144
|
+
gem = Polisher::Gem.new :version => '1.0.0'
|
145
|
+
spec.should_receive(:update_files_from) # stub out files update
|
146
|
+
spec.update_to(gem)
|
147
|
+
spec.version.should == '1.0.0'
|
148
|
+
spec.release.should == '1%{?dist}'
|
149
|
+
end
|
150
|
+
|
151
|
+
it "adds changelog entry"
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#to_string" do
|
155
|
+
it "returns string representation of spec"
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "#compare" do
|
159
|
+
it "returns requirements in spec but not in gem" do
|
160
|
+
req = Requirement.parse 'rubygem(rails) > 3.0.0'
|
161
|
+
spec = described_class.new :requires => [req]
|
162
|
+
gem = Polisher::Gem.new
|
163
|
+
|
164
|
+
spec.compare(gem).should ==
|
165
|
+
{:same => {}, :diff => {'rails' =>
|
166
|
+
{:spec => '> 3.0.0', :upstream => nil}}}
|
167
|
+
end
|
168
|
+
|
169
|
+
it "returns requirements in gem but not in spec" do
|
170
|
+
req = ::Gem::Dependency.new('rails', '> 3.0.0')
|
171
|
+
spec = described_class.new
|
172
|
+
gem = Polisher::Gem.new :deps => [req]
|
173
|
+
|
174
|
+
spec.compare(gem).should ==
|
175
|
+
{:same => {}, :diff => {'rails' =>
|
176
|
+
{:spec => nil, :upstream => '> 3.0.0'}}}
|
177
|
+
end
|
178
|
+
|
179
|
+
it "returns shared requirements with different specifiers" do
|
180
|
+
greq = ::Gem::Dependency.new('rails', '< 5.0.0')
|
181
|
+
gem = Polisher::Gem.new :deps => [greq]
|
182
|
+
|
183
|
+
sreq = Requirement.parse 'rubygem(rails) > 3.0.0'
|
184
|
+
spec = described_class.new :requires => [sreq]
|
185
|
+
|
186
|
+
spec.compare(gem).should ==
|
187
|
+
{:same => {}, :diff => {'rails' =>
|
188
|
+
{:spec => '> 3.0.0', :upstream => '< 5.0.0'}}}
|
189
|
+
end
|
190
|
+
|
191
|
+
it "returns shared requirements" do
|
192
|
+
greq = ::Gem::Dependency.new('rails', '< 3.0.0')
|
193
|
+
gem = Polisher::Gem.new :deps => [greq]
|
194
|
+
|
195
|
+
sreq = Requirement.parse 'rubygem(rails) < 3.0.0'
|
196
|
+
spec = described_class.new :requires => [sreq]
|
197
|
+
|
198
|
+
spec.compare(gem).should ==
|
199
|
+
{:diff => {}, :same => {'rails' =>
|
200
|
+
{:spec => '< 3.0.0', :upstream => '< 3.0.0'}}}
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end # describe Spec
|
204
|
+
end # module Polisher::RPM
|
data/spec/spec_helper.rb
CHANGED
@@ -5,10 +5,22 @@
|
|
5
5
|
|
6
6
|
SPEC_DIR = File.expand_path File.dirname(__FILE__)
|
7
7
|
|
8
|
+
begin
|
9
|
+
require 'coveralls'
|
10
|
+
Coveralls.wear!
|
11
|
+
rescue LoadError
|
12
|
+
end
|
13
|
+
|
8
14
|
require 'polisher/rpm/spec'
|
9
15
|
require 'polisher/gem_cache'
|
10
16
|
|
11
17
|
RSpec.configure do |config|
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = 'random'
|
23
|
+
|
12
24
|
config.after do
|
13
25
|
Polisher::GemCache.clear!
|
14
26
|
end
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Frey
|
8
8
|
- Mo Morsi
|
9
9
|
- Joe Rafaniello
|
10
10
|
- Ken Dreyer
|
11
|
+
- Achilleas Pipinellis
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
|
-
date: 2014-
|
15
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: json
|
@@ -167,13 +168,28 @@ dependencies:
|
|
167
168
|
- - '>='
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: 2.0.0
|
171
|
+
- !ruby/object:Gem::Dependency
|
172
|
+
name: coveralls
|
173
|
+
requirement: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
type: :development
|
179
|
+
prerelease: false
|
180
|
+
version_requirements: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - '>='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
170
185
|
description: General API and utility scripts to manipulate and query ruby gems and
|
171
186
|
projects after being published
|
172
187
|
email:
|
173
|
-
-
|
188
|
+
- fryguy9@gmail.com
|
174
189
|
- mo@morsi.org
|
175
190
|
- jrafanie@redhat.com
|
176
191
|
- ktdreyer@ktdreyer.com
|
192
|
+
- axilleas@archlinux.gr
|
177
193
|
executables:
|
178
194
|
- binary_gem_resolver.rb
|
179
195
|
- gem_dependency_checker.rb
|
@@ -206,6 +222,7 @@ files:
|
|
206
222
|
- lib/polisher/koji.rb
|
207
223
|
- lib/polisher/gem_cache.rb
|
208
224
|
- lib/polisher/rhn.rb
|
225
|
+
- lib/polisher/missing.rb
|
209
226
|
- lib/polisher/yum.rb
|
210
227
|
- lib/polisher.rb
|
211
228
|
- spec/git_spec.rb
|
@@ -213,11 +230,12 @@ files:
|
|
213
230
|
- spec/spec_helper.rb
|
214
231
|
- spec/errata_spec.rb
|
215
232
|
- spec/gemfile_spec.rb
|
233
|
+
- spec/rpm/spec_spec.rb
|
234
|
+
- spec/rpm/requirement_spec.rb
|
216
235
|
- spec/koji_spec.rb
|
217
236
|
- spec/gem_spec.rb
|
218
237
|
- spec/yum_spec.rb
|
219
238
|
- spec/upstream_spec.rb
|
220
|
-
- spec/rpmspec_spec.rb
|
221
239
|
- spec/vendor_spec.rb
|
222
240
|
- spec/fedora_spec.rb
|
223
241
|
- spec/core_spec.rb
|
@@ -254,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
272
|
version: '0'
|
255
273
|
requirements: []
|
256
274
|
rubyforge_project:
|
257
|
-
rubygems_version: 2.0.
|
275
|
+
rubygems_version: 2.0.14
|
258
276
|
signing_key:
|
259
277
|
specification_version: 4
|
260
278
|
summary: Ruby Project Post-Publishing Processor
|