On 4/28/20 10:53 AM, Nicolas Mailhot via devel wrote:
Le mardi 28 avril 2020 à 08:43 +0200, Petr Pisar a écrit :
On Mon, Apr 27, 2020 at 04:33:52PM +0200, Petr Šabata wrote:
%_use_ncurses %{lua: if rpm.expand("%{name}") == "yourpackage1" or rpm.expand("%{name}") == "yourpackage2" then print(rpm.expand("%{bcond_with foo}%{with foo}")) else print(rpm.expand("%{bcond_without foo}%{with foo}")) end }
%{name} use in macro logic is unsafe because %{name} does not exist in the preamble before the Name: line, and the Name: line does not exist before you start declaring package headers.
Just to clarify, this is true of all versions of rpm.
Once you’re in package header declaration mode rpm parser behaviour will prevent you from doing logic between headers blocks, so it all needs interleaving, which ends un not possible sanely in any semi-complex spec file.
The rpm parser will now insult you with messages like warning: undefined macro(s) in %{_sourcedir}: /var/lib/builder/rpmbuild/SOURCES/%{name}
if you try to use %{name} at the srpm level.
This is an rpm 4.15 change https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/83
And that's a redhat-rpm-config pull-request, which doesn't really explain a thing.
The actual background is in this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1820349
- Panu -