polisher 0.7.1 → 0.8.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/bin/binary_gem_resolver.rb +1 -1
- data/bin/gem_dependency_checker.rb +12 -8
- data/bin/git_gem_updater.rb +6 -5
- data/bin/ruby_rpm_spec_updater.rb +1 -1
- data/lib/polisher.rb +3 -1
- data/lib/polisher/core.rb +47 -4
- data/lib/polisher/errata.rb +0 -1
- data/lib/polisher/error.rb +7 -0
- data/lib/polisher/gem.rb +105 -77
- data/lib/polisher/gemfile.rb +43 -27
- data/lib/polisher/git.rb +3 -230
- data/lib/polisher/git/pkg.rb +189 -0
- data/lib/polisher/git/project.rb +23 -0
- data/lib/polisher/git/repo.rb +74 -0
- data/lib/polisher/koji.rb +10 -16
- data/lib/polisher/rpm/patch.rb +44 -0
- data/lib/polisher/rpm/requirement.rb +188 -0
- data/lib/polisher/rpm/spec.rb +381 -0
- data/lib/polisher/vendor.rb +28 -0
- data/lib/polisher/version.rb +1 -1
- data/lib/polisher/version_checker.rb +13 -9
- data/spec/gem_spec.rb +2 -25
- data/spec/gemfile_spec.rb +13 -0
- data/spec/git_spec.rb +34 -10
- data/spec/rpmspec_spec.rb +36 -36
- data/spec/spec_helper.rb +29 -29
- data/spec/vendor_spec.rb +41 -0
- metadata +10 -5
- data/lib/polisher/formatter.rb +0 -1
- data/lib/polisher/gemspec.rb +0 -32
- data/lib/polisher/rpmspec.rb +0 -512
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cde437d4b30595528a08d2127ed32d64458b9910
|
4
|
+
data.tar.gz: 2124dcabfc9cfda82bc6a481163e17e0ef0e6774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46ed5242624caa97426ee83c6b37a21f14253ceab0ccaa026e2154c8936d9594e79c0383cfdb409ddc6a045129a62154b7ee5c695178ac402a9562b858644292
|
7
|
+
data.tar.gz: 029682eb264075bf04c12a8922bc58a3da54622d48bdac446501c87e58b9fe70a87e2ad3bb798c15f2b82a4b8278054e9bc65174b41c0497c078113a4b4184c6
|
data/bin/binary_gem_resolver.rb
CHANGED
@@ -18,13 +18,13 @@ require 'optparse'
|
|
18
18
|
require 'colored'
|
19
19
|
require 'polisher/gem'
|
20
20
|
require 'polisher/gemfile'
|
21
|
-
require 'polisher/gemspec'
|
22
21
|
|
23
22
|
##########################################################
|
24
23
|
|
25
24
|
conf = { :gemfile => './Gemfile',
|
26
25
|
:gemspec => nil,
|
27
26
|
:gemname => nil,
|
27
|
+
:groups => [],
|
28
28
|
:devel_deps => false,
|
29
29
|
:highlight_missing => false,
|
30
30
|
:check_fedora => false,
|
@@ -46,6 +46,10 @@ optparse = OptionParser.new do |opts|
|
|
46
46
|
conf[:gemfile] = g
|
47
47
|
end
|
48
48
|
|
49
|
+
opts.on('--group gemfile_groups', 'Gemfile groups (may be specified multiple times)') do |g|
|
50
|
+
conf[:groups] << g
|
51
|
+
end
|
52
|
+
|
49
53
|
opts.on('--gemspec file', 'Location of the gemspec to parse') do |g|
|
50
54
|
conf[:gemspec] = g
|
51
55
|
end
|
@@ -145,11 +149,17 @@ if conf[:gemname]
|
|
145
149
|
print_dep(tgt, dep, versions)
|
146
150
|
end
|
147
151
|
|
152
|
+
elsif conf[:gemspec]
|
153
|
+
gem = Polisher::Gem.from_gemspec(conf[:gemspec])
|
154
|
+
gem.versions(:recursive => true, :dev_deps => true) do |tgt, dep, versions|
|
155
|
+
print_dep(tgt, dep, versions)
|
156
|
+
end
|
157
|
+
|
148
158
|
elsif conf[:gemfile]
|
149
159
|
gemfile = nil
|
150
160
|
|
151
161
|
begin
|
152
|
-
gemfile = Polisher::Gemfile.parse(conf[:gemfile])
|
162
|
+
gemfile = Polisher::Gemfile.parse(conf[:gemfile], :groups => conf[:groups])
|
153
163
|
rescue => e
|
154
164
|
puts "Runtime err #{e}".red
|
155
165
|
exit 1
|
@@ -158,10 +168,4 @@ elsif conf[:gemfile]
|
|
158
168
|
gemfile.dependency_versions do |tgt, dep, versions|
|
159
169
|
print_dep(tgt, dep, versions)
|
160
170
|
end
|
161
|
-
|
162
|
-
elsif conf[:gemspec]
|
163
|
-
gemspec = Polisher::Gemspec.parse(conf[:gemspec])
|
164
|
-
gemspec.dependency_versions do |tgt, dep, versions|
|
165
|
-
print_dep(tgt, dep, versions)
|
166
|
-
end
|
167
171
|
end
|
data/bin/git_gem_updater.rb
CHANGED
@@ -61,26 +61,27 @@ Dir.chdir conf[:dir]
|
|
61
61
|
conf[:gems].each do |gem_name|
|
62
62
|
pkg =
|
63
63
|
begin
|
64
|
-
Polisher::
|
64
|
+
Polisher::Git::Pkg.new(:name => gem_name).clone
|
65
65
|
rescue => e
|
66
|
+
puts "Problem Cloning Package, Skipping: #{e}"
|
66
67
|
next
|
67
68
|
end
|
68
69
|
|
69
70
|
gem = Polisher::Gem.retrieve gem_name
|
70
|
-
File.write("#{gem.name}-#{gem.version}.gem", gem.download_gem)
|
71
71
|
pkg.update_to(gem)
|
72
72
|
# TODO append gem dependencies to conf[:gems] list
|
73
73
|
|
74
74
|
pkg.build
|
75
75
|
|
76
76
|
unless pkg.spec.has_check?
|
77
|
-
puts "Warning: no %check section in spec
|
78
|
-
|
77
|
+
puts "Warning: no %check section in spec, "\
|
78
|
+
"manually verify functionality!".bold.red
|
79
79
|
end
|
80
80
|
|
81
81
|
pkg.commit
|
82
82
|
|
83
83
|
puts "#{gem_name} commit complete".green
|
84
|
+
puts "Package located in #{pkg.path.bold}"
|
84
85
|
puts "Push commit with: git push".blue
|
85
|
-
puts "Build and tag official rpms with: #{Polisher::
|
86
|
+
puts "Build and tag official rpms with: #{Polisher::Git::Pkg.pkg_cmd} build".blue
|
86
87
|
end
|
@@ -19,7 +19,7 @@ require 'polisher'
|
|
19
19
|
|
20
20
|
spec_file = ARGV.shift
|
21
21
|
source = ARGV.shift
|
22
|
-
rpmspec = Polisher::
|
22
|
+
rpmspec = Polisher::RPM::Spec.parse File.read(spec_file)
|
23
23
|
source = source.nil? ?
|
24
24
|
Polisher::Gem.retrieve(rpmspec.gem_name) :
|
25
25
|
Polisher::Upstream.parse(source)
|
data/lib/polisher.rb
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
6
|
require 'polisher/core'
|
7
|
-
require 'polisher/
|
7
|
+
require 'polisher/error'
|
8
|
+
require 'polisher/rpm/requirement'
|
9
|
+
require 'polisher/rpm/spec'
|
8
10
|
require 'polisher/gem'
|
9
11
|
require 'polisher/upstream'
|
10
12
|
require 'polisher/gemfile'
|
data/lib/polisher/core.rb
CHANGED
@@ -3,7 +3,50 @@
|
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
|
6
|
+
class Object
|
7
|
+
def eigenclass
|
8
|
+
class << self
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ConfHelpers
|
15
|
+
# Defines a 'config attribute' or attribute on the class
|
16
|
+
# which this is defined in. Accessors to the single shared
|
17
|
+
# attribute will be added to the class as well as instances
|
18
|
+
# of the class. Specify the default value with the attr name
|
19
|
+
# or via an env variable
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# class Custom
|
23
|
+
# extend ConfHelpers
|
24
|
+
# conf_attr :data_dir, '/etc/'
|
25
|
+
# end
|
26
|
+
# Custom.data_dir # => '/etc/'
|
27
|
+
# ENV['POLISHER_DATA_DIR'] = '/usr/'
|
28
|
+
# Custom.data_dir # => '/usr/'
|
29
|
+
# Custom.data_dir == Custom.new.data_dir # => true
|
30
|
+
#
|
31
|
+
def conf_attr(name, default=nil)
|
32
|
+
self.send(:define_singleton_method, name) do |*args|
|
33
|
+
nvar = "@#{name}".intern
|
34
|
+
current = self.instance_variable_get(nvar)
|
35
|
+
envk = "POLISHER_#{name.to_s.upcase}"
|
36
|
+
self.instance_variable_set(nvar, default) unless current
|
37
|
+
self.instance_variable_set(ENV[envk]) if ENV.has_key?(envk)
|
38
|
+
# TODO also allow vars to be able to be set from a conf file
|
39
|
+
self.instance_variable_set(nvar, args.first) unless args.empty?
|
40
|
+
self.instance_variable_get(nvar)
|
41
|
+
end
|
42
|
+
|
43
|
+
self.send(:define_method, name) do
|
44
|
+
self.class.send(name)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'polisher/rpm/spec'
|
7
50
|
|
8
51
|
class String
|
9
52
|
# Return bool indicating if self is a path to a gem
|
@@ -25,8 +68,8 @@ class String
|
|
25
68
|
# macro correspondents. If no rpm macro is specified macro will
|
26
69
|
# simply be removed
|
27
70
|
def unrpmize
|
28
|
-
fmm = Polisher::
|
29
|
-
fmr = Polisher::
|
71
|
+
fmm = Polisher::RPM::Spec::FILE_MACRO_MATCHERS
|
72
|
+
fmr = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS
|
30
73
|
f = fmm.inject(self) { |file, matcher| file.gsub(matcher, '') }
|
31
74
|
f = fmr.keys.inject(f) { |file, r| file.gsub(Regexp.new(r), fmr[r]) }
|
32
75
|
f
|
@@ -35,7 +78,7 @@ class String
|
|
35
78
|
# Replace all occurrances of non-rpm macro strings in self
|
36
79
|
# with their macro correspondences
|
37
80
|
def rpmize
|
38
|
-
fmr = Polisher::
|
81
|
+
fmr = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS.invert
|
39
82
|
fmr.keys.inject(self) { |file, r| file.gsub(r, fmr[r]) }
|
40
83
|
end
|
41
84
|
end
|
data/lib/polisher/errata.rb
CHANGED
data/lib/polisher/gem.rb
CHANGED
@@ -15,9 +15,12 @@ require 'active_support/core_ext'
|
|
15
15
|
|
16
16
|
require 'polisher/version_checker'
|
17
17
|
require 'polisher/gem_cache'
|
18
|
+
require 'polisher/vendor'
|
18
19
|
|
19
20
|
module Polisher
|
20
21
|
class Gem
|
22
|
+
include HasVendoredDeps
|
23
|
+
|
21
24
|
GEM_CMD = '/usr/bin/gem'
|
22
25
|
DIFF_CMD = '/usr/bin/diff'
|
23
26
|
|
@@ -64,6 +67,58 @@ module Polisher
|
|
64
67
|
versions
|
65
68
|
end
|
66
69
|
|
70
|
+
# Return new instance of Gem from JSON Specification
|
71
|
+
def self.from_json(json)
|
72
|
+
specj = JSON.parse(json)
|
73
|
+
metadata = {}
|
74
|
+
metadata[:spec] = specj
|
75
|
+
metadata[:name] = specj['name']
|
76
|
+
metadata[:version] = specj['version']
|
77
|
+
|
78
|
+
metadata[:deps] =
|
79
|
+
specj['dependencies']['runtime'].collect { |d|
|
80
|
+
::Gem::Dependency.new d['name'], *d['requirements'].split(',')
|
81
|
+
}
|
82
|
+
|
83
|
+
metadata[:dev_deps] =
|
84
|
+
specj['dependencies']['development'].collect { |d|
|
85
|
+
::Gem::Dependency.new d['name'], d['requirements'].split(',')
|
86
|
+
}
|
87
|
+
|
88
|
+
self.new metadata
|
89
|
+
end
|
90
|
+
|
91
|
+
# Return new instance of Gem from Gemspec
|
92
|
+
def self.from_gemspec(gemspec)
|
93
|
+
gemspec =
|
94
|
+
::Gem::Specification.load(gemspec) if !gemspec.is_a?(::Gem::Specification) &&
|
95
|
+
File.exists?(gemspec)
|
96
|
+
|
97
|
+
metadata = {}
|
98
|
+
metadata[:spec] = gemspec
|
99
|
+
metadata[:name] = gemspec.name
|
100
|
+
metadata[:version] = gemspec.version.to_s
|
101
|
+
|
102
|
+
metadata[:deps] =
|
103
|
+
gemspec.dependencies.select { |dep|
|
104
|
+
dep.type == :runtime
|
105
|
+
}.collect { |dep| dep }
|
106
|
+
|
107
|
+
metadata[:dev_deps] =
|
108
|
+
gemspec.dependencies.select { |dep|
|
109
|
+
dep.type == :development
|
110
|
+
}.collect { |dep| dep }
|
111
|
+
|
112
|
+
self.new metadata
|
113
|
+
end
|
114
|
+
|
115
|
+
# Return new instance of Gem from rubygem
|
116
|
+
def self.from_gem(gem_path)
|
117
|
+
gem = self.parse :gemspec => ::Gem::Package.new(gem_path).spec
|
118
|
+
gem.path = gem_path
|
119
|
+
gem
|
120
|
+
end
|
121
|
+
|
67
122
|
# Parse the specified gemspec & return new Gem instance from metadata
|
68
123
|
#
|
69
124
|
# @param [String,Hash] args contents of actual gemspec of option hash
|
@@ -71,72 +126,65 @@ module Polisher
|
|
71
126
|
# @option args [String] :gemspec path to gemspec to load / parse
|
72
127
|
# @return [Polisher::Gem] gem instantiated from gemspec metadata
|
73
128
|
def self.parse(args={})
|
74
|
-
metadata = {}
|
75
|
-
|
76
129
|
if args.is_a?(String)
|
77
|
-
|
78
|
-
metadata[:spec] = specj
|
79
|
-
metadata[:name] = specj['name']
|
80
|
-
metadata[:version] = specj['version']
|
81
|
-
|
82
|
-
metadata[:deps] =
|
83
|
-
specj['dependencies']['runtime'].collect { |d|
|
84
|
-
::Gem::Dependency.new d['name'], *d['requirements'].split(',')
|
85
|
-
}
|
86
|
-
|
87
|
-
metadata[:dev_deps] =
|
88
|
-
specj['dependencies']['development'].collect { |d|
|
89
|
-
::Gem::Dependency.new d['name'], d['requirements'].split(',')
|
90
|
-
}
|
130
|
+
return self.from_json args
|
91
131
|
|
92
132
|
elsif args.has_key?(:gemspec)
|
93
|
-
|
94
|
-
metadata[:spec] = gemspec # TODO to json
|
95
|
-
metadata[:name] = gemspec.name
|
96
|
-
metadata[:version] = gemspec.version.to_s
|
97
|
-
|
98
|
-
metadata[:deps] =
|
99
|
-
gemspec.dependencies.select { |dep|
|
100
|
-
dep.type == :runtime
|
101
|
-
}.collect { |dep| dep }
|
102
|
-
|
103
|
-
metadata[:dev_deps] =
|
104
|
-
gemspec.dependencies.select { |dep|
|
105
|
-
dep.type == :development
|
106
|
-
}.collect { |dep| dep }
|
133
|
+
return self.from_gemspec args[:gemspec]
|
107
134
|
|
108
135
|
elsif args.has_key?(:gem)
|
109
|
-
|
136
|
+
return self.from_gem args[:gem]
|
137
|
+
|
110
138
|
end
|
111
139
|
|
112
|
-
self.new
|
140
|
+
self.new
|
113
141
|
end
|
114
142
|
|
115
|
-
#
|
143
|
+
# Return handler to internal curl helper
|
144
|
+
def self.client
|
145
|
+
@client ||= Curl::Easy.new
|
146
|
+
end
|
147
|
+
|
148
|
+
# Download the specified gem and return the binary file contents as a string
|
116
149
|
#
|
117
150
|
# @return [String] binary gem contents
|
118
|
-
def download_gem
|
119
|
-
cached = GemCache.get(
|
151
|
+
def self.download_gem(name, version)
|
152
|
+
cached = GemCache.get(name, version)
|
120
153
|
return cached unless cached.nil?
|
121
154
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
curl.http_get
|
127
|
-
gemf = curl.body_str
|
155
|
+
client.url = "https://rubygems.org/gems/#{name}-#{version}.gem"
|
156
|
+
client.follow_location = true
|
157
|
+
client.http_get
|
158
|
+
gemf = client.body_str
|
128
159
|
|
129
|
-
GemCache.set(
|
160
|
+
GemCache.set(name, version, gemf)
|
130
161
|
gemf
|
131
162
|
end
|
132
163
|
|
164
|
+
# Download the local gem and return it as a string
|
165
|
+
def download_gem
|
166
|
+
self.class.download_gem @name, @version
|
167
|
+
end
|
168
|
+
|
169
|
+
# Download the specified gem / version from rubygems and
|
170
|
+
# return instance of Polisher::Gem class corresponding to it
|
171
|
+
def self.from_rubygems(name, version)
|
172
|
+
download_gem name, version
|
173
|
+
self.from_gem downloaded_gem_path(name, version)
|
174
|
+
end
|
175
|
+
|
133
176
|
# Returns path to downloaded gem
|
134
177
|
#
|
135
178
|
# @return [String] path to downloaded gem
|
136
|
-
def downloaded_gem_path
|
179
|
+
def self.downloaded_gem_path(name, version)
|
137
180
|
# ensure gem is downloaded
|
138
|
-
self.download_gem
|
139
|
-
GemCache.path_for(
|
181
|
+
self.download_gem(name, version)
|
182
|
+
GemCache.path_for(name, version)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Return path to downloaded gem
|
186
|
+
def downloaded_gem_path
|
187
|
+
self.class.downloaded_gem_path @name, @version
|
140
188
|
end
|
141
189
|
|
142
190
|
# Returns path to gem, either specified one of downloaded one
|
@@ -170,7 +218,8 @@ module Polisher
|
|
170
218
|
self.unpack do |dir|
|
171
219
|
Pathname(dir).find do |path|
|
172
220
|
next if path.to_s == dir.to_s
|
173
|
-
|
221
|
+
pathstr = path.to_s.gsub("#{dir}/", '')
|
222
|
+
bl.call pathstr unless pathstr.blank?
|
174
223
|
end
|
175
224
|
end
|
176
225
|
end
|
@@ -182,8 +231,7 @@ module Polisher
|
|
182
231
|
@file_paths ||= begin
|
183
232
|
files = []
|
184
233
|
self.each_file do |path|
|
185
|
-
|
186
|
-
files << pathstr unless pathstr.blank?
|
234
|
+
files << path
|
187
235
|
end
|
188
236
|
files
|
189
237
|
end
|
@@ -212,9 +260,10 @@ module Polisher
|
|
212
260
|
def versions(args={}, &bl)
|
213
261
|
recursive = args[:recursive]
|
214
262
|
dev_deps = args[:dev_deps]
|
215
|
-
|
216
263
|
versions = args[:versions] || {}
|
217
|
-
|
264
|
+
|
265
|
+
gem_versions = Polisher::VersionChecker.versions_for(self.name, &bl)
|
266
|
+
versions.merge!({ self.name => gem_versions })
|
218
267
|
args[:versions] = versions
|
219
268
|
|
220
269
|
if recursive
|
@@ -237,42 +286,21 @@ module Polisher
|
|
237
286
|
versions
|
238
287
|
end
|
239
288
|
|
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
289
|
# Return diff of content in this gem against other
|
264
290
|
def diff(other)
|
265
291
|
out = nil
|
266
292
|
|
267
293
|
begin
|
268
294
|
this_dir = self.unpack
|
269
|
-
other_dir = other.unpack
|
295
|
+
other_dir = other.is_a?(Polisher::Gem) ? other.unpack :
|
296
|
+
(other.is_a?(Polisher::Git::Repo) ? other.path : other)
|
270
297
|
result = AwesomeSpawn.run("#{DIFF_CMD} -r #{this_dir} #{other_dir}")
|
271
|
-
out = result.output
|
298
|
+
out = result.output.gsub("#{this_dir}", 'a').gsub("#{other_dir}", 'b')
|
272
299
|
rescue
|
273
300
|
ensure
|
274
|
-
FileUtils.rm_rf this_dir
|
275
|
-
FileUtils.rm_rf other_dir
|
301
|
+
FileUtils.rm_rf this_dir unless this_dir.nil?
|
302
|
+
FileUtils.rm_rf other_dir unless other_dir.nil? ||
|
303
|
+
!other.is_a?(Polisher::Gem)
|
276
304
|
end
|
277
305
|
|
278
306
|
out
|