Add conflicts RPM generator.

This leverages RPM Conflicts instead of expanding the version ranges,
which does not work as reliably for this purpose.
This commit is contained in:
Vít Ondruch 2018-02-01 19:22:44 +01:00
parent 75ea12f0a3
commit 637f46e17d
4 changed files with 63 additions and 12 deletions

View File

@ -94,10 +94,11 @@ Source6: abrt_prelude.rb
Source8: rubygems.attr Source8: rubygems.attr
Source9: rubygems.req Source9: rubygems.req
Source10: rubygems.prov Source10: rubygems.prov
Source11: rubygems.con
# ABRT hoook test case. # ABRT hoook test case.
Source12: test_abrt.rb Source13: test_abrt.rb
# SystemTap tests. # SystemTap tests.
Source13: test_systemtap.rb Source14: test_systemtap.rb
# The load directive is supported since RPM 4.12, i.e. F21+. The build process # The load directive is supported since RPM 4.12, i.e. F21+. The build process
# fails on older Fedoras. # fails on older Fedoras.
@ -599,6 +600,7 @@ mkdir -p %{buildroot}%{_rpmconfigdir}/fileattrs
install -m 644 %{SOURCE8} %{buildroot}%{_rpmconfigdir}/fileattrs install -m 644 %{SOURCE8} %{buildroot}%{_rpmconfigdir}/fileattrs
install -m 755 %{SOURCE9} %{buildroot}%{_rpmconfigdir} install -m 755 %{SOURCE9} %{buildroot}%{_rpmconfigdir}
install -m 755 %{SOURCE10} %{buildroot}%{_rpmconfigdir} install -m 755 %{SOURCE10} %{buildroot}%{_rpmconfigdir}
install -m 755 %{SOURCE11} %{buildroot}%{_rpmconfigdir}
# Install custom operating_system.rb. # Install custom operating_system.rb.
mkdir -p %{buildroot}%{rubygems_dir}/rubygems/defaults mkdir -p %{buildroot}%{rubygems_dir}/rubygems/defaults
@ -726,10 +728,10 @@ touch abrt.rb
# Check if abrt hook is required (RubyGems are disabled by default when using # Check if abrt hook is required (RubyGems are disabled by default when using
# runruby, so re-enable them). # runruby, so re-enable them).
make runruby TESTRUN_SCRIPT="--enable-gems %{SOURCE12}" make runruby TESTRUN_SCRIPT="--enable-gems %{SOURCE13}"
# Check if systemtap is supported. # Check if systemtap is supported.
%{?with_systemtap:make runruby TESTRUN_SCRIPT=%{SOURCE13}} %{?with_systemtap:make runruby TESTRUN_SCRIPT=%{SOURCE14}}
DISABLE_TESTS="" DISABLE_TESTS=""
@ -960,6 +962,7 @@ make check TESTS="-v $DISABLE_TESTS"
%{_rpmconfigdir}/fileattrs/rubygems.attr %{_rpmconfigdir}/fileattrs/rubygems.attr
%{_rpmconfigdir}/rubygems.req %{_rpmconfigdir}/rubygems.req
%{_rpmconfigdir}/rubygems.prov %{_rpmconfigdir}/rubygems.prov
%{_rpmconfigdir}/rubygems.con
%files -n rubygem-rake %files -n rubygem-rake
%{_bindir}/rake %{_bindir}/rake
@ -1064,6 +1067,7 @@ make check TESTS="-v $DISABLE_TESTS"
- Drop obsolete ldconfig scriptlets. - Drop obsolete ldconfig scriptlets.
- Add GMP dependency. - Add GMP dependency.
- Use 'with' operator in RPM dependency generator. - Use 'with' operator in RPM dependency generator.
- Add conflicts RPM generator.
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-89 * Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-89
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

View File

@ -1,5 +1,6 @@
%__rubygems_requires %{_rpmconfigdir}/rubygems.req %__rubygems_requires %{_rpmconfigdir}/rubygems.req
%__rubygems_provides %{_rpmconfigdir}/rubygems.prov %__rubygems_provides %{_rpmconfigdir}/rubygems.prov
%__rubygems_conflicts %{_rpmconfigdir}/rubygems.con
# In non-gem packages, the %%{gem_name} macro is not available and the macro # In non-gem packages, the %%{gem_name} macro is not available and the macro
# stays unexpanded which leads to "invalid regex" error (rhbz#1154067). # stays unexpanded which leads to "invalid regex" error (rhbz#1154067).
%__rubygems_path ^%{?gem_name:%{gem_spec}}%{!?gem_name:this_should_never_match_anything}$ %__rubygems_path ^%{?gem_name:%{gem_spec}}%{!?gem_name:this_should_never_match_anything}$

52
rubygems.con Normal file
View File

@ -0,0 +1,52 @@
#!/usr/bin/ruby
require 'rubygems/package'
module RubyGemsReq
module Helpers
# Keep only '!=' requirements.
def self.conflicts(requirements)
conflicts = requirements.select {|r| r.first == '!='}
end
# Converts Gem::Requirement into array of requirements strings compatible
# with RPM .spec file.
def self.requirement_versions_to_rpm(requirement)
self.conflicts(requirement.requirements).map do |op, version|
version == Gem::Version.new(0) ? "" : "= #{version}"
end
end
end
# Report conflicting gem dependencies including their version.
def self.gem_depenencies(specification)
specification.runtime_dependencies.each do |dependency|
conflict_strings = Helpers::requirement_versions_to_rpm(dependency.requirement).map do |requirement|
requirement_string = "rubygem(#{dependency.name}) #{requirement}"
end
if conflict_strings.length > 0
conflict_string = conflict_strings.join(' with ')
conflict_string.prepend('(').concat(')') if conflict_strings.length > 1
puts conflict_string
end
end
end
# Reports all conflicts specified by all provided .gemspec files.
def self.conflicts
while filename = gets
filename.strip!
begin
specification = Gem::Specification.load filename
gem_depenencies(specification)
rescue => e
# Ignore all errors.
end
end
end
end
if __FILE__ == $0
RubyGemsReq::conflicts
end

View File

@ -11,11 +11,11 @@ module RubyGemsReq
when '~>' when '~>'
expand_pessimistic_requirement(r) expand_pessimistic_requirement(r)
when '!=' when '!='
expand_not_equal_requirement(r) []
else else
[r] [r]
end end
end end.reject {|r| r.empty? }
end end
# Expands the pessimistic version operator '~>' into equivalent '>=' and # Expands the pessimistic version operator '~>' into equivalent '>=' and
@ -25,12 +25,6 @@ module RubyGemsReq
return ['>=', requirement.last], ['<', next_version] return ['>=', requirement.last], ['<', next_version]
end 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 # Converts Gem::Requirement into array of requirements strings compatible
# with RPM .spec file. # with RPM .spec file.
def self.requirement_versions_to_rpm(requirement) def self.requirement_versions_to_rpm(requirement)