-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement rich RPM dependencies #124
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I am missing something, I'd prefer to keep using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant to reply https://github.com/fedora-ruby/gem2rpm/pull/124/files#r1406987179 here. |
||
<% end -%> | ||
<% if spec.extensions.empty? -%> | ||
BuildArch: noarch | ||
<% end -%> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ def test_exclude_extension_directory | |
end | ||
|
||
def test_build_requires | ||
assert_match(/^# BuildRequires: rubygem\(test_development\) >= 1\.0\.0$/, @out_string) | ||
assert_includes(@out_string, "\n# BuildRequires: (rubygem(test_development) >= 1.0 with rubygem(test_development) < 2 with rubygem(test_development) >= 1.0.0)\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to double check, is RPM able to cope with this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://fedoraproject.org/wiki/Changes/RPM-4.14#User_Experience lists # Compose dependency together with its requirements in RPM rich dependency
# string.
def self.compose_dependency_string(name, requirements)
dependency_strings = requirements.map { |requirement| name + requirement }
dependency_string = dependency_strings.join(' with ')
dependency_string.prepend('(').concat(')') if dependency_strings.length > 1
dependency_string
end That doesn't make any special conditions and does pretty much the same thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't tell I trust myself :D |
||
end | ||
|
||
def test_rubygems_is_not_required | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, I don't have anything against this. However, what is the merit of separate method in comparison to adding some options to
to_rpm
? Maybe the options could also cover my proposal with dropping the version altogether (but now I remember that having the versions around is nice for awareness, so I'd like to keep them printed into the output).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, second option could be to have filter, similar to how the
virtualize.with_requires.comment_out
filter chain works. Actually that would be probably the best option if it is doableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that
virtualize.with_requires
results in['Requires: rubygem(mygem) >= 1.0', 'Requires: rubygem(mygem) < 2']
and if you join that, it doesn't work. I considered something likevirtualize.to_rich_rpm.with_requires.commented_out
but then.to_rich_rpm
doesn't return a string anymore.I'm not sure what you exactly mean by this. Do you mean supporting a block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demonstrates how the filter chain works:
As you can see, there still single
Gem::Dependency
object and the filters modifies the internalname
field, keeping therequirement
field in its original form. IOW it is still array ofGem::Version
object.Let me change the template a bit:
IOW, at this stage, it is still possible to output single line or three lines, as needed. From here I continued in this direction:
This however unveils, that my filter idea won't work as I hoped 🤣🤦🏻♂️ But after all, this might be the way:
This could be further improved if the
RpmDependencyList
implemented themap
method or of course if there was different filter, such as.rich_dependencies
hiding this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly what I was referring to.
I'll say that I actually like the loop in the ERB template: it makes it easier to understand what's going on. Implementing
map
(or even more parts ofEnumerable
) onRpmDependencyList
does sound like a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementing the map or additional filter provides just an option. It does not limit use of more low level constructs. After all, we certainly had more bare loops in the templates previously.