Skip to content
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

RFE: Support rpm version comparison in expressions #1233

Merged
merged 3 commits into from May 27, 2020

Conversation

pmatilai
Copy link
Member

Adds rpm version as a new expression value type, denoted by v"" (similar to Python u"", b"" etc), which are compared using rpm version comparison algorithm rather than regular string comparison.

For example in specs:

%if v"%{python_version}" < v"3.9"
...
%endif

...but also command lines, arbitrary macros etc: rpm --eval '%[v"1:1.2" < v"2.0"]'

Fixes: #1217

@pmatilai pmatilai added the RFE label May 19, 2020
@pmatilai
Copy link
Member Author

This is on top of #1221 as that is required for this to work, but in a separate PR to hopefully keep it more reviewable.

We might want to add s"" as an alias to regular "" just for symmetry if/when this goes in, but leaving that out for now as it doesn't add anything new.

@hroncok
Copy link
Contributor

hroncok commented May 19, 2020

So, this basically compares evrs, correct?

doc/manual/macros Outdated Show resolved Hide resolved
doc/manual/macros Outdated Show resolved Hide resolved
@pmatilai
Copy link
Member Author

So, this basically compares evrs, correct?

Yes.

It also has provisions for validating EVR strings, but the only validation currently done is that an EVR string cannot be empty.

@ffesti
Copy link
Contributor

ffesti commented May 27, 2020

This looks good (only looking at the last three - parser related - patches).

It's less code, less redundancy and makes adding new types nicer.
Less redundancy and makes adding new types nicer.
Adds rpm version as a new expression value type, denoted by v"" (similar
to Python u"", b"" etc), which are compared using rpm version comparison
algorithm rather than regular string comparison.

For example in specs:

    %if v"%{python_version}" < v"3.9"
    %endif

...but also command lines, arbitrary macros etc:

    rpm --eval '%[v"1:1.2" < v"2.0"]'

Fixes: rpm-software-management#1217
@pmatilai
Copy link
Member Author

Rebased.

@ffesti ffesti merged commit 145b5f8 into rpm-software-management:master May 27, 2020
@pmatilai
Copy link
Member Author

🎆

@pmatilai pmatilai deleted the verexp-pr branch May 27, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFE: Convenient version comparison macro
4 participants