RPM spec file - Is it possible to dynamically populate a spec file variable

巧了我就是萌 提交于 2019-12-02 21:56:43

You can define rpmbuild variables with %(cmd) at the top of the spec file. Notice the command is in parenthesis, not curly brackets. An example:

%define whoami %(whoami)

And elsewhere in the spec file, such as a script or the build/install sections, use the variable as normal in the curly brackets like this:

echo "The user that built this is %{whoami}"

The cmd can be anything, including your cat command. Be careful - when another user rebuilds the spec file it may not find the file. So it'll be preferable to use the %{sourcedir} macro like this:

%define path %(cat %{sourcedir}/path_file)

And make sure that path_file is in the source directory and included as a source in the spec file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!