开发者

how to update a pre-existing config file using rpmbuild?

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/stu开发者_开发技巧nnel/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.


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 ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜