rpmrpm-spec

Can I use rpm to expand the macros in a specfile?


The concrete example being I have lots of specfiles with Source0: or other Source lines containing macros. How can I have these macros expanded without actually starting a build on the specfile or writing my own parser?


Solution

  • You could grep to get the Source lines, sed to extract the string containing the macro and then rpm --eval 'string' to evaluate it. Note that this will only expand the global macros, not the ones defined in this spec.

    To expand those as well you'd probably need to grep for them and feed them to rpm as your custom macros file.