我创建了一个rpm,在%prep中的spec文件中我创建了用户和组,因此新安装的文件在该特定用户下运行。但是,看起来像rpmbuild忽略了我的%prep并且在rpm安装期间我得到了:
Running Transaction
Installing : appdynamics-machineagent-4.0.1.0-1.x86_64 1/1
warning: user appdynamics does not exist - using root
warning: group appdynamics does not exist - using root
warning: user appdynamics does not exist - using root
warning: group appdynamics does not exist - using root
RPM已安装但使用root用户。我的spec文件(%prep部分)如下所示:
%define _unpackaged_files_terminate_build 0
%prep
getent group appdynamics >/dev/null || groupadd -r appdynamics || exit 1
getent passwd appdynamics >/dev/null || useradd -r -g appdynamics -d /opt/appdynamics -s /bin/sh -c "appdynamics system user" appdynamics || exit 1
if [ -x /etc/init.d/appdynamics ]
then
/etc/init.d/appdynamics stop || true
fi
if [ -d /opt/appdynamics ]
then
rm -rf /opt/appdynamics || true
fi
exit 0
%setup -q
%build
%install
......
%files
%defattr(-,appdynamics,appdynamics)
%dir /opt/appdynamics
......
有什么建议吗? 非常感谢
答案 0 :(得分:3)
%prep
准备构建。它不在客户端计算机上运行。您希望%pre
或%post
在安装时运行。