如何根据正在设置或未设置的定义.rpm有条件地将文件包含在_foobar中?定义_foobar将包含构建根中的绝对路径。文件就在那儿。
根据文档,我期望以下内容能够正常工作(注意:这个%files部分中还有更多的文件,但这是要点):
%files
%if %{_foobar}
%{_foobar}
%endif然而,这给了我一个错误:
error: parse error in expression
error: /path/to/specfile:LINENO: parseExpressionBoolean returns -1其中/path/to/specfile:LINENO是指向.spec文件的路径和%if行的行号。
发布于 2015-02-05 12:40:46
我就是这样解决问题的
步骤1:
In Build section .. somewhere I wrote :
%build
.....
#check my condition here & if true define some macro
%define is_valid %( if [ -f /usr/bin/myfile ]; then echo "1" ; else echo "0"; fi )
#after his normal continuation
.....
...步骤2:安装部分
%install
......
#do something in that condition
if %is_valid
install -m 0644 <file>
%endif
#rest all your stuff
................步骤3:在“文件”部分
%files
if %is_valid
%{_dir}/<file>
%endif就这样
它起作用了。
PS :我无法给出完整的代码,因此给出了所有有用的代码片段。
发布于 2013-09-12 23:14:13
多亏了this blog post,我找到了一个适合我的版本:
%files
%if %{?_foobar:1}%{!?_foobar:0}
%{_foobar}
%endif如果已设置定义,则将其扩展到%if 1,否则将扩展到%if 0。
如果其他人有更好的解决方案,请回答。比起我自己,我当然更愿意接受别人的回答。
https://stackoverflow.com/questions/18775680
复制相似问题