spec-cleaner icon indicating copy to clipboard operation
spec-cleaner copied to clipboard

Breaks order of macro evaluation with %version reference

Open Vogtinator opened this issue 5 years ago • 5 comments

%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.

Vogtinator avatar Aug 04 '18 09:08 Vogtinator