当我们使用spec文件中的%define标签定义变量以使用rpmbuild命令构建RPM时...是否可以在%pre上更新其值并在以后使用它?
When we define variables using the %define tag in a spec file to build an RPM using the rpmbuild command ... is it possible to update its value on %pre and use it later on ?
最满意答案
没有。
%define宏总是在spec文件中从上到下重新评估,因此不能有循环。
%global宏是一次性的。
例如, 关于“需要”处理的另一个问题 :
%global _use_internal_dependency_generator 0 %global __find_requires_orig %{__find_requires} %define __find_requires %{_builddir}/%{?buildsubdir}/build/find-requires %{__find_requires_orig}如果我使用%define来声明__find_requires_orig ,则会出现宏循环错误。
如果这不能回答您的问题,请详细说明您要查找的信息或最终目标。
ETA:
%pre和%post部分已经具有从构建RPM时硬编码的宏。 如果您需要做出额外的运行时决策,则需要在这些shell脚本中完成。
No.
%define macros are always re-evaluated, top to bottom in the spec file, so you cannot have loops.
%global macros are one-time.
Example, from another question concerning 'requires' processing:
%global _use_internal_dependency_generator 0 %global __find_requires_orig %{__find_requires} %define __find_requires %{_builddir}/%{?buildsubdir}/build/find-requires %{__find_requires_orig}If I had used %define to declare __find_requires_orig, it would error out with a macro loop.
If this doesn't answer your question, please elaborate what information you are looking for, or your end goal.
ETA:
The %pre and %post sections will already have the macros hard-coded from when the RPM is built. If you need additional run-time decisions to be made, they will need to be done in those shell scripts.
更多推荐
发布评论