RPM构建不采用%file中的语法

时间:2018-03-21 10:37:56

标签: rpm rpmbuild rpm-spec

if ! /usr/bin/getent passwd sgate>/dev/null; then %define bindir /home/sgate/elasticsearch elif ! /usr/bin/getent passwd rgate>/dev/null; then %define bindir /home/rgate/elasticsearch fi

RPM构建错误:

File must begin with "/": if  
File must begin with "/": !  
Two files on one line: /usr/bin/getent
File must begin with "/": passwd
Two files on one line: /usr/bin/getent
File must begin with "/": sgate>/dev/null;
Two files on one line: /usr/bin/getent
File must begin with "/": the
File not found: /root/ES_RPM/ElasticSearchRPM/BUILDROOT/elasticsearch-5.2.2-1.x86_64/home/*/elasticsearch  
File must begin with "/": elif  
File must begin with "/": !
Two files on one line: /usr/bin/getent
File must begin with "/": passwd
Two files on one line: /usr/bin/getent
File must begin with "/": rgate>/dev/null;
Two files on one line: /usr/bin/getent
File must begin with "/": then
File not found: /root/ES_RPM/ElasticSearchRPM/BUILDROOT/elasticsearch-5.2.2-1.x86_64/home/*/elasticsearch
File must begin with "/": fi

运行RPM时出现此错误。如果逻辑,我在哪里出错?

2 个答案:

答案 0 :(得分:2)

您无法在%files部分中使用shell脚本。您可以使用宏,例如:

%if
...
%endif

但是这些宏条件在构建期间而不是在安装期间进行评估。

答案 1 :(得分:0)

你所拥有的%define并没有你想到的那样;他们正在定义事物,然后留下无效的shell代码。您可能需要一个包装器shell或Makefile,在命令行上调用rpmbuild并定义“mybindir”,例如 {{1} }

重新阅读问题,无论如何,您尝试做的事情似乎都是一个安装时间的事情,您无法像那样即时决定。我会说你在标准位置安装你的东西,例如 rpmbuild --define="mybindir /home/rgate/elasticsearch",然后在/usr/share/yourpackage中在适当用户的主目录中设置一个符号链接。在%post中,您可以编写脚本以执行您期望的操作。