如何在打包 RPM 时设置已安装(谁正在安装 RPM)用户和组权限

How to set the installed(who is installing the RPM) user and group privileges while packing the RPM

I am just wondering if there is a way to specify the current user(who is installing the RPM) user:group privileges to installed folder of RPM(/usr/lib/appfloder) in the Spec(.spec) file.

示例:当前在安装 RPM 时,如果我们不创建用户和组且未在部分中添加,它正在考虑 root:root 权限 (%defattr(777, maya, maya, 777)) 在规范文件中。如果我们添加 defattr,它会将 maya 视为用户。

Expecting, please consider the current user 'user1' is installing the RPM, the privileges should under 'user1'. if 'user2' is installing the RPM it should under 'user2'.. Why?

I have an RPM package which install on /usr/lib/app and run as a service. And my application needs the current user home directory to search for some package which is installed for the current user.

安装 rpm 的用户始终是 root,因为您需要 root 权限才能安装转数。

所以你不能这样做。您需要找到其他方法,包不应在用户的 /home 目录中提供文件。如果您有通用配置要打包;把它放在 /etc.