polisher 0.6.1 → 0.7.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 +1 -1
- data/bin/binary_gem_resolver.rb +1 -1
- data/bin/gem_dependency_checker.rb +4 -2
- data/bin/git_gem_updater.rb +3 -3
- data/bin/ruby_rpm_spec_updater.rb +2 -3
- data/lib/polisher.rb +1 -1
- data/lib/polisher/apt.rb +1 -1
- data/lib/polisher/bodhi.rb +8 -10
- data/lib/polisher/bugzilla.rb +3 -1
- data/lib/polisher/core.rb +9 -1
- data/lib/polisher/errata.rb +26 -14
- data/lib/polisher/fedora.rb +1 -1
- data/lib/polisher/formatter.rb +1 -0
- data/lib/polisher/gem.rb +124 -39
- data/lib/polisher/gem_cache.rb +34 -0
- data/lib/polisher/gemfile.rb +12 -3
- data/lib/polisher/gemspec.rb +1 -1
- data/lib/polisher/git.rb +166 -68
- data/lib/polisher/git_cache.rb +25 -0
- data/lib/polisher/koji.rb +1 -1
- data/lib/polisher/rhn.rb +1 -1
- data/lib/polisher/rpmspec.rb +263 -25
- data/lib/polisher/upstream.rb +1 -1
- data/lib/polisher/vendor.rb +1 -1
- data/lib/polisher/version.rb +2 -2
- data/lib/polisher/version_checker.rb +6 -1
- data/lib/polisher/yum.rb +1 -1
- data/spec/bodhi_spec.rb +1 -1
- data/spec/core_spec.rb +3 -3
- data/spec/errata_spec.rb +1 -1
- data/spec/fedora_spec.rb +1 -1
- data/spec/gem_spec.rb +159 -17
- data/spec/gemfile_spec.rb +2 -2
- data/spec/git_spec.rb +298 -94
- data/spec/koji_spec.rb +1 -1
- data/spec/rpmspec_spec.rb +435 -6
- data/spec/spec_helper.rb +41 -6
- data/spec/upstream_spec.rb +1 -1
- data/spec/yum_spec.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cccecc84da6d0524db953260dc592ee5424f33b0
|
4
|
+
data.tar.gz: c9dc301daf1b9366e5d62eb68615b9b53004d6a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd10517253ce3ddf2c69a0169d720d52031dc61586078f7598bbd25909057f73aa0b96c4f7610ef996458bc1303b9c2d21381a7a08d338f5a85c7c9a07f5f7fb
|
7
|
+
data.tar.gz: eea79b07d89a0966245a48654967bb49be12e6df13da1c1c15ba1b4c283ca2d85812a46be3d5f6f41bb00e75f83dd72c2b34cee107016744689323f25cbf25a6
|
data/README.md
CHANGED
@@ -136,7 +136,7 @@ The test suite is based on rspec, to run:
|
|
136
136
|
|
137
137
|
## Legal & Other
|
138
138
|
|
139
|
-
Polisher is Licensed under the MIT License, Copyright (C) 2013 Red Hat, Inc.
|
139
|
+
Polisher is Licensed under the MIT License, Copyright (C) 2013-2014 Red Hat, Inc.
|
140
140
|
|
141
141
|
See the commit log for authors of the project. All feedback and contributions
|
142
142
|
are more than welcome.
|
data/bin/binary_gem_resolver.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
# ./binary_gem_resolver.rb <path-to-gem-install>
|
11
11
|
#
|
12
12
|
# Licensed under the MIT license
|
13
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
13
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
14
14
|
###########################################################
|
15
15
|
|
16
16
|
require 'colored'
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# before invoking this script
|
12
12
|
#
|
13
13
|
# Licensed under the MIT license
|
14
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
14
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
15
15
|
###########################################################
|
16
16
|
|
17
17
|
require 'optparse'
|
@@ -33,7 +33,8 @@ conf = { :gemfile => './Gemfile',
|
|
33
33
|
:check_rhn => false,
|
34
34
|
:check_yum => false,
|
35
35
|
:check_bugzilla => false,
|
36
|
-
:check_errata => false
|
36
|
+
:check_errata => false,
|
37
|
+
:check_bodhi => false}
|
37
38
|
|
38
39
|
optparse = OptionParser.new do |opts|
|
39
40
|
opts.on('-h', '--help', 'Display this help screen') do
|
@@ -118,6 +119,7 @@ targets << Polisher::VersionChecker::KOJI_TARGET if conf[:check_koji]
|
|
118
119
|
targets << Polisher::VersionChecker::FEDORA_TARGET if conf[:check_fedora]
|
119
120
|
targets << Polisher::VersionChecker::GIT_TARGET if conf[:check_git]
|
120
121
|
targets << Polisher::VersionChecker::YUM_TARGET if conf[:check_yum]
|
122
|
+
targets << Polisher::VersionChecker::BODHI_TARGET if conf[:check_bodhi]
|
121
123
|
targets = Polisher::VersionChecker::ALL_TARGETS if targets.empty?
|
122
124
|
Polisher::VersionChecker.check targets
|
123
125
|
|
data/bin/git_gem_updater.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# git_gem_updater.rb -n <gem_name>
|
9
9
|
#
|
10
10
|
# Licensed under the MIT License
|
11
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
11
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
12
12
|
|
13
13
|
require 'colored'
|
14
14
|
require 'curb'
|
@@ -61,7 +61,7 @@ Dir.chdir conf[:dir]
|
|
61
61
|
conf[:gems].each do |gem_name|
|
62
62
|
pkg =
|
63
63
|
begin
|
64
|
-
Polisher::GitPackage.
|
64
|
+
Polisher::GitPackage.new(:name => gem_name).clone
|
65
65
|
rescue => e
|
66
66
|
next
|
67
67
|
end
|
@@ -73,7 +73,7 @@ conf[:gems].each do |gem_name|
|
|
73
73
|
|
74
74
|
pkg.build
|
75
75
|
|
76
|
-
unless pkg.has_check?
|
76
|
+
unless pkg.spec.has_check?
|
77
77
|
puts "Warning: no %check section in spec,\
|
78
78
|
manually verify functionality!".bold.red
|
79
79
|
end
|
@@ -13,9 +13,8 @@
|
|
13
13
|
# ruby_rpm_spec_updater.rb <path-to-spec> <optional-source-or-version>
|
14
14
|
#
|
15
15
|
# Licensed under the MIT License
|
16
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
16
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
17
17
|
|
18
|
-
require 'colored'
|
19
18
|
require 'polisher'
|
20
19
|
|
21
20
|
spec_file = ARGV.shift
|
@@ -26,4 +25,4 @@ source = source.nil? ?
|
|
26
25
|
Polisher::Upstream.parse(source)
|
27
26
|
|
28
27
|
rpmspec.update_to(source)
|
29
|
-
puts rpmspec.to_string
|
28
|
+
puts rpmspec.to_string
|
data/lib/polisher.rb
CHANGED
data/lib/polisher/apt.rb
CHANGED
data/lib/polisher/bodhi.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
# Polisher Bodhi Operations
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
+
# XXX issue w/ retreiving packages from pkgwat causing sporadic issues:
|
7
|
+
# https://github.com/fedora-infra/fedora-packages/issues/55
|
8
|
+
|
9
|
+
# fedora pkgwat provides a frontend to bodhi
|
6
10
|
require 'pkgwat'
|
7
11
|
|
8
12
|
module Polisher
|
9
13
|
class Bodhi
|
10
14
|
def self.versions_for(name, &bl)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# fedora pkgwat provides a frontend to bodhi
|
15
|
-
updates = Pkgwat.get_updates("rubygem-#{name}", 'all', 'all') # TODO set timeout
|
16
|
-
updates.reject! { |u|
|
17
|
-
u['stable_version'] == 'None' && u['testing_version'] == "None"
|
18
|
-
}
|
19
|
-
versions = updates.collect { |u| u['stable_version'] }
|
15
|
+
versions = Pkgwat.get_updates("rubygem-#{name}", 'all', 'all').
|
16
|
+
select { |update| update['stable_version'] != 'None' }.
|
17
|
+
collect { |update| update['stable_version'] }
|
20
18
|
bl.call(:bodhi, name, versions) unless(bl.nil?)
|
21
19
|
versions
|
22
20
|
end
|
data/lib/polisher/bugzilla.rb
CHANGED
data/lib/polisher/core.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
# Polisher Core Ruby Extensions
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/rpmspec'
|
7
7
|
|
8
8
|
class String
|
9
|
+
# Return bool indicating if self is a path to a gem
|
9
10
|
def gem?
|
10
11
|
File.extname(self) == ".gem"
|
11
12
|
end
|
12
13
|
|
14
|
+
# Return bool indicating if self is a path to a gemspec
|
13
15
|
def gemspec?
|
14
16
|
File.extname(self) == ".gemspec"
|
15
17
|
end
|
16
18
|
|
19
|
+
# Return bool indicating if self is a path to a Gemfile
|
17
20
|
def gemfile?
|
18
21
|
File.basename(self) == "Gemfile"
|
19
22
|
end
|
20
23
|
|
24
|
+
# Remove and replace all occurances of rpm macros in self with non-rpm
|
25
|
+
# macro correspondents. If no rpm macro is specified macro will
|
26
|
+
# simply be removed
|
21
27
|
def unrpmize
|
22
28
|
fmm = Polisher::RPMSpec::FILE_MACRO_MATCHERS
|
23
29
|
fmr = Polisher::RPMSpec::FILE_MACRO_REPLACEMENTS
|
@@ -26,6 +32,8 @@ class String
|
|
26
32
|
f
|
27
33
|
end
|
28
34
|
|
35
|
+
# Replace all occurrances of non-rpm macro strings in self
|
36
|
+
# with their macro correspondences
|
29
37
|
def rpmize
|
30
38
|
fmr = Polisher::RPMSpec::FILE_MACRO_REPLACEMENTS.invert
|
31
39
|
fmr.keys.inject(self) { |file, r| file.gsub(r, fmr[r]) }
|
data/lib/polisher/errata.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# Polisher Errata Operations
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'json'
|
7
7
|
require 'curb'
|
8
8
|
|
9
9
|
module Polisher
|
10
10
|
class Errata
|
11
|
+
# Initialize/return singleton curl handle to
|
12
|
+
# query errata and set url
|
11
13
|
def self.client(url)
|
12
14
|
@curl ||= begin
|
13
15
|
c = Curl::Easy.new
|
@@ -23,22 +25,32 @@ module Polisher
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def self.versions_for(advisory_url, name, &bl)
|
26
|
-
|
27
|
-
result = self.client(url).get
|
28
|
-
json = JSON.parse result.body_str
|
28
|
+
result = self.client("#{advisory_url}/builds").get
|
29
29
|
versions =
|
30
|
-
|
31
|
-
builds
|
32
|
-
|
33
|
-
|
34
|
-
$1
|
35
|
-
else
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
}
|
39
|
-
}.flatten.compact
|
30
|
+
JSON.parse(result.body_str).collect { |tag, builds|
|
31
|
+
ErrataBuild.builds_matching(builds, name)
|
32
|
+
}.flatten
|
33
|
+
|
40
34
|
bl.call(:errata, name, versions) unless(bl.nil?)
|
41
35
|
versions
|
42
36
|
end
|
43
37
|
end
|
38
|
+
|
39
|
+
class ErrataBuild
|
40
|
+
def self.builds_matching(builds, name)
|
41
|
+
builds.collect { |build|
|
42
|
+
self.build_matches?(build, name) ? self.build_version(build, name) : nil
|
43
|
+
}.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.build_matches?(build, name)
|
47
|
+
pkg,meta = *build.flatten
|
48
|
+
pkg =~ /^rubygem-#{name}-([^-]*)-.*$/
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.build_version(build, name)
|
52
|
+
pkg,meta = *build.flatten
|
53
|
+
pkg.split('-')[2]
|
54
|
+
end
|
55
|
+
end
|
44
56
|
end
|
data/lib/polisher/fedora.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# TODO
|
data/lib/polisher/gem.rb
CHANGED
@@ -1,36 +1,55 @@
|
|
1
1
|
# Polisher Gem Represenation
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
|
-
# Copyright (C) 2013 Red Hat, Inc.
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'curb'
|
7
7
|
require 'json'
|
8
8
|
require 'yaml'
|
9
9
|
require 'tempfile'
|
10
10
|
require 'pathname'
|
11
|
+
require 'fileutils'
|
12
|
+
require 'awesome_spawn'
|
11
13
|
require 'rubygems/installer'
|
12
14
|
require 'active_support/core_ext'
|
13
15
|
|
14
16
|
require 'polisher/version_checker'
|
17
|
+
require 'polisher/gem_cache'
|
15
18
|
|
16
19
|
module Polisher
|
17
20
|
class Gem
|
18
21
|
GEM_CMD = '/usr/bin/gem'
|
22
|
+
DIFF_CMD = '/usr/bin/diff'
|
23
|
+
|
24
|
+
# Common files shipped in gems that we should ignore
|
25
|
+
IGNORE_FILES = ['.gemtest', '.gitignore', '.travis.yml',
|
26
|
+
/.*.gemspec/, /Gemfile.*/, 'Rakefile',
|
27
|
+
/rspec.*/, '.yardopts', '.rvmrc']
|
28
|
+
|
29
|
+
# TODO also mark certain files to be tagged as %{doc}
|
19
30
|
|
20
31
|
attr_accessor :spec
|
21
32
|
attr_accessor :name
|
22
33
|
attr_accessor :version
|
23
34
|
attr_accessor :deps
|
24
35
|
attr_accessor :dev_deps
|
25
|
-
|
36
|
+
|
37
|
+
attr_accessor :path
|
26
38
|
|
27
39
|
def initialize(args={})
|
28
40
|
@spec = args[:spec]
|
29
41
|
@name = args[:name]
|
30
42
|
@version = args[:version]
|
43
|
+
@path = args[:path]
|
31
44
|
@deps = args[:deps] || []
|
32
45
|
@dev_deps = args[:dev_deps] || []
|
33
|
-
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return bool indiicating if the specified file is on the IGNORE_FILES list
|
49
|
+
def self.ignorable_file?(file)
|
50
|
+
IGNORE_FILES.any? do |ignore|
|
51
|
+
ignore.is_a?(Regexp) ? ignore.match(file) : ignore == file
|
52
|
+
end
|
34
53
|
end
|
35
54
|
|
36
55
|
# Retrieve list of the versions of the specified gem installed locally
|
@@ -67,7 +86,7 @@ module Polisher
|
|
67
86
|
|
68
87
|
metadata[:dev_deps] =
|
69
88
|
specj['dependencies']['development'].collect { |d|
|
70
|
-
::Gem::Dependency.new d['name'], d['requirements']
|
89
|
+
::Gem::Dependency.new d['name'], d['requirements'].split(',')
|
71
90
|
}
|
72
91
|
|
73
92
|
elsif args.has_key?(:gemspec)
|
@@ -94,55 +113,80 @@ module Polisher
|
|
94
113
|
end
|
95
114
|
|
96
115
|
# Download the gem and return the binary file contents as a string
|
116
|
+
#
|
97
117
|
# @return [String] binary gem contents
|
98
118
|
def download_gem
|
119
|
+
cached = GemCache.get(@name, @version)
|
120
|
+
return cached unless cached.nil?
|
121
|
+
|
122
|
+
# TODO utilize a singleton curl instance (akin to errata module)
|
99
123
|
gem_path = "https://rubygems.org/gems/#{@name}-#{@version}.gem"
|
100
124
|
curl = Curl::Easy.new(gem_path)
|
101
125
|
curl.follow_location = true
|
102
126
|
curl.http_get
|
103
127
|
gemf = curl.body_str
|
128
|
+
|
129
|
+
GemCache.set(@name, @version, gemf)
|
130
|
+
gemf
|
131
|
+
end
|
132
|
+
|
133
|
+
# Returns path to downloaded gem
|
134
|
+
#
|
135
|
+
# @return [String] path to downloaded gem
|
136
|
+
def downloaded_gem_path
|
137
|
+
# ensure gem is downloaded
|
138
|
+
self.download_gem
|
139
|
+
GemCache.path_for(@name, @version)
|
104
140
|
end
|
105
141
|
|
106
|
-
#
|
107
|
-
def
|
108
|
-
|
109
|
-
tgem = Tempfile.new(@name)
|
110
|
-
tgem.write gemf
|
111
|
-
tgem.close
|
112
|
-
|
113
|
-
@spec = YAML.load `#{GEM_CMD} specification #{tgem.path}`
|
114
|
-
|
115
|
-
# update deps, dev_deps
|
116
|
-
@deps =
|
117
|
-
@spec.dependencies.select { |dep|
|
118
|
-
dep.type == :runtime
|
119
|
-
}.collect { |dep| dep }
|
120
|
-
|
121
|
-
@dev_deps =
|
122
|
-
@spec.dependencies.select { |dep|
|
123
|
-
dep.type == :development
|
124
|
-
}.collect { |dep| dep }
|
142
|
+
# Returns path to gem, either specified one of downloaded one
|
143
|
+
def gem_path
|
144
|
+
@path || downloaded_gem_path
|
125
145
|
end
|
126
146
|
|
127
|
-
#
|
147
|
+
# Unpack files & return unpacked directory
|
128
148
|
#
|
129
|
-
#
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
149
|
+
# If block is specified, it will be invoked
|
150
|
+
# with directory after which directory will be removed
|
151
|
+
def unpack(&bl)
|
152
|
+
dir = nil
|
153
|
+
pkg = ::Gem::Installer.new gem_path, :unpack => true
|
154
|
+
|
155
|
+
if bl
|
156
|
+
Dir.mktmpdir { |dir|
|
157
|
+
pkg.unpack dir
|
158
|
+
bl.call dir
|
159
|
+
}
|
160
|
+
else
|
161
|
+
dir = Dir.mktmpdir
|
139
162
|
pkg.unpack dir
|
163
|
+
end
|
164
|
+
|
165
|
+
dir
|
166
|
+
end
|
167
|
+
|
168
|
+
# Iterate over each file in gem invoking block with path
|
169
|
+
def each_file(&bl)
|
170
|
+
self.unpack do |dir|
|
140
171
|
Pathname(dir).find do |path|
|
141
|
-
|
142
|
-
|
172
|
+
next if path.to_s == dir.to_s
|
173
|
+
bl.call path
|
143
174
|
end
|
144
|
-
|
145
|
-
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# Retrieve the list of paths to files in the gem
|
179
|
+
#
|
180
|
+
# @return [Array<String>] list of files in the gem
|
181
|
+
def file_paths
|
182
|
+
@file_paths ||= begin
|
183
|
+
files = []
|
184
|
+
self.each_file do |path|
|
185
|
+
pathstr = path.to_s.gsub("#{dir}/", '')
|
186
|
+
files << pathstr unless pathstr.blank?
|
187
|
+
end
|
188
|
+
files
|
189
|
+
end
|
146
190
|
end
|
147
191
|
|
148
192
|
# Retrieve gem metadata and contents from rubygems.org
|
@@ -153,7 +197,6 @@ module Polisher
|
|
153
197
|
gem_json_path = "https://rubygems.org/api/v1/gems/#{name}.json"
|
154
198
|
spec = Curl::Easy.http_get(gem_json_path).body_str
|
155
199
|
gem = self.parse spec
|
156
|
-
gem.refresh_files
|
157
200
|
gem
|
158
201
|
end
|
159
202
|
|
@@ -193,5 +236,47 @@ module Polisher
|
|
193
236
|
end
|
194
237
|
versions
|
195
238
|
end
|
239
|
+
|
240
|
+
# Return list of file paths marked as vendored
|
241
|
+
def vendored_file_paths
|
242
|
+
self.file_paths.select { |f| f.include?('vendor/') }
|
243
|
+
end
|
244
|
+
|
245
|
+
# Return list of vendered gems in file list
|
246
|
+
def vendored
|
247
|
+
vendored_file_paths.inject({}){ |v,fp|
|
248
|
+
vendored_file = fp.split('/')
|
249
|
+
vendor_index = vendored_file.index('vendor')
|
250
|
+
|
251
|
+
# only process vendor'd dirs:
|
252
|
+
next v if vendor_index + 2 == vendored_file.size
|
253
|
+
|
254
|
+
vname = vendored_file[vendor_index + 1]
|
255
|
+
vversion = nil
|
256
|
+
# TODO set vversion from version.rb:
|
257
|
+
#vf.last.downcase == 'version.rb'
|
258
|
+
v[vname] = vversion
|
259
|
+
v
|
260
|
+
}
|
261
|
+
end
|
262
|
+
|
263
|
+
# Return diff of content in this gem against other
|
264
|
+
def diff(other)
|
265
|
+
out = nil
|
266
|
+
|
267
|
+
begin
|
268
|
+
this_dir = self.unpack
|
269
|
+
other_dir = other.unpack
|
270
|
+
result = AwesomeSpawn.run("#{DIFF_CMD} -r #{this_dir} #{other_dir}")
|
271
|
+
out = result.output
|
272
|
+
rescue
|
273
|
+
ensure
|
274
|
+
FileUtils.rm_rf this_dir
|
275
|
+
FileUtils.rm_rf other_dir
|
276
|
+
end
|
277
|
+
|
278
|
+
out
|
279
|
+
end
|
280
|
+
|
196
281
|
end # class Gem
|
197
282
|
end # module Polisher
|