polisher 0.10.2 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/binary_gem_resolver.rb +2 -2
- data/bin/bundler2yum.rb +51 -0
- data/bin/check_ruby_spec.rb +32 -0
- data/bin/gem_dependency_checker.rb +13 -242
- data/bin/gem_mapper.rb +27 -0
- data/bin/gems2update.rb +27 -0
- data/bin/git_gem_diff.rb +48 -0
- data/bin/git_gem_updater.rb +3 -3
- data/bin/missing_deps.rb +29 -0
- data/bin/polisher-config.rb +17 -0
- data/bin/ruby_rpm_spec_updater.rb +23 -2
- data/lib/polisher.rb +5 -12
- data/lib/polisher/adaptors/checker_loader.rb +78 -0
- data/lib/polisher/{upstream.rb → adaptors/upstream.rb} +1 -0
- data/lib/polisher/adaptors/version_checker.rb +57 -0
- data/lib/polisher/adaptors/version_checker/bodhi.rb +29 -0
- data/lib/polisher/adaptors/version_checker/errata.rb +29 -0
- data/lib/polisher/adaptors/version_checker/fedora.rb +29 -0
- data/lib/polisher/adaptors/version_checker/gem.rb +27 -0
- data/lib/polisher/adaptors/version_checker/git.rb +29 -0
- data/lib/polisher/adaptors/version_checker/koji.rb +29 -0
- data/lib/polisher/adaptors/version_checker/yum.rb +29 -0
- data/lib/polisher/cli/all.rb +22 -0
- data/lib/polisher/cli/bin/gem_dependency_checker.rb +85 -0
- data/lib/polisher/cli/bin/gem_mapper.rb +37 -0
- data/lib/polisher/cli/bin/gems2update.rb +86 -0
- data/lib/polisher/cli/bin/missing_deps.rb +35 -0
- data/lib/polisher/cli/conf.rb +18 -0
- data/lib/polisher/cli/default.rb +25 -0
- data/lib/polisher/cli/format.rb +130 -0
- data/lib/polisher/cli/sources.rb +106 -0
- data/lib/polisher/cli/specifier.rb +30 -0
- data/lib/polisher/cli/status.rb +50 -0
- data/lib/polisher/cli/targets.rb +88 -0
- data/lib/polisher/gem.rb +41 -338
- data/lib/polisher/gem/attributes.rb +20 -0
- data/lib/polisher/gem/dependencies.rb +63 -0
- data/lib/polisher/gem/diff.rb +39 -0
- data/lib/polisher/gem/files.rb +111 -0
- data/lib/polisher/gem/parser.rb +85 -0
- data/lib/polisher/gem/retriever.rb +137 -0
- data/lib/polisher/{gem_state.rb → gem/state.rb} +6 -6
- data/lib/polisher/gem/versions.rb +131 -0
- data/lib/polisher/gemfile.rb +20 -89
- data/lib/polisher/gemfile/attributes.rb +19 -0
- data/lib/polisher/gemfile/deps.rb +43 -0
- data/lib/polisher/gemfile/parser.rb +45 -0
- data/lib/polisher/git/pkg.rb +33 -238
- data/lib/polisher/git/pkg/attributes.rb +60 -0
- data/lib/polisher/git/pkg/builder.rb +47 -0
- data/lib/polisher/git/pkg/repo.rb +82 -0
- data/lib/polisher/git/pkg/updater.rb +53 -0
- data/lib/polisher/git/pkg/versions.rb +40 -0
- data/lib/polisher/git/project.rb +1 -1
- data/lib/polisher/git/repo.rb +79 -76
- data/lib/polisher/{vendor.rb → mixins/vendored_deps.rb} +4 -7
- data/lib/polisher/mixins/versioned_dependencies.rb +86 -0
- data/lib/polisher/record.rb +2 -0
- data/lib/polisher/rpm.rb +23 -0
- data/lib/polisher/rpm/patch.rb +10 -8
- data/lib/polisher/rpm/requirement.rb +33 -189
- data/lib/polisher/rpm/requirement/attributes.rb +43 -0
- data/lib/polisher/rpm/requirement/comparison.rb +97 -0
- data/lib/polisher/rpm/requirement/gem_reference.rb +46 -0
- data/lib/polisher/rpm/requirement/parser.rb +41 -0
- data/lib/polisher/rpm/spec.rb +97 -436
- data/lib/polisher/rpm/spec/check.rb +14 -0
- data/lib/polisher/rpm/spec/comparison.rb +64 -0
- data/lib/polisher/rpm/spec/files.rb +15 -0
- data/lib/polisher/rpm/spec/gem_files.rb +65 -0
- data/lib/polisher/rpm/spec/gem_reference.rb +59 -0
- data/lib/polisher/rpm/spec/gem_requirements.rb +73 -0
- data/lib/polisher/rpm/spec/parser.rb +106 -0
- data/lib/polisher/rpm/spec/requirements.rb +31 -0
- data/lib/polisher/rpm/spec/subpackages.rb +23 -0
- data/lib/polisher/rpm/spec/updater.rb +268 -0
- data/lib/polisher/specifier.rb +13 -0
- data/lib/polisher/targets.rb +36 -0
- data/lib/polisher/{apt.rb → targets/apt.rb} +1 -1
- data/lib/polisher/targets/bodhi.rb +43 -0
- data/lib/polisher/{bugzilla.rb → targets/bugzilla.rb} +1 -1
- data/lib/polisher/targets/errata.rb +55 -0
- data/lib/polisher/targets/errata/build.rb +24 -0
- data/lib/polisher/targets/fedora.rb +47 -0
- data/lib/polisher/targets/koji.rb +39 -0
- data/lib/polisher/targets/koji/builder.rb +38 -0
- data/lib/polisher/targets/koji/diff.rb +39 -0
- data/lib/polisher/targets/koji/rpc.rb +43 -0
- data/lib/polisher/targets/koji/versions.rb +67 -0
- data/lib/polisher/targets/rhn.rb +12 -0
- data/lib/polisher/targets/yum.rb +36 -0
- data/lib/polisher/{component.rb → util/component.rb} +3 -3
- data/lib/polisher/util/conf_helpers.rb +77 -0
- data/lib/polisher/util/config.rb +45 -0
- data/lib/polisher/util/core_ext.rb +59 -0
- data/lib/polisher/{error.rb → util/error.rb} +0 -0
- data/lib/polisher/{gem_cache.rb → util/gem_cache.rb} +1 -1
- data/lib/polisher/{git_cache.rb → util/git_cache.rb} +0 -0
- data/lib/polisher/{logger.rb → util/logger.rb} +2 -0
- data/lib/polisher/{tag_mapper.rb → util/tag_mapper.rb} +1 -1
- data/lib/polisher/version.rb +1 -1
- data/spec/{upstream_spec.rb → adaptors/upstream_spec.rb} +1 -1
- data/spec/{version_checker_spec.rb → adaptors/version_checker_spec.rb} +1 -6
- data/spec/data/activesupport-4.1.4.gem +0 -0
- data/spec/data/rubygem-activesupport-with-doc.spec +247 -0
- data/spec/data/rubygem-activesupport-without-requires.spec +232 -0
- data/spec/data/rubygem-activesupport.spec +0 -122
- data/spec/fixtures/gem_json.rb +49 -0
- data/spec/fixtures/gem_spec.rb +13 -0
- data/spec/fixtures/gemfile.rb +10 -0
- data/spec/fixtures/local_gem.rb +62 -0
- data/spec/fixtures/rpm_spec.rb +91 -0
- data/spec/gem/attributes_spec.rb +17 -0
- data/spec/gem/diff_spec.rb +80 -0
- data/spec/gem/files_spec.rb +171 -0
- data/spec/gem/parser_spec.rb +44 -0
- data/spec/gem/retriever_spec.rb +124 -0
- data/spec/gem/state_spec.rb +79 -0
- data/spec/gem/versions_spec.rb +148 -0
- data/spec/gem_spec.rb +5 -347
- data/spec/gemfile/deps_spec.rb +20 -0
- data/spec/gemfile/parser_spec.rb +26 -0
- data/spec/gemfile_spec.rb +0 -34
- data/spec/git/pkg/attributes_spec.rb +128 -0
- data/spec/git/pkg/builder_spec.rb +63 -0
- data/spec/git/pkg/repo_spec.rb +146 -0
- data/spec/git/pkg/updater_spec.rb +86 -0
- data/spec/git/pkg/versions_spec.rb +42 -0
- data/spec/git/pkg_spec.rb +21 -0
- data/spec/git/project_spec.rb +21 -0
- data/spec/git/repo_spec.rb +160 -0
- data/spec/{vendor_spec.rb → mixins/vendored_deps_spec.rb} +2 -4
- data/spec/mixins/versioned_dependencies_spec.rb +48 -0
- data/spec/rpm/patch_spec.rb +48 -0
- data/spec/rpm/requirement/attributes_spec.rb +34 -0
- data/spec/rpm/requirement/comparison_spec.rb +286 -0
- data/spec/rpm/requirement/gem_spec.rb +49 -0
- data/spec/rpm/requirement/parser_spec.rb +31 -0
- data/spec/rpm/requirement_spec.rb +8 -334
- data/spec/rpm/spec/check_spec.rb +25 -0
- data/spec/rpm/spec/comparison_spec.rb +55 -0
- data/spec/rpm/spec/files_spec.rb +17 -0
- data/spec/rpm/spec/gem_files_spec.rb +112 -0
- data/spec/rpm/spec/gem_reference_spec.rb +99 -0
- data/spec/rpm/spec/gem_requirement_spec.rb +38 -0
- data/spec/rpm/spec/parser_spec.rb +64 -0
- data/spec/rpm/spec/requirements_spec.rb +10 -0
- data/spec/rpm/spec/subpackages_spec.rb +38 -0
- data/spec/rpm/spec/updater_spec.rb +486 -0
- data/spec/rpm/spec_spec.rb +27 -174
- data/spec/spec_helper.rb +7 -107
- data/spec/support/coveralls.rb +10 -0
- data/spec/support/fixtures.rb +8 -0
- data/spec/support/paths.rb +20 -0
- data/spec/support/rspec.rb +20 -0
- data/spec/support/vcr.rb +11 -0
- data/spec/{bodhi_spec.rb → targets/bodhi_spec.rb} +3 -1
- data/spec/{errata_spec.rb → targets/errata_spec.rb} +2 -2
- data/spec/{fedora_spec.rb → targets/fedora_spec.rb} +3 -3
- data/spec/targets/koji/builder_spec.rb +48 -0
- data/spec/targets/koji/diff_spec.rb +36 -0
- data/spec/targets/koji/rpc_spec.rb +28 -0
- data/spec/{koji_spec.rb → targets/koji/versions_spec.rb} +1 -59
- data/spec/targets/koji_spec.rb +11 -0
- data/spec/{yum_spec.rb → targets/yum_spec.rb} +1 -1
- data/spec/{component_spec.rb → util/component_spec.rb} +1 -1
- data/spec/{core_spec.rb → util/core_ext_spec.rb} +2 -3
- metadata +278 -88
- data/lib/polisher/bodhi.rb +0 -23
- data/lib/polisher/config.rb +0 -32
- data/lib/polisher/core.rb +0 -101
- data/lib/polisher/errata.rb +0 -75
- data/lib/polisher/fedora.rb +0 -46
- data/lib/polisher/git.rb +0 -8
- data/lib/polisher/koji.rb +0 -159
- data/lib/polisher/rhn.rb +0 -15
- data/lib/polisher/version_checker.rb +0 -177
- data/lib/polisher/yum.rb +0 -37
- data/spec/git_spec.rb +0 -445
@@ -1,12 +1,12 @@
|
|
1
|
-
# Polisher Gem State
|
1
|
+
# Polisher Gem State Mixin
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'polisher/tag_mapper'
|
6
|
+
require 'polisher/util/tag_mapper'
|
7
7
|
|
8
8
|
module Polisher
|
9
|
-
module
|
9
|
+
module GemState
|
10
10
|
def koji_tags
|
11
11
|
Koji.tagged_version_for(name)
|
12
12
|
end
|
@@ -17,7 +17,7 @@ module Polisher
|
|
17
17
|
return :missing if koji_tags.empty?
|
18
18
|
return :available unless check_dep
|
19
19
|
|
20
|
-
koji_tags.each do |
|
20
|
+
koji_tags.each do |_tag, version|
|
21
21
|
return :available if !version.nil? && args[:check].match?(name, version)
|
22
22
|
end
|
23
23
|
|
@@ -31,7 +31,7 @@ module Polisher
|
|
31
31
|
def distgit_branches
|
32
32
|
tags = []
|
33
33
|
|
34
|
-
koji_tags.each do |tag,
|
34
|
+
koji_tags.each do |tag, _version|
|
35
35
|
tag = TagMapper.map(tag)
|
36
36
|
tags << tag unless tag.nil?
|
37
37
|
end
|
@@ -77,7 +77,7 @@ module Polisher
|
|
77
77
|
|
78
78
|
state = distgit_state(args)
|
79
79
|
return :needs_repo if state == :missing_repo
|
80
|
-
return :needs_branch if state == :missing_branch
|
80
|
+
return :needs_branch if state == :missing_branch
|
81
81
|
return :needs_spec if state == :missing_spec
|
82
82
|
return :needs_build if state == :available
|
83
83
|
return :needs_update
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# Polisher Gem Versions Mixin
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
require 'polisher/adaptors/version_checker'
|
7
|
+
|
8
|
+
module Polisher
|
9
|
+
module GemVersions
|
10
|
+
def self.included(base)
|
11
|
+
base.extend(ClassMethods)
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
# Retrieve list of the versions of the specified gem installed locally
|
16
|
+
#
|
17
|
+
# @param [String] name name of the gem to lookup
|
18
|
+
# @param [Callable] bl optional block to invoke with versions retrieved
|
19
|
+
# @return [Array<String>] list of versions of gem installed locally
|
20
|
+
def local_versions_for(name, &bl)
|
21
|
+
silence_warnings do
|
22
|
+
@local_db ||= ::Gem::Specification.all
|
23
|
+
end
|
24
|
+
versions = @local_db.select { |s| s.name == name }.collect { |s| s.version }
|
25
|
+
bl.call(:local_gem, name, versions) unless bl.nil?
|
26
|
+
versions
|
27
|
+
end
|
28
|
+
|
29
|
+
# Retrieve all versions of gem available on rubygems
|
30
|
+
def remote_versions_for(name)
|
31
|
+
require 'json'
|
32
|
+
|
33
|
+
client.url = "https://rubygems.org/api/v1/versions/#{name}.json"
|
34
|
+
client.follow_location = true
|
35
|
+
client.http_get
|
36
|
+
json = JSON.parse(client.body_str)
|
37
|
+
json.collect { |version| version['number'] }
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retieve latest version of gem available on rubygems
|
41
|
+
def latest_version_of(name)
|
42
|
+
remote_versions_for(name).collect { |v| ::Gem::Version.new v }.max.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
# Retrieve versions matching dependency
|
46
|
+
def versions_matching(dep)
|
47
|
+
remote_versions_for(dep.name).select { |v|
|
48
|
+
dep.match? dep.name, v
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Retrieve latest version matching dep
|
53
|
+
def latest_version_matching(dep)
|
54
|
+
version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.max
|
55
|
+
version.nil? ? nil : version.to_s
|
56
|
+
end
|
57
|
+
|
58
|
+
# Retrieve earliest version matching dep
|
59
|
+
def earliest_version_matching(dep)
|
60
|
+
version = versions_matching(dep).collect { |v| ::Gem::Version.new v }.min
|
61
|
+
version.nil? ? nil : version.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
# Retrieve version of gem matching target
|
65
|
+
def version_matching_target(dep, target)
|
66
|
+
version = versions_in_target(dep.name, target).select { |v| dep.match? dep.name, v }
|
67
|
+
.collect { |v| ::Gem::Version.new v }.max
|
68
|
+
version.nil? ? nil : version.to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
# Return versions of gem in target
|
72
|
+
def versions_in_target(name, target)
|
73
|
+
require 'polisher/targets'
|
74
|
+
Polisher.target(target).versions_for(name)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Return latest version of gem in target
|
78
|
+
def latest_version_in_target(name, target)
|
79
|
+
versions_in_target(name, target).collect { |v| ::Gem::Version.new v }.max
|
80
|
+
end
|
81
|
+
end # module ClassMethods
|
82
|
+
|
83
|
+
# Retreive versions of gem available in all configured targets (optionally recursively)
|
84
|
+
#
|
85
|
+
# @param [Hash] args hash of options to configure retrieval
|
86
|
+
# @option args [Boolean] :recursive indicates if versions of dependencies
|
87
|
+
# should also be retrieved
|
88
|
+
# @option args [Boolean] :dev_deps indicates if versions of development
|
89
|
+
# dependencies should also be retrieved
|
90
|
+
# @retrieve versions of all gem dependencies available in configured targets
|
91
|
+
def dependency_versions(args = {}, &bl)
|
92
|
+
versions = args[:versions] || {}
|
93
|
+
check_deps = args[:dev] ? dev_deps : deps
|
94
|
+
|
95
|
+
check_deps.each do |dep|
|
96
|
+
unless versions.key?(dep.name)
|
97
|
+
begin
|
98
|
+
gem = Polisher::Gem.retrieve(dep.name)
|
99
|
+
versions.merge! gem.versions(args, &bl)
|
100
|
+
rescue
|
101
|
+
unknown = Polisher::VersionChecker.unknown_version(:all, dep.name, &bl)
|
102
|
+
versions.merge! dep.name => unknown
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
args[:versions] = versions
|
107
|
+
end
|
108
|
+
|
109
|
+
versions
|
110
|
+
end
|
111
|
+
|
112
|
+
# (and dependencies if specified)
|
113
|
+
def versions(args = {}, &bl)
|
114
|
+
local_args = Hash[args]
|
115
|
+
recursive = local_args[:recursive]
|
116
|
+
dev_deps = local_args[:dev_deps]
|
117
|
+
versions = local_args[:versions] || {}
|
118
|
+
|
119
|
+
gem_versions = Polisher::VersionChecker.versions_for(name, &bl)
|
120
|
+
versions.merge! name => gem_versions
|
121
|
+
local_args[:versions] = versions
|
122
|
+
|
123
|
+
if recursive
|
124
|
+
versions.merge! dependency_versions local_args, &bl
|
125
|
+
versions.merge! dependency_versions local_args.merge(:dev => true), &bl if dev_deps
|
126
|
+
end
|
127
|
+
|
128
|
+
versions
|
129
|
+
end # module ClassMethods
|
130
|
+
end # module GemVersions
|
131
|
+
end # module Polisher
|
data/lib/polisher/gemfile.rb
CHANGED
@@ -1,96 +1,27 @@
|
|
1
|
-
# Polisher Gemfile
|
1
|
+
# Polisher Gemfile
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'polisher/
|
7
|
-
require 'polisher/
|
8
|
-
require 'polisher/
|
9
|
-
require 'polisher/
|
6
|
+
require 'polisher/mixins/versioned_dependencies'
|
7
|
+
require 'polisher/gemfile/attributes'
|
8
|
+
require 'polisher/gemfile/parser'
|
9
|
+
require 'polisher/gemfile/deps'
|
10
10
|
|
11
11
|
module Polisher
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def initialize(args = {})
|
28
|
-
@version = nil
|
29
|
-
@deps = args[:deps]
|
30
|
-
@dev_deps = args[:dev_deps]
|
31
|
-
@definition = args[:definition]
|
32
|
-
@file_paths = []
|
33
|
-
end
|
34
|
-
|
35
|
-
# Parse the specified gemfile & return new Gemfile instance from metadata
|
36
|
-
#
|
37
|
-
# @param [String] path to gemfile to parse
|
38
|
-
# @return [Polisher::Gemfile] gemfile instantiated from parsed metadata
|
39
|
-
def self.parse(path, args = {})
|
40
|
-
groups = args[:groups]
|
41
|
-
|
42
|
-
definition = nil
|
43
|
-
path, gemfile = File.split(path)
|
44
|
-
Dir.chdir(path){
|
45
|
-
begin
|
46
|
-
definition = Bundler::Definition.build(gemfile, nil, false)
|
47
|
-
rescue Bundler::GemfileNotFound
|
48
|
-
raise ArgumentError, "invalid gemfile: #{path}"
|
49
|
-
end
|
50
|
-
}
|
51
|
-
|
52
|
-
metadata = {}
|
53
|
-
metadata[:deps] =
|
54
|
-
definition.dependencies.select { |d|
|
55
|
-
groups.nil? || groups.empty? || # groups not specified
|
56
|
-
groups.any? { |g| d.groups.include?(g.intern) } # dep in any group
|
57
|
-
}
|
58
|
-
|
59
|
-
metadata[:dev_deps] = [] # TODO
|
60
|
-
metadata[:definition] = definition
|
61
|
-
|
62
|
-
new metadata
|
63
|
-
end
|
64
|
-
|
65
|
-
# Simply alias for all dependencies in Gemfile
|
66
|
-
def vendored
|
67
|
-
deps + dev_deps
|
68
|
-
end
|
69
|
-
|
70
|
-
# Retrieve gems which differ from
|
71
|
-
# rubygems.org/other upstream sources
|
72
|
-
def patched
|
73
|
-
vendored.collect do |dep|
|
74
|
-
# TODO: right now just handling git based alternate sources,
|
75
|
-
# should be able to handle other types bundler supports
|
76
|
-
# (path and alternate rubygems src)
|
77
|
-
next unless dep.source.is_a?(Bundler::Source::Git)
|
78
|
-
src = dep.source
|
79
|
-
|
80
|
-
# retrieve gem
|
81
|
-
gem = src.version ?
|
82
|
-
Polisher::Gem.new(:name => dep.name, :version => src.version) :
|
83
|
-
Polisher::Gem.retrieve(dep.name)
|
84
|
-
|
85
|
-
# retrieve dep
|
86
|
-
git = Polisher::Git::Repo.new :url => src.uri
|
87
|
-
git.clone unless git.cloned?
|
88
|
-
git.checkout src.ref if src.ref
|
89
|
-
|
90
|
-
# diff gem against git
|
91
|
-
gem.diff(git.path)
|
92
|
-
end.compact!
|
93
|
-
end
|
94
|
-
end # class Gemfile
|
95
|
-
end # Component.verify("Gemfile")
|
12
|
+
class Gemfile
|
13
|
+
include VersionedDependencies
|
14
|
+
|
15
|
+
include GemfileAttributes
|
16
|
+
include GemfileDeps
|
17
|
+
include GemfileParser
|
18
|
+
|
19
|
+
def initialize(args = {})
|
20
|
+
@version = nil
|
21
|
+
@deps = args[:deps]
|
22
|
+
@dev_deps = args[:dev_deps]
|
23
|
+
@definition = args[:definition]
|
24
|
+
@file_paths = []
|
25
|
+
end
|
26
|
+
end # class Gemfile
|
96
27
|
end # module Polisher
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Polisher Gemfile Attributes Mixin
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
module Polisher
|
7
|
+
module GemfileAttributes
|
8
|
+
# always nil, for interface compatability
|
9
|
+
attr_accessor :version
|
10
|
+
|
11
|
+
attr_accessor :deps
|
12
|
+
attr_accessor :dev_deps
|
13
|
+
|
14
|
+
# always empty array, for interface compatability
|
15
|
+
attr_accessor :file_paths
|
16
|
+
|
17
|
+
attr_accessor :definition
|
18
|
+
end # module GemfileAttributes
|
19
|
+
end # module Polisher
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Polisher Gemfile Deps Mixin
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
require 'polisher/git/repo'
|
7
|
+
require 'polisher/gem'
|
8
|
+
|
9
|
+
module Polisher
|
10
|
+
module GemfileDeps
|
11
|
+
# Simply alias for all dependencies in Gemfile
|
12
|
+
def vendored
|
13
|
+
deps + dev_deps
|
14
|
+
end
|
15
|
+
|
16
|
+
# Retrieve gems which differ from
|
17
|
+
# rubygems.org/other upstream sources
|
18
|
+
def patched
|
19
|
+
vendored.collect do |dep|
|
20
|
+
# TODO: right now just handling git based alternate sources,
|
21
|
+
# should be able to handle other types bundler supports
|
22
|
+
# (path and alternate rubygems src)
|
23
|
+
next unless dep.source.is_a?(Bundler::Source::Git)
|
24
|
+
src = dep.source
|
25
|
+
|
26
|
+
# retrieve gem
|
27
|
+
gem = if src.version
|
28
|
+
Polisher::Gem.new(:name => dep.name, :version => src.version)
|
29
|
+
else
|
30
|
+
Polisher::Gem.retrieve(dep.name)
|
31
|
+
end
|
32
|
+
|
33
|
+
# retrieve dep
|
34
|
+
git = Polisher::Git::Repo.new :url => src.uri
|
35
|
+
git.clone unless git.cloned?
|
36
|
+
git.checkout src.ref if src.ref
|
37
|
+
|
38
|
+
# diff gem against git
|
39
|
+
gem.diff(git.path)
|
40
|
+
end.compact!
|
41
|
+
end
|
42
|
+
end # module GemfileDeps
|
43
|
+
end # module Polisher
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Polisher Gemfile Parser Mixin
|
2
|
+
#
|
3
|
+
# Licensed under the MIT license
|
4
|
+
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
|
+
|
6
|
+
module Polisher
|
7
|
+
module GemfileParser
|
8
|
+
def self.included(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
# Parse the specified gemfile & return new Gemfile instance from metadata
|
14
|
+
#
|
15
|
+
# @param [String] path to gemfile to parse
|
16
|
+
# @return [Polisher::Gemfile] gemfile instantiated from parsed metadata
|
17
|
+
def parse(path, args = {})
|
18
|
+
require 'bundler'
|
19
|
+
|
20
|
+
groups = args[:groups]
|
21
|
+
|
22
|
+
definition = nil
|
23
|
+
path, gemfile = File.split(path)
|
24
|
+
Dir.chdir(path) do
|
25
|
+
begin
|
26
|
+
definition = Bundler::Definition.build(gemfile, nil, false)
|
27
|
+
rescue Bundler::GemfileNotFound
|
28
|
+
raise ArgumentError, "invalid gemfile: #{path}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
metadata = {}
|
33
|
+
metadata[:deps] = definition.dependencies.select do |d|
|
34
|
+
groups.nil? || groups.empty? || # groups not specified
|
35
|
+
groups.any? { |g| d.groups.include?(g.intern) } # dep in any group
|
36
|
+
end
|
37
|
+
|
38
|
+
metadata[:dev_deps] = [] # TODO
|
39
|
+
metadata[:definition] = definition
|
40
|
+
|
41
|
+
new metadata
|
42
|
+
end
|
43
|
+
end # module ClassMethods
|
44
|
+
end # module GemfileParser
|
45
|
+
end # module Polisher
|
data/lib/polisher/git/pkg.rb
CHANGED
@@ -1,248 +1,43 @@
|
|
1
|
-
# Polisher Git
|
1
|
+
# Polisher Git Package (distgit)
|
2
2
|
#
|
3
3
|
# Licensed under the MIT license
|
4
4
|
# Copyright (C) 2013-2014 Red Hat, Inc.
|
5
5
|
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
require 'polisher/error'
|
9
6
|
require 'polisher/git/repo'
|
10
|
-
require 'polisher/
|
11
|
-
require 'polisher/
|
12
|
-
require 'polisher/
|
13
|
-
require 'polisher/
|
7
|
+
require 'polisher/git/pkg/attributes'
|
8
|
+
require 'polisher/git/pkg/repo'
|
9
|
+
require 'polisher/git/pkg/versions'
|
10
|
+
require 'polisher/git/pkg/builder'
|
11
|
+
require 'polisher/git/pkg/updater'
|
14
12
|
|
15
13
|
module Polisher
|
16
14
|
module Git
|
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
|
-
end
|
45
|
-
|
46
|
-
# Return full srpm file name of package
|
47
|
-
def srpm
|
48
|
-
@srpm ||= "#{rpm_name}-#{version}-1.*.src.rpm"
|
49
|
-
end
|
50
|
-
|
51
|
-
# Return full spec file name
|
52
|
-
def spec_file
|
53
|
-
@spec_path ||= "#{rpm_name}.spec"
|
54
|
-
end
|
55
|
-
|
56
|
-
# Return boolean indicating if spec file exists
|
57
|
-
def spec?
|
58
|
-
include? spec_file
|
59
|
-
end
|
60
|
-
|
61
|
-
# Return handle to instance of Polisher::RPM::Spec corresponding to spec
|
62
|
-
def spec
|
63
|
-
@spec, @dirty_spec = nil, false if @dirty_spec
|
64
|
-
@spec ||= in_repo { Polisher::RPM::Spec.parse File.read(spec_file) }
|
65
|
-
end
|
66
|
-
|
67
|
-
# Files representing pkg tracked by git
|
68
|
-
def pkg_files
|
69
|
-
@pkg_files ||= [spec_file, 'sources', '.gitignore']
|
70
|
-
end
|
71
|
-
|
72
|
-
# Override path to reference pkg name
|
73
|
-
# @override
|
74
|
-
def path
|
75
|
-
GitCache.path_for(rpm_name)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Alias orig clone method to git_clone
|
79
|
-
alias :git_clone :clone
|
80
|
-
|
81
|
-
# Override clone to use PKG_PCMD
|
82
|
-
# @override
|
83
|
-
def clone
|
84
|
-
require_cmd! pkg_cmd
|
85
|
-
clobber!
|
86
|
-
Dir.mkdir path unless File.directory? path
|
87
|
-
in_repo do
|
88
|
-
result = AwesomeSpawn.run "#{pkg_cmd} clone #{rpm_name}"
|
89
|
-
raise PolisherError,
|
90
|
-
"could not clone #{rpm_name}" unless result.exit_status == 0
|
91
|
-
|
92
|
-
# pkg_cmd will clone into the rpm_name subdir,
|
93
|
-
# move everything up a dir
|
94
|
-
Dir.foreach("#{rpm_name}/") do |f|
|
95
|
-
orig = "#{rpm_name}/#{f}"
|
96
|
-
skip = ['.', '..'].include?(f)
|
97
|
-
FileUtils.move orig, '.' unless skip
|
98
|
-
end
|
99
|
-
|
100
|
-
FileUtils.rm_rf rpm_name
|
101
|
-
end
|
102
|
-
|
103
|
-
self
|
104
|
-
end
|
105
|
-
|
106
|
-
# Return boolean indicating if package is marked as dead (retired/obsolete/etc)
|
107
|
-
def dead?
|
108
|
-
in_repo { File.exist?('dead.package') }
|
109
|
-
end
|
110
|
-
|
111
|
-
# Fetch specified target or configured fetch_tgt if not specified
|
112
|
-
def fetch(target = nil)
|
113
|
-
target = self.class.fetch_tgts.first if target.nil?
|
114
|
-
clone unless cloned?
|
115
|
-
raise Exception, "Dead package detected" if dead?
|
116
|
-
checkout target
|
117
|
-
reset!
|
118
|
-
pull
|
119
|
-
|
120
|
-
self
|
121
|
-
end
|
122
|
-
|
123
|
-
# Return the valid targets, eg those which we can fetch
|
124
|
-
def valid_targets
|
125
|
-
valid = []
|
126
|
-
self.class.fetch_tgts.collect do |target|
|
127
|
-
begin
|
128
|
-
fetch target
|
129
|
-
valid << target
|
130
|
-
rescue
|
131
|
-
# noop
|
132
|
-
end
|
133
|
-
end
|
134
|
-
valid
|
135
|
-
end
|
136
|
-
|
137
|
-
alias :valid_branches :valid_targets
|
138
|
-
|
139
|
-
def update_metadata(gem)
|
140
|
-
@version = gem.version
|
141
|
-
end
|
142
|
-
|
143
|
-
# Update the local spec to the specified gem version
|
144
|
-
def update_spec_to(gem)
|
145
|
-
in_repo do
|
146
|
-
spec.update_to(gem)
|
147
|
-
File.write(spec_file, spec.to_string)
|
148
|
-
@dirty_spec = true
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
# Generate new sources file
|
153
|
-
def gen_sources_for(gem)
|
154
|
-
require_cmd! md5sum_cmd
|
155
|
-
in_repo do
|
156
|
-
AwesomeSpawn.run "#{md5sum_cmd} #{gem.gem_path} > sources"
|
157
|
-
File.write('sources', File.read('sources').gsub("#{GemCache::DIR}/", ''))
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
# Update git ignore to ignore gem
|
162
|
-
def ignore(gem)
|
163
|
-
in_repo do
|
164
|
-
nl = File.exist?('.gitignore') ? "\n" : ''
|
165
|
-
content = "#{nl}#{gem.name}-#{gem.version}.gem"
|
166
|
-
File.open(".gitignore", 'a') { |f| f.write content }
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# Update the local pkg to specified gem
|
171
|
-
#
|
172
|
-
# @param [Polisher::Gem] gem instance of gem containing metadata to update to
|
173
|
-
def update_to(gem)
|
174
|
-
update_metadata gem
|
175
|
-
update_spec_to gem
|
176
|
-
gen_sources_for gem
|
177
|
-
ignore gem
|
178
|
-
self
|
179
|
-
end
|
180
|
-
|
181
|
-
# Override commit, generate a default msg, always add pkg files
|
182
|
-
# @override
|
183
|
-
def commit(msg = nil)
|
184
|
-
require_cmd! git_cmd
|
185
|
-
in_repo { AwesomeSpawn.run "#{git_cmd} add #{pkg_files.join(' ')}" }
|
186
|
-
super(msg.nil? ? "updated to #{version}" : msg)
|
187
|
-
self
|
188
|
-
end
|
189
|
-
|
190
|
-
# Build the srpm
|
191
|
-
def build_srpm
|
192
|
-
require_cmd! pkg_cmd
|
193
|
-
in_repo do
|
194
|
-
begin
|
195
|
-
gem = spec.upstream_gem
|
196
|
-
FileUtils.rm_f gem.file_name if File.exist?(gem.file_name)
|
197
|
-
FileUtils.ln_s gem.gem_path, gem.file_name
|
198
|
-
result = AwesomeSpawn.run "#{pkg_cmd} srpm"
|
199
|
-
raise result.error unless result.exit_status == 0
|
200
|
-
ensure
|
201
|
-
FileUtils.rm_f gem.file_name if File.exist?(gem.file_name)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
self
|
205
|
-
end
|
206
|
-
|
207
|
-
# Run a scratch build
|
208
|
-
def scratch_build
|
209
|
-
in_repo do
|
210
|
-
Koji.build :srpm => srpm,
|
211
|
-
:scratch => true
|
212
|
-
end
|
213
|
-
self
|
214
|
-
end
|
215
|
-
|
216
|
-
# Build the pkg
|
217
|
-
def build
|
218
|
-
build_srpm
|
219
|
-
scratch_build
|
220
|
-
self
|
221
|
-
end
|
222
|
-
|
223
|
-
# Retrieve list of the versions of the specified package in git
|
224
|
-
#
|
225
|
-
# @param [String] name name of package to lookup
|
226
|
-
# @param [Callable] bl optional block to invoke with version retrieved
|
227
|
-
# @return [Array<String>] versions retrieved, or empty array if none found
|
228
|
-
def self.versions_for(name, &bl)
|
229
|
-
version = nil
|
230
|
-
gitpkg = new :name => name
|
231
|
-
gitpkg.url = "#{dist_git_url}#{gitpkg.rpm_name}.git"
|
232
|
-
versions = []
|
233
|
-
fetch_tgts.each do |tgt|
|
234
|
-
begin
|
235
|
-
gitpkg.fetch tgt
|
236
|
-
versions << gitpkg.spec.version
|
237
|
-
rescue => e
|
238
|
-
logger.warn "error retrieving #{name} from #{gitpkg.url}/#{tgt}(distgit): #{e}"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
bl.call(:git, name, versions) unless bl.nil?
|
243
|
-
versions
|
244
|
-
end
|
245
|
-
end # module Pkg
|
246
|
-
end # Component.verify("Git::Pkg")
|
15
|
+
# Git Based Package
|
16
|
+
class Pkg < Repo
|
17
|
+
extend Logging
|
18
|
+
|
19
|
+
include PkgAttributes
|
20
|
+
include PkgRepo
|
21
|
+
include PkgVersions
|
22
|
+
|
23
|
+
include PkgBuilder
|
24
|
+
include PkgUpdater
|
25
|
+
|
26
|
+
conf_attr :rpm_prefix, 'rubygem-'
|
27
|
+
conf_attr :pkg_cmd, '/usr/bin/fedpkg'
|
28
|
+
conf_attr :md5sum_cmd, '/usr/bin/md5sum'
|
29
|
+
conf_attr :dist_git_url, 'git://pkgs.fedoraproject.org/'
|
30
|
+
conf_attr :fetch_tgt, 'master'
|
31
|
+
|
32
|
+
def self.fetch_tgts
|
33
|
+
[fetch_tgt].flatten
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize(args = {})
|
37
|
+
@name = args[:name]
|
38
|
+
@version = args[:version]
|
39
|
+
super(args)
|
40
|
+
end
|
41
|
+
end # module Pkg
|
247
42
|
end # module Git
|
248
43
|
end # module Polisher
|