rpm – 如何在%post rpm中执行一个php文件

我正在创build一个PHP Web应用程序的rpm安装程序。 其中一个要求是运行一个php脚本,一个将更新源代码,数据库和执行修复脚本的入口脚本。

为了达到这个要求,我创build了一个tar文件,其中包含php脚本和更新所需的其他文件,并将其存储在sources目录中。 我只需要在%post上调用php脚本。

%post cd $RPM_BUILD_ROOT gunzip %{name}-%{version}.tar tar -xvf %{name}-%{version}.tar php install.php 

因为我认为这是tar文件的位置,所以我先改变目录来build立。 然后解压缩文件并执行php脚本。 但是,我得到了下面的错误:

 gunzip: can't stat: webapp-1.0.tar (webapp-1.0.tar.gz): No such file or directory tar: Error opening archive: Failed to open 'webapp-1.0.tar' Could not open input file: install.php 

我应该如何执行php脚本? 这可能吗?

另外哪个rpm文件应该用于最终发布,目录rpms / i386或srpms? 我仍然在开发转速。

任何帮助表示赞赏。

[编辑]我试图%setup -c -n %{name}命令使用%setup -c -n %{name}而不是tar命令。 然后我得到这个消息Could not open input file: install.php

如果这是.spec文件,请使用%{buildroot}而不是$ RPM_BUILD_ROOT。 请参阅此处的“macros”一章: https : //fedoraproject.org/wiki/How_to_create_an_RPM_package

另外,请尝试echo %{buildroot} > /tmp/dbg.txt并检查/tmp/dbg.txt内容以查看它尝试cd的位置。

我build议尝试使用能够build立各种软件包的fpm 。 只要提供前后安装脚本作为参数和其余部分。 没有rpm spec文件或deb规则文件需要。