如何使用 rpmbuild 更新预先存在的配置文件?

发布于 2024-12-04 16:03:23 字数 745 浏览 1 评论 0原文

我一直在研究如何使用 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 包时被删除。

我的问题是:

  1. 如何将 /etc/stunnel/stunnel.conf 排除在我的 rpm 之外?
  2. 在 rpm 期间向配置文件添加行的正确方法是什么?
  3. 请有人提供一些链接,我可以在其中查看如何使其正常工作,或者我可以在规范文件中使用的几行示例。

我查看了官方指南 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:

  1. How can I exclude the /etc/stunnel/stunnel.conf from being part of my rpm?
  2. What is the correct way to add lines to a config file during an rpm?
  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水般的淡然安静女子 2024-12-11 16:03:23

a) 出于这个确切的原因,许多更现代的工具还支持与平面文件并行的 .d 配置目录。例如,我的 Debian wheezy 发行版将 /etc/stunnel 视为一个目录,其中每个 .conf 文件都是一个单独的 stunnel 配置。

b) 已建立的替代方案似乎是一个条件构造,例如

grep -q '[SomeAppName]' %{buildroot}/etc/stunnel/stunnel.conf || cat ...

(或者,如果不确定 stunnel.conf 是否已经存在)

grep -s '[SomeAppName]' %{buildroot}/etc/stunnel/stunnel.conf || cat ...

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

grep -q '[SomeAppName]' %{buildroot}/etc/stunnel/stunnel.conf || cat ...

(or, if not sure if stunnel.conf already exists)

grep -s '[SomeAppName]' %{buildroot}/etc/stunnel/stunnel.conf || cat ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文