rpm.spec 中的 %attr 不采用 env 变量的值 [英] %attr in rpm.spec does not take env variable's value

查看:98
本文介绍了rpm.spec 中的 %attr 不采用 env 变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 rpm.spec 文件,我必须在其中授予文件的文件权限.

I have a rpm.spec file in which i have to give file permissions for a file.

我希望 %attr 在 rpm 安装期间采用 $user 和 $group 值.(我将在其中执行export user="和export group=")但它不采用这些值,而是在安装 rpm 时出现语法错误.

I want %attr to take $user and $group values during the rpm installation.(where i will be doing "export user=" and "export group=") but it does not take these values,instead gives a syntax error while installing the rpm.

我的规范文件中有这样的内容

I have something like this in my specfile

%pre

%files
%defattr(-,root,root,-)
<some_path>
%config /etc/akshatha
%doc /usr/share/doc/akshatha
%attr(0700,$user,$group) %dir directory_path
%attr(0700,$user,$group) %dir directory_path
%attr(0600,$user,$group) path_to_file 

这给了我一个错误,同时将 rpm 安装为 -

this gives me an error, while installing the rpm as -

warning: user $user does not exist - using root
warning: group $group does not exist - using root

我什至尝试过给 %attr(0700,%{getenv:user},%{getenv:group}) 但这在准备 rpm 本身时失败了

I have even tried giving %attr(0700,%{getenv:user},%{getenv:group}) but this fails while preparing the rpm itself saying

RPM build errors:
Bad syntax: %attr(0700)
make: *** [all] Error 1

推荐答案

这是不可能的.%attr 在构建时固定;您特别要求在 rpm 安装期间",这将不起作用.

This is not possible. %attr is fixed at build time; you specifically asked for "during the rpm installation" which won't work.

在您的 %post 中,您可以 chown 但这会破坏您的验证.

In your %post you can chown but then that will break your verification.

这篇关于rpm.spec 中的 %attr 不采用 env 变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆