Skip to content

Commit

Permalink
Implement rich RPM dependencies
Browse files Browse the repository at this point in the history
This implements rich RPM dependencies, which are available with RPM
4.14+ (introduced in Fedora 27[1]). This means only a single line for a
dependency is used. That doesn't play well with the
.with_requires.commented_out approach that was implemented. This instead
moves the loop back to the template.

[1]: https://fedoraproject.org/wiki/Changes/RPM-4.14
  • Loading branch information
ekohl committed Nov 24, 2023
1 parent 919653d commit 128f58f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/gem2rpm/rpm_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ def to_rpm
end
rpm_dependencies.join("\n")
end

# Returns string with entry suitable for RPM .spec file with RPM 4.14+.
def to_rich_rpm
rpm_dependencies = requirement.map { |v| v.to_s.empty? ? name : "#{name} #{v}" }
rpm_dependencies.size == 1 ? rpm_dependencies.first : "(#{rpm_dependencies.join(' with ')})"
end
end
end
6 changes: 3 additions & 3 deletions templates/fedora-27-rawhide.spec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ BuildRequires: <%= requirement "ruby#{'-devel' unless spec.extensions.empty?}",
# https://fedoraproject.org/wiki/Packaging:C_and_C++#BuildRequires_and_Requires
BuildRequires: gcc
<% end -%>
<%= development_dependencies.reject do |d|
["rdoc", "rake", "bundler"].include? d.name
end.virtualize.with_requires.comment_out.to_rpm -%>
<% for req in development_dependencies.reject { |d| ["rdoc", "rake", "bundler"].include? d.name }.virtualize -%>
# BuildRequires: <%= req.to_rich_rpm %>
<% end -%>
<% if spec.extensions.empty? -%>
BuildArch: noarch
<% end -%>
Expand Down

0 comments on commit 128f58f

Please sign in to comment.