polisher 0.10.2 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/bin/binary_gem_resolver.rb +2 -2
  3. data/bin/bundler2yum.rb +51 -0
  4. data/bin/check_ruby_spec.rb +32 -0
  5. data/bin/gem_dependency_checker.rb +13 -242
  6. data/bin/gem_mapper.rb +27 -0
  7. data/bin/gems2update.rb +27 -0
  8. data/bin/git_gem_diff.rb +48 -0
  9. data/bin/git_gem_updater.rb +3 -3
  10. data/bin/missing_deps.rb +29 -0
  11. data/bin/polisher-config.rb +17 -0
  12. data/bin/ruby_rpm_spec_updater.rb +23 -2
  13. data/lib/polisher.rb +5 -12
  14. data/lib/polisher/adaptors/checker_loader.rb +78 -0
  15. data/lib/polisher/{upstream.rb → adaptors/upstream.rb} +1 -0
  16. data/lib/polisher/adaptors/version_checker.rb +57 -0
  17. data/lib/polisher/adaptors/version_checker/bodhi.rb +29 -0
  18. data/lib/polisher/adaptors/version_checker/errata.rb +29 -0
  19. data/lib/polisher/adaptors/version_checker/fedora.rb +29 -0
  20. data/lib/polisher/adaptors/version_checker/gem.rb +27 -0
  21. data/lib/polisher/adaptors/version_checker/git.rb +29 -0
  22. data/lib/polisher/adaptors/version_checker/koji.rb +29 -0
  23. data/lib/polisher/adaptors/version_checker/yum.rb +29 -0
  24. data/lib/polisher/cli/all.rb +22 -0
  25. data/lib/polisher/cli/bin/gem_dependency_checker.rb +85 -0
  26. data/lib/polisher/cli/bin/gem_mapper.rb +37 -0
  27. data/lib/polisher/cli/bin/gems2update.rb +86 -0
  28. data/lib/polisher/cli/bin/missing_deps.rb +35 -0
  29. data/lib/polisher/cli/conf.rb +18 -0
  30. data/lib/polisher/cli/default.rb +25 -0
  31. data/lib/polisher/cli/format.rb +130 -0
  32. data/lib/polisher/cli/sources.rb +106 -0
  33. data/lib/polisher/cli/specifier.rb +30 -0
  34. data/lib/polisher/cli/status.rb +50 -0
  35. data/lib/polisher/cli/targets.rb +88 -0
  36. data/lib/polisher/gem.rb +41 -338
  37. data/lib/polisher/gem/attributes.rb +20 -0
  38. data/lib/polisher/gem/dependencies.rb +63 -0
  39. data/lib/polisher/gem/diff.rb +39 -0
  40. data/lib/polisher/gem/files.rb +111 -0
  41. data/lib/polisher/gem/parser.rb +85 -0
  42. data/lib/polisher/gem/retriever.rb +137 -0
  43. data/lib/polisher/{gem_state.rb → gem/state.rb} +6 -6
  44. data/lib/polisher/gem/versions.rb +131 -0
  45. data/lib/polisher/gemfile.rb +20 -89
  46. data/lib/polisher/gemfile/attributes.rb +19 -0
  47. data/lib/polisher/gemfile/deps.rb +43 -0
  48. data/lib/polisher/gemfile/parser.rb +45 -0
  49. data/lib/polisher/git/pkg.rb +33 -238
  50. data/lib/polisher/git/pkg/attributes.rb +60 -0
  51. data/lib/polisher/git/pkg/builder.rb +47 -0
  52. data/lib/polisher/git/pkg/repo.rb +82 -0
  53. data/lib/polisher/git/pkg/updater.rb +53 -0
  54. data/lib/polisher/git/pkg/versions.rb +40 -0
  55. data/lib/polisher/git/project.rb +1 -1
  56. data/lib/polisher/git/repo.rb +79 -76
  57. data/lib/polisher/{vendor.rb → mixins/vendored_deps.rb} +4 -7
  58. data/lib/polisher/mixins/versioned_dependencies.rb +86 -0
  59. data/lib/polisher/record.rb +2 -0
  60. data/lib/polisher/rpm.rb +23 -0
  61. data/lib/polisher/rpm/patch.rb +10 -8
  62. data/lib/polisher/rpm/requirement.rb +33 -189
  63. data/lib/polisher/rpm/requirement/attributes.rb +43 -0
  64. data/lib/polisher/rpm/requirement/comparison.rb +97 -0
  65. data/lib/polisher/rpm/requirement/gem_reference.rb +46 -0
  66. data/lib/polisher/rpm/requirement/parser.rb +41 -0
  67. data/lib/polisher/rpm/spec.rb +97 -436
  68. data/lib/polisher/rpm/spec/check.rb +14 -0
  69. data/lib/polisher/rpm/spec/comparison.rb +64 -0
  70. data/lib/polisher/rpm/spec/files.rb +15 -0
  71. data/lib/polisher/rpm/spec/gem_files.rb +65 -0
  72. data/lib/polisher/rpm/spec/gem_reference.rb +59 -0
  73. data/lib/polisher/rpm/spec/gem_requirements.rb +73 -0
  74. data/lib/polisher/rpm/spec/parser.rb +106 -0
  75. data/lib/polisher/rpm/spec/requirements.rb +31 -0
  76. data/lib/polisher/rpm/spec/subpackages.rb +23 -0
  77. data/lib/polisher/rpm/spec/updater.rb +268 -0
  78. data/lib/polisher/specifier.rb +13 -0
  79. data/lib/polisher/targets.rb +36 -0
  80. data/lib/polisher/{apt.rb → targets/apt.rb} +1 -1
  81. data/lib/polisher/targets/bodhi.rb +43 -0
  82. data/lib/polisher/{bugzilla.rb → targets/bugzilla.rb} +1 -1
  83. data/lib/polisher/targets/errata.rb +55 -0
  84. data/lib/polisher/targets/errata/build.rb +24 -0
  85. data/lib/polisher/targets/fedora.rb +47 -0
  86. data/lib/polisher/targets/koji.rb +39 -0
  87. data/lib/polisher/targets/koji/builder.rb +38 -0
  88. data/lib/polisher/targets/koji/diff.rb +39 -0
  89. data/lib/polisher/targets/koji/rpc.rb +43 -0
  90. data/lib/polisher/targets/koji/versions.rb +67 -0
  91. data/lib/polisher/targets/rhn.rb +12 -0
  92. data/lib/polisher/targets/yum.rb +36 -0
  93. data/lib/polisher/{component.rb → util/component.rb} +3 -3
  94. data/lib/polisher/util/conf_helpers.rb +77 -0
  95. data/lib/polisher/util/config.rb +45 -0
  96. data/lib/polisher/util/core_ext.rb +59 -0
  97. data/lib/polisher/{error.rb → util/error.rb} +0 -0
  98. data/lib/polisher/{gem_cache.rb → util/gem_cache.rb} +1 -1
  99. data/lib/polisher/{git_cache.rb → util/git_cache.rb} +0 -0
  100. data/lib/polisher/{logger.rb → util/logger.rb} +2 -0
  101. data/lib/polisher/{tag_mapper.rb → util/tag_mapper.rb} +1 -1
  102. data/lib/polisher/version.rb +1 -1
  103. data/spec/{upstream_spec.rb → adaptors/upstream_spec.rb} +1 -1
  104. data/spec/{version_checker_spec.rb → adaptors/version_checker_spec.rb} +1 -6
  105. data/spec/data/activesupport-4.1.4.gem +0 -0
  106. data/spec/data/rubygem-activesupport-with-doc.spec +247 -0
  107. data/spec/data/rubygem-activesupport-without-requires.spec +232 -0
  108. data/spec/data/rubygem-activesupport.spec +0 -122
  109. data/spec/fixtures/gem_json.rb +49 -0
  110. data/spec/fixtures/gem_spec.rb +13 -0
  111. data/spec/fixtures/gemfile.rb +10 -0
  112. data/spec/fixtures/local_gem.rb +62 -0
  113. data/spec/fixtures/rpm_spec.rb +91 -0
  114. data/spec/gem/attributes_spec.rb +17 -0
  115. data/spec/gem/diff_spec.rb +80 -0
  116. data/spec/gem/files_spec.rb +171 -0
  117. data/spec/gem/parser_spec.rb +44 -0
  118. data/spec/gem/retriever_spec.rb +124 -0
  119. data/spec/gem/state_spec.rb +79 -0
  120. data/spec/gem/versions_spec.rb +148 -0
  121. data/spec/gem_spec.rb +5 -347
  122. data/spec/gemfile/deps_spec.rb +20 -0
  123. data/spec/gemfile/parser_spec.rb +26 -0
  124. data/spec/gemfile_spec.rb +0 -34
  125. data/spec/git/pkg/attributes_spec.rb +128 -0
  126. data/spec/git/pkg/builder_spec.rb +63 -0
  127. data/spec/git/pkg/repo_spec.rb +146 -0
  128. data/spec/git/pkg/updater_spec.rb +86 -0
  129. data/spec/git/pkg/versions_spec.rb +42 -0
  130. data/spec/git/pkg_spec.rb +21 -0
  131. data/spec/git/project_spec.rb +21 -0
  132. data/spec/git/repo_spec.rb +160 -0
  133. data/spec/{vendor_spec.rb → mixins/vendored_deps_spec.rb} +2 -4
  134. data/spec/mixins/versioned_dependencies_spec.rb +48 -0
  135. data/spec/rpm/patch_spec.rb +48 -0
  136. data/spec/rpm/requirement/attributes_spec.rb +34 -0
  137. data/spec/rpm/requirement/comparison_spec.rb +286 -0
  138. data/spec/rpm/requirement/gem_spec.rb +49 -0
  139. data/spec/rpm/requirement/parser_spec.rb +31 -0
  140. data/spec/rpm/requirement_spec.rb +8 -334
  141. data/spec/rpm/spec/check_spec.rb +25 -0
  142. data/spec/rpm/spec/comparison_spec.rb +55 -0
  143. data/spec/rpm/spec/files_spec.rb +17 -0
  144. data/spec/rpm/spec/gem_files_spec.rb +112 -0
  145. data/spec/rpm/spec/gem_reference_spec.rb +99 -0
  146. data/spec/rpm/spec/gem_requirement_spec.rb +38 -0
  147. data/spec/rpm/spec/parser_spec.rb +64 -0
  148. data/spec/rpm/spec/requirements_spec.rb +10 -0
  149. data/spec/rpm/spec/subpackages_spec.rb +38 -0
  150. data/spec/rpm/spec/updater_spec.rb +486 -0
  151. data/spec/rpm/spec_spec.rb +27 -174
  152. data/spec/spec_helper.rb +7 -107
  153. data/spec/support/coveralls.rb +10 -0
  154. data/spec/support/fixtures.rb +8 -0
  155. data/spec/support/paths.rb +20 -0
  156. data/spec/support/rspec.rb +20 -0
  157. data/spec/support/vcr.rb +11 -0
  158. data/spec/{bodhi_spec.rb → targets/bodhi_spec.rb} +3 -1
  159. data/spec/{errata_spec.rb → targets/errata_spec.rb} +2 -2
  160. data/spec/{fedora_spec.rb → targets/fedora_spec.rb} +3 -3
  161. data/spec/targets/koji/builder_spec.rb +48 -0
  162. data/spec/targets/koji/diff_spec.rb +36 -0
  163. data/spec/targets/koji/rpc_spec.rb +28 -0
  164. data/spec/{koji_spec.rb → targets/koji/versions_spec.rb} +1 -59
  165. data/spec/targets/koji_spec.rb +11 -0
  166. data/spec/{yum_spec.rb → targets/yum_spec.rb} +1 -1
  167. data/spec/{component_spec.rb → util/component_spec.rb} +1 -1
  168. data/spec/{core_spec.rb → util/core_ext_spec.rb} +2 -3
  169. metadata +278 -88
  170. data/lib/polisher/bodhi.rb +0 -23
  171. data/lib/polisher/config.rb +0 -32
  172. data/lib/polisher/core.rb +0 -101
  173. data/lib/polisher/errata.rb +0 -75
  174. data/lib/polisher/fedora.rb +0 -46
  175. data/lib/polisher/git.rb +0 -8
  176. data/lib/polisher/koji.rb +0 -159
  177. data/lib/polisher/rhn.rb +0 -15
  178. data/lib/polisher/version_checker.rb +0 -177
  179. data/lib/polisher/yum.rb +0 -37
  180. data/spec/git_spec.rb +0 -445
@@ -1,23 +0,0 @@
1
- # Polisher Bodhi Operations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- # XXX issue w/ retreiving packages from pkgwat causing sporadic issues:
7
- # https://github.com/fedora-infra/fedora-packages/issues/55
8
- require 'polisher/component'
9
-
10
- module Polisher
11
- # fedora pkgwat provides a frontend to bodhi
12
- Component.verify("Bodhi", "pkgwat") do
13
- class Bodhi
14
- def self.versions_for(name, &bl)
15
- versions = Pkgwat.get_updates("rubygem-#{name}", 'all', 'all').
16
- select { |update| update['stable_version'] != 'None' }.
17
- collect { |update| update['stable_version'] }
18
- bl.call(:bodhi, name, versions) unless(bl.nil?)
19
- versions
20
- end
21
- end
22
- end
23
- end
@@ -1,32 +0,0 @@
1
- # Polisher Config Operations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'yaml'
7
- require 'active_support'
8
- require 'active_support/core_ext'
9
-
10
- module Polisher
11
- class Config
12
- CONF = "#{ENV['HOME']}/.polisher/config"
13
- TARGETS = [['koji', 'polisher/koji', 'Koji'],
14
- ['distgit', 'polisher/git/pkg', 'Git::Pkg'],
15
- ['rpm', 'polisher/rpm/spec', 'RPM::Requirement'],
16
- ['tags', 'polisher/tag_mapper', 'TagMapper']]
17
-
18
- def self.opts
19
- @opts ||= File.exist?(CONF) ? YAML.load_file(CONF) : {}
20
- end
21
-
22
- def self.set
23
- TARGETS.each do |target, req, polisher_class|
24
- if opts[target]
25
- require req
26
- target_class = "Polisher::#{polisher_class}".constantize
27
- opts[target].each { |k, v| target_class.send(k.intern, v) }
28
- end
29
- end
30
- end
31
- end # class Config
32
- end # module Polisher
@@ -1,101 +0,0 @@
1
- # Polisher Core Ruby Extensions
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'polisher/config'
7
-
8
- module ConfHelpers
9
- module ClassMethods
10
- # Defines a 'config attribute' or attribute on the class
11
- # which this is defined in. Accessors to the single shared
12
- # attribute will be added to the class as well as instances
13
- # of the class. Specify the default value with the attr name
14
- # or via an env variable
15
- #
16
- # @example
17
- # class Custom
18
- # extend ConfHelpers
19
- # conf_attr :data_dir, '/etc/'
20
- # end
21
- # Custom.data_dir # => '/etc/'
22
- # ENV['POLISHER_DATA_DIR'] = '/usr/'
23
- # Custom.data_dir # => '/usr/'
24
- # Custom.data_dir == Custom.new.data_dir # => true
25
- #
26
- def conf_attr(name, default=nil)
27
- self.send(:define_singleton_method, name) do |*args|
28
- nvar = "@#{name}".intern
29
- current = self.instance_variable_get(nvar)
30
- envk = "POLISHER_#{name.to_s.upcase}"
31
- instance_variable_set(nvar, default) unless current
32
- instance_variable_set(nvar, ENV[envk]) if ENV.key?(envk)
33
- # TODO also allow vars to be able to be set from a conf file
34
- self.instance_variable_set(nvar, args.first) unless args.empty?
35
- self.instance_variable_get(nvar)
36
- end
37
-
38
- self.send(:define_method, name) do
39
- self.class.send(name)
40
- end
41
- end
42
-
43
- def cmd_available?(cmd)
44
- File.exist?(cmd) && File.executable?(cmd)
45
- end
46
-
47
- def require_cmd!(cmd)
48
- raise "command #{cmd} not available" unless cmd_available?(cmd)
49
- end # module ClassMethods
50
- end
51
-
52
- def self.included(base)
53
- base.extend(ClassMethods)
54
- end
55
-
56
- def require_cmd!(cmd)
57
- self.class.require_cmd!(cmd)
58
- end
59
- end
60
-
61
- class String
62
- # Return bool indicating if self is a path to a gem
63
- def gem?
64
- File.extname(self) == ".gem"
65
- end
66
-
67
- # Return bool indicating if self is a path to a gemspec
68
- def gemspec?
69
- File.extname(self) == ".gemspec"
70
- end
71
-
72
- # Return bool indicating if self is a path to a Gemfile
73
- def gemfile?
74
- File.basename(self) == "Gemfile"
75
- end
76
-
77
- # Remove and replace all occurances of rpm macros in self with non-rpm
78
- # macro correspondents. If no rpm macro is specified macro will
79
- # simply be removed
80
- def unrpmize
81
- require 'polisher/rpm/spec'
82
- matchers = Polisher::RPM::Spec::FILE_MACRO_MATCHERS
83
- replacements = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS
84
- f = matchers.inject(self) { |file, matcher| file.gsub(matcher, '') }
85
- f = replacements.keys.inject(f) { |file, r| file.gsub(Regexp.new(r), replacements[r]) }
86
- f
87
- end
88
-
89
- # Replace all occurrances of non-rpm macro strings in self
90
- # with their macro correspondences
91
- def rpmize
92
- require 'polisher/rpm/spec'
93
- matchers = Polisher::RPM::Spec::FILE_MACRO_MATCHERS
94
- replacements = Polisher::RPM::Spec::FILE_MACRO_REPLACEMENTS.invert
95
- f = replacements.keys.inject(self) { |file, r| file.gsub(r, replacements[r]) }
96
-
97
- special = (matchers + replacements.values).any? { |matcher| f =~ /^#{matcher}.*/ }
98
- f = special ? f : "%{gem_instdir}/#{f}"
99
- f
100
- end
101
- end
@@ -1,75 +0,0 @@
1
- # Polisher Errata Operations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'polisher/core'
7
- require 'polisher/component'
8
-
9
- module Polisher
10
- Component.verify("Errata", 'json', 'curb') do
11
- class Errata
12
- include ConfHelpers
13
-
14
- conf_attr :advisory_url, ''
15
- conf_attr :package_prefix, 'rubygem-'
16
-
17
- # Initialize/return singleton curl handle to query errata
18
- def self.client
19
- @curl ||= begin
20
- curl = Curl::Easy.new
21
- curl.ssl_verify_peer = false
22
- curl.ssl_verify_host = false
23
- curl.http_auth_types = :negotiate
24
- curl.userpwd = ':'
25
- curl
26
- end
27
- end
28
-
29
- def self.clear!
30
- @cached_url = nil
31
- @cached_builds = nil
32
- self
33
- end
34
-
35
- def self.builds
36
- @cached_url ||= advisory_url
37
- @cached_builds ||= nil
38
-
39
- if @cached_url != advisory_url || @cached_builds.nil?
40
- client.url = "#{advisory_url}/builds"
41
- @cached_builds = client.get
42
- @cached_builds = JSON.parse(client.body_str)
43
- end
44
-
45
- @cached_builds
46
- end
47
-
48
- def self.versions_for(name, &bl)
49
- versions = builds.collect do |tag, builds|
50
- ErrataBuild.builds_matching(builds, name)
51
- end.flatten
52
- bl.call(:errata, name, versions) unless(bl.nil?)
53
- versions
54
- end
55
- end # class Errata
56
-
57
- class ErrataBuild
58
- def self.builds_matching(builds, name)
59
- builds.collect { |build|
60
- self.build_matches?(build, name) ? self.build_version(build, name) : nil
61
- }.compact
62
- end
63
-
64
- def self.build_matches?(build, name)
65
- pkg,meta = *build.flatten
66
- pkg =~ /^#{Errata.package_prefix}#{name}-([^-]*)-.*$/
67
- end
68
-
69
- def self.build_version(build, name)
70
- pkg,meta = *build.flatten
71
- pkg.gsub(Errata.package_prefix, '').split('-')[1]
72
- end
73
- end # class ErrataBuild
74
- end # Component.verify(Errata)
75
- end # module Polisher
@@ -1,46 +0,0 @@
1
- # Polisher Fedora Operations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'polisher/bodhi'
7
- require 'polisher/component'
8
-
9
- module Polisher
10
- Component.verify("Fedora", "curb", "pkgwat", "nokogiri") do
11
- class Fedora
12
- PACKAGE_LIST = 'https://admin.fedoraproject.org/pkgdb/users/packages/'
13
-
14
- def self.client
15
- @client ||= Curl::Easy.new
16
- end
17
-
18
- # Retrieve list of gems owned by the specified user
19
- #
20
- # @param [String] user Fedora username to lookup
21
- # @return [Array<String>] list of gems which the user owns/has access to
22
- def self.gems_owned_by(user)
23
- client.url = "#{PACKAGE_LIST}#{user}"
24
- client.http_get
25
- packages = client.body_str
26
- # TODO: instantiate Polisher::Gem instances & return
27
- Nokogiri::HTML(packages).xpath("//a[@class='PackageName']")
28
- .select { |i| i.text =~ /rubygem-.*/ }
29
- .collect { |i| i.text.gsub(/rubygem-/, '') }
30
- end
31
-
32
- # Retrieve list of the versions of the specified package in the various
33
- # Fedora releases.
34
- #
35
- # @param [String] name name of the package to lookup
36
- # @param [Callable] bl optional callback to invoke with versions retrieved
37
- # @return [Array<String>] list of versions in Fedora
38
- def self.versions_for(name, &bl)
39
- # simply dispatch to bodhi to get latest updates
40
- Polisher::Bodhi.versions_for name do |_target, pkg_name, versions|
41
- bl.call(:fedora, pkg_name, versions) unless bl.nil?
42
- end
43
- end
44
- end # class Fedora
45
- end # Component.verify("Fedora")
46
- end # module Polisher
@@ -1,8 +0,0 @@
1
- # Polisher Git Entity Representations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'polisher/git/repo'
7
- require 'polisher/git/pkg'
8
- require 'polisher/git/project'
@@ -1,159 +0,0 @@
1
- # Polisher Koji Operations
2
- #
3
- # Licensed under the MIT license
4
- # Copyright (C) 2013-2014 Red Hat, Inc.
5
-
6
- require 'polisher/core'
7
- require 'polisher/component'
8
-
9
- module Polisher
10
- deps = ['awesome_spawn', 'xmlrpc/client', 'active_support',
11
- 'active_support/core_ext/kernel/reporting']
12
- Component.verify("Koji", *deps) do
13
- silence_warnings do
14
- XMLRPC::Config::ENABLE_NIL_PARSER = true
15
- XMLRPC::Config::ENABLE_NIL_CREATE = true
16
- end
17
-
18
- class Koji
19
- include ConfHelpers
20
-
21
- conf_attr :koji_url, 'koji.fedoraproject.org/kojihub'
22
- conf_attr :koji_tag, 'f21'
23
- conf_attr :package_prefix, 'rubygem-'
24
-
25
- # XXX don't like having to shell out to koji but quickest
26
- # way to get an authenticated session so as to launch builds
27
- conf_attr :build_cmd, '/usr/bin/koji'
28
- conf_attr :build_tgt, 'rawhide'
29
-
30
- def self.koji_tags
31
- [koji_tag].flatten
32
- end
33
-
34
- def self.package_prefixes
35
- [package_prefix].flatten
36
- end
37
-
38
- # Retrieve shared instance of xmlrpc client to use
39
- def self.client
40
- @client ||= begin
41
- url = koji_url.split('/')
42
- XMLRPC::Client.new(url[0..-2].join('/'),
43
- "/#{url.last}")
44
- end
45
- end
46
-
47
- # Return bool indiciating if koji has a build exactly
48
- # matching the specified version
49
- def self.has_build?(name, version)
50
- versions = versions_for name
51
- versions.include?(version)
52
- end
53
-
54
- # Return bool indicating if koji has a build which
55
- # satisfies the specified ruby dependency
56
- def self.has_build_satisfying?(name, version)
57
- dep = ::Gem::Dependency.new name, version
58
- versions_for(name).any? { |v| dep.match?(name, v) }
59
- end
60
-
61
- # Return list of tags for which a package exists
62
- #
63
- # @param [String] name of package to lookup
64
- # @return [Hash<String,String>] hash of tag names to package versions for tags
65
- # which package was found in
66
- def self.tagged_in(name)
67
- # tagid userid pkgid prefix inherit with_dups
68
- pkgs = client.call('listPackages', nil, nil, "rubygem-#{name}", nil, false, true)
69
- pkgs.collect { |pkg| pkg['tag_name'] }
70
- end
71
-
72
- # Retrieve list of the versions of the specified package in koji
73
- #
74
- # @param [String] name name of package to lookup
75
- # @param [Callable] bl optional block to invoke with versions retrieved
76
- # @return [Array<String>] versions retrieved, empty array if none found
77
- def self.versions_for(name, &bl)
78
- # koji xmlrpc call
79
- versions = tagged_versions_for(name).values.flatten.uniq
80
- bl.call(:koji, name, versions) unless bl.nil?
81
- versions
82
- end
83
-
84
- def self.tagged_versions_for(name)
85
- versions = {}
86
- koji_tags.each do |tag|
87
- versions[tag] = versions_for_tag(name, tag).flatten.uniq
88
- end
89
- versions
90
- end
91
-
92
- def self.tagged_version_for(name)
93
- versions = {}
94
- tagged_versions_for(name).each do |tag, tagged_versions|
95
- versions[tag] = tagged_versions.first
96
- end
97
- versions
98
- end
99
-
100
- def self.versions_for_tag(name, tag)
101
- metadata =
102
- package_prefixes.collect do |prefix|
103
- # tag event inherit prefix latest
104
- client.call('listTagged', tag, nil, true, nil, false,
105
- "#{prefix}#{name}")
106
- end
107
-
108
- metadata.flatten.collect { |b| b['version'] }.uniq
109
- end
110
-
111
- # Run a build against the specified target using the specified rpm
112
- def self.build(args = {})
113
- require_cmd! build_cmd
114
-
115
- target = args[:target] || build_tgt
116
- srpm = args[:srpm]
117
- scratch = args[:scratch] ? '--scratch' : ''
118
-
119
- cmd = "#{build_cmd} build #{scratch} #{target} #{srpm}"
120
- result = AwesomeSpawn.run(cmd)
121
- url = parse_url(result.output)
122
- raise url if result.exit_status != 0
123
- url
124
- end
125
-
126
- # Parse a koji build url from output
127
- def self.parse_url(output)
128
- task_info = output.lines.detect { |l| l =~ /Task info:.*/ }
129
- task_info ? task_info.split.last : ''
130
- end
131
-
132
- # def self.build_logs(url) # TODO
133
-
134
- # Return diff between list of packages in two tags in koji
135
- def self.diff(tag1, tag2)
136
- builds1 = client.call('listTagged', tag1, nil, false, nil, false)
137
- builds2 = client.call('listTagged', tag2, nil, false, nil, false)
138
- builds = {}
139
- builds1.each do |build|
140
- name = build['package_name']
141
- build2 = builds2.detect { |b| b['name'] == name }
142
- version1 = build['version']
143
- version2 = build2 && build2['version']
144
- builds[name] = {tag1 => version1, tag2 => version2}
145
- end
146
-
147
- builds2.each do |build|
148
- name = build['package_name']
149
- next if builds.key?(name)
150
-
151
- version = build['version']
152
- builds[name] = {tag1 => nil, tag2 => version}
153
- end
154
-
155
- builds
156
- end
157
- end # class Koji
158
- end # Component.verify("Koji")
159
- end # module Polisher