Add RPM dependency generators for RubyGems.
This commit is contained in:
parent
b038223eae
commit
724ffdbb53
16
ruby.spec
16
ruby.spec
@ -82,6 +82,10 @@ Source6: abrt_prelude.rb
|
||||
# https://fedorahosted.org/fpc/ticket/312
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=977941
|
||||
Source7: config.h
|
||||
# RPM dependency generators.
|
||||
Source8: rubygems.attr
|
||||
Source9: rubygems.req
|
||||
Source10: rubygems.prov
|
||||
|
||||
|
||||
# Include the constants defined in macros files.
|
||||
@ -477,6 +481,12 @@ sed -i "s/%%{name}/%{name}/" %{buildroot}%{_rpmconfigdir}/macros.d/macros.ruby
|
||||
install -m 644 %{SOURCE5} %{buildroot}%{_rpmconfigdir}/macros.d/macros.rubygems
|
||||
sed -i "s/%%{name}/%{name}/" %{buildroot}%{_rpmconfigdir}/macros.d/macros.rubygems
|
||||
|
||||
# Install dependency generators.
|
||||
mkdir -p %{buildroot}%{_rpmconfigdir}/fileattrs
|
||||
install -m 644 %{SOURCE8} %{buildroot}%{_rpmconfigdir}/fileattrs
|
||||
install -m 755 %{SOURCE9} %{buildroot}%{_rpmconfigdir}
|
||||
install -m 755 %{SOURCE10} %{buildroot}%{_rpmconfigdir}
|
||||
|
||||
# Install custom operating_system.rb.
|
||||
mkdir -p %{buildroot}%{rubygems_dir}/rubygems/defaults
|
||||
cp %{SOURCE1} %{buildroot}%{rubygems_dir}/rubygems/defaults
|
||||
@ -821,6 +831,9 @@ OPENSSL_ENABLE_MD5_VERIFY=1 make check TESTS="-v $DISABLE_TESTS"
|
||||
|
||||
%files -n rubygems-devel
|
||||
%{_rpmconfigdir}/macros.d/macros.rubygems
|
||||
%{_rpmconfigdir}/fileattrs/rubygems.attr
|
||||
%{_rpmconfigdir}/rubygems.req
|
||||
%{_rpmconfigdir}/rubygems.prov
|
||||
|
||||
%files -n rubygem-rake
|
||||
%{_bindir}/rake
|
||||
@ -890,6 +903,9 @@ OPENSSL_ENABLE_MD5_VERIFY=1 make check TESTS="-v $DISABLE_TESTS"
|
||||
%{ruby_libdir}/tkextlib
|
||||
|
||||
%changelog
|
||||
* Mon Mar 03 2014 Vít Ondruch <vondruch@redhat.com> - 2.1.0-19
|
||||
- Add RPM dependency generators for RubyGems.
|
||||
|
||||
* Mon Feb 10 2014 Josef Stribny <jstribny@redhat.com> - 2.1.0-19
|
||||
- Don't link cert.pem explicitely
|
||||
|
||||
|
3
rubygems.attr
Normal file
3
rubygems.attr
Normal file
@ -0,0 +1,3 @@
|
||||
%__rubygems_requires %{_rpmconfigdir}/rubygems.req
|
||||
%__rubygems_provides %{_rpmconfigdir}/rubygems.prov
|
||||
%__rubygems_path ^%{gem_spec}$
|
36
rubygems.prov
Normal file
36
rubygems.prov
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'rubygems/package'
|
||||
|
||||
module RubyGemsProv
|
||||
module Helpers
|
||||
# If there is some prelease version files, such as rc1 (i.e. non-numeric
|
||||
# field), prepend this field by tilde instead of dot.
|
||||
def self.normalize_prerelease(version)
|
||||
if version.prerelease?
|
||||
prerelease = version.version.sub /^#{version.release}\./, ''
|
||||
"#{version.release}~#{prerelease}"
|
||||
else
|
||||
version.release
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Reports all functionality gem provides.
|
||||
def self.provides
|
||||
while filename = gets
|
||||
filename.strip!
|
||||
begin
|
||||
specification = Gem::Specification.load filename
|
||||
|
||||
puts "rubygem(#{specification.name}) = #{Helpers::normalize_prerelease(specification.version)}"
|
||||
rescue => e
|
||||
# Ignore all errors.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
RubyGemsProv::provides
|
||||
end
|
81
rubygems.req
Normal file
81
rubygems.req
Normal file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'rubygems/package'
|
||||
|
||||
module RubyGemsReq
|
||||
module Helpers
|
||||
# Expands '~>' and '!=' gem requirements.
|
||||
def self.expand_requirement(requirements)
|
||||
requirements.inject([]) do |output, r|
|
||||
output.concat case r.first
|
||||
when '~>'
|
||||
expand_pessimistic_requirement(r)
|
||||
when '!='
|
||||
expand_not_equal_requirement(r)
|
||||
else
|
||||
[r]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Expands the pessimistic version operator '~>' into equivalent '>=' and
|
||||
# '<' pair.
|
||||
def self.expand_pessimistic_requirement(requirement)
|
||||
next_version = Gem::Version.create(requirement.last).bump
|
||||
return ['>=', requirement.last], ['<', next_version]
|
||||
end
|
||||
|
||||
# Expands the not equal version operator '!=' into equivalent '<' and
|
||||
# '>' pair.
|
||||
def self.expand_not_equal_requirement(requirement)
|
||||
return ['<', requirement.last], ['>', requirement.last]
|
||||
end
|
||||
|
||||
# Converts Gem::Requirement into array of requirements strings compatible
|
||||
# with RPM .spec file.
|
||||
def self.requirement_versions_to_rpm(requirement)
|
||||
self.expand_requirement(requirement.requirements).map do |op, version|
|
||||
version == Gem::Version.new(0) ? "" : "#{op} #{version}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Report RubyGems dependency, versioned if required.
|
||||
def self.rubygems_dependency(specification)
|
||||
Helpers::requirement_versions_to_rpm(specification.required_rubygems_version).each do |requirement|
|
||||
dependency_string = "ruby(rubygems)"
|
||||
dependency_strint += " #{specification.required_rubygems_version}" if requirement && requirement.length > 0
|
||||
puts dependency_string
|
||||
end
|
||||
end
|
||||
|
||||
# Report all gem dependencies including their version.
|
||||
def self.gem_depenencies(specification)
|
||||
specification.runtime_dependencies.each do |dependency|
|
||||
Helpers::requirement_versions_to_rpm(dependency.requirement).each do |requirement|
|
||||
dependency_string = "rubygem(#{dependency.name})"
|
||||
dependency_string += " #{requirement}" if requirement && requirement.length > 0
|
||||
puts dependency_string
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Reports all requirements specified by all provided .gemspec files.
|
||||
def self.requires
|
||||
while filename = gets
|
||||
filename.strip!
|
||||
begin
|
||||
specification = Gem::Specification.load filename
|
||||
|
||||
rubygems_dependency(specification)
|
||||
gem_depenencies(specification)
|
||||
rescue => e
|
||||
# Ignore all errors.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
RubyGemsReq::requires
|
||||
end
|
Loading…
Reference in New Issue
Block a user