如何使用 rpmbuild 更新预先存在的配置文件?
我一直在研究如何使用 rpmbuild 规范文件来更新现有的配置文件。
举个例子,在我的 rpm 中,我想将行添加到配置文件中,例如 /etc/stunnel/stunnel
[SomeAppName]
accept = 8006
connect = 127.0.0.1:5006
我目前在我的 %install 部分中得到了这个:
cat stunnel/stunnel.conf >> %{buildroot}/etc/stunnel/stunnel.conf
现在显然这是垃圾,因为每次我运行 rpm 时,它都会将这些相同的行添加到配置文件中。
我也不希望 /etc/stunnel/stunnel.conf 文件成为我的 rpm 的一部分,因为我不希望它在删除 rpm 包时被删除。
我的问题是:
- 如何将 /etc/stunnel/stunnel.conf 排除在我的 rpm 之外?
- 在 rpm 期间向配置文件添加行的正确方法是什么?
- 请有人提供一些链接,我可以在其中查看如何使其正常工作,或者我可以在规范文件中使用的几行示例。
我查看了官方指南 Max Rpm 但到目前为止我还没有找到回答我的问题。
I've been looking into how to use an rpmbuild spec file to update an already existing config file.
As an example, in my rpm I'd like to add lines to a config file e.g. /etc/stunnel/stunnel
[SomeAppName]
accept = 8006
connect = 127.0.0.1:5006
I've currently got this in my %install section:
cat stunnel/stunnel.conf >> %{buildroot}/etc/stunnel/stunnel.conf
Now clearly this is rubbish because each time I run the rpm it will add these same lines to the config file.
I also don't want the /etc/stunnel/stunnel.conf
file to be part of my rpm as I don't want it removed when I erase my rpm package.
My questions are:
- How can I exclude the /etc/stunnel/stunnel.conf from being part of my rpm?
- What is the correct way to add lines to a config file during an rpm?
- Please could someone provide some links where I can see how to get this working or example of a few lines that I can use in my spec file.
I've look at the official guide over at Max Rpm but so far I've not found the answer to my issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
a) 出于这个确切的原因,许多更现代的工具还支持与平面文件并行的 .d 配置目录。例如,我的 Debian wheezy 发行版将 /etc/stunnel 视为一个目录,其中每个 .conf 文件都是一个单独的 stunnel 配置。
b) 已建立的替代方案似乎是一个条件构造,例如
(或者,如果不确定 stunnel.conf 是否已经存在)
a) Many more modern tools also support a .d configuration directory parallel to flat files for this exact reason. For example, my Debian wheezy distribution treats /etc/stunnel as a directory in which each .conf file is a separate stunnel configuration.
b) The established alternative seems to be a conditional construct like
(or, if not sure if stunnel.conf already exists)