将值重新分配给spec文件中的%define变量

编程入门 行业动态 更新时间:2024-10-21 09:43:28
将值重新分配给spec文件中的%define变量 - RPM(Reassign values to %define variables in spec file - RPM)

当我们使用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.

更多推荐

本文发布于:2023-08-07 10:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1463772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   文件   spec   define

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!