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

Breaks order of macro evaluation with %version reference #239

Open
Vogtinator opened this issue Aug 4, 2018 · 5 comments
Open

Breaks order of macro evaluation with %version reference #239

Vogtinator opened this issue Aug 4, 2018 · 5 comments
Labels

Comments

@Vogtinator
Copy link

%version is only defined after Version: in the .spec file, which means in combination with %global the order is important.

Name:           asdf
Version:        1.0.5
Release:        0
# Full Plasma 5 version (e.g. 5.8.95)
%{!?_plasma5_bugfix: %global _plasma5_bugfix %{version}}
# Lasted ABI-stable Plasma (e.g. 5.8 in KF5, but 5.8.95 in KUF)
%{!?_plasma5_version: %global _plasma5_version %(echo %{_plasma5_bugfix} | awk -F. '{print $1"."$2}')}
Summary:        asdf
License:        none
Requires:       foo = %{_plasma5_version}
%description
none

evaluates to Requires: foo = 1.0.

spec-cleaner converts this to

# Full Plasma 5 version (e.g. 5.8.95)
%{!?_plasma5_bugfix: %global _plasma5_bugfix %{version}}
# Lasted ABI-stable Plasma (e.g. 5.8 in KF5, but 5.8.95 in KUF)
%{!?_plasma5_version: %global _plasma5_version %(echo %{_plasma5_bugfix} | awk -F. '{print $1"."$2}')}
Name:           asdf
Version:        1.0.5
Release:        0
Summary:        asdf
License:        none
Requires:       foo = %{_plasma5_version}
%description
none

which evaluates to Requires: foo = 1.0.5. as %version is only available after the %global expansion.

As a workaround, we switched to %define for the time being, but this results in evaluating the command once per macro expansion.

@scarabeusiv scarabeusiv added the bug label Aug 6, 2018
@scarabeusiv
Copy link
Contributor

hmm globals with awk are not a really good idea for once.

But yea it should play it safe... Any ideas how to achieve that?

@Vogtinator
Copy link
Author

hmm globals with awk are not a really good idea for once.

Feel free to come up with a better idea which doesn't involve lua...

But yea it should play it safe... Any ideas how to achieve that?

Is there already some kind of variable definition order tracking implemented? If not, it might be a bit difficult indeed... Maybe it could try to keep %global at the same position?

@scarabeusiv
Copy link
Contributor

No evaluation and tracking in the code yet. Well the globals idea was that they should be used only for when they are not depending on external resources as otherwise it "just works" thanks to the command order, while all other expansions are parsed fully first and then expressed.

@Conan-Kudo
Copy link
Member

@Vogtinator Two choices:

  1. Use %define so that it does lazy evaluation
  2. Use %{expand:%{version}} instead, so that block is forced to lazy evaluation

@mlschroe
Copy link

%{expand:%{version}} will not help. %expand is not about lazy evaluation, but instead it does a re-expansion. This re-expansion happens right away, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants