1

If I have a macro defined globally as:

%{!?patch_file_list: %global patch_file_list %(pfl=$(mktemp -t); ls %{_topdir}/SOURCES/*.patch | sort > $pfl; echo $pfl)}

and use it in the %prep section, is it assured that %{patch_file_list} will contain the name of the file returned by mktemp -t and the file will contain the list of patch files ?

When will the macro defined by %global patch_file_list ... get expanded ? when defined globally or when used first time in the %prep section ?

energon0
  • 11
  • 1

1 Answers1

1

A conditional macro expansion expands the body (i.e. Following the colon up to matching right curly brace) if the test macro is defined (note that a definition to %{nil} is a valid definition).

Macros are expanded immediately when encountered; in you case, this is when the spec file is being parsed before the %prep section is executed.

What may be confusing is that the conditional expansion defines the same macro name being tested.

Jeff Johnson
  • 2,310
  • 13
  • 23