封装RPM,避免创建.rpmnew文件

时间:2021-06-06 13:29:32

I'm packaging some of my own software, as part of the installation I need to drop some config files in a directory that's used by a 3. party.

我正在打包我自己的一些软件,作为安装的一部分,我需要将一些配置文件放到一个由3所使用的目录中。聚会。

To avoid overwriting configuration that have been locally changed, that file is marked as a config file like so in the RPM .spec file:

为了避免覆盖已在本地更改的配置,该文件在RPM .spec文件中被标记为类似的配置文件:

%config(norelace) /opt/lmd/conf/srv1.conf

The issue is that upgrading an rpm will now produce the file

问题是升级rpm将生成文件

 /opt/lmd/conf/srv1.conf.rpmnew

if /opt/lmd/conf/srv1.conf have been altered locally. And the 3.d party software reads everything in /opt/lmd/conf/* .

如果/ opt / lmd / conf / srv1。conf已在当地进行了修改。和3。d方软件读取/opt/lmd/conf/*中的所有内容。

Can I somehow mark a config file in the RPM .spec file to not produce such an .rpmnew file ?

我是否可以在RPM .spec文件中标记一个配置文件,以不产生这样的.rpmnew文件?

3 个解决方案

#1


1  

Not that I'm aware of. This (and the human-made equivalents .bak, .off, .tmp etc.) is why most tools glob *.conf or similar when they read configuration files.

我不知道。这就是为什么大多数工具都使用glob *。当他们读取配置文件时,conf或类似的。

If you can't modify the third-party tool to fix that problem then you really can't do much about this short of not installing to that directory directly and making the user do the copying.

如果您不能修改第三方工具来解决这个问题,那么除了不直接安装到该目录并让用户进行复制之外,您真的不能做太多事情。

(You could package the old file too or sums of the old config file and check those against the current file in %post, etc. but that's ugly, manual and prone to possible failures.)

(您也可以打包旧文件或旧配置文件的总和,并根据%post等中的当前文件检查这些文件,但这很难看,手工操作,并且很容易发生故障。)

You might be able to manually remove/move the .rpmnew files in your %post (or %posttrans) scriptlet but I don't know if that's actually possible (timing-wise).

您可能可以手动删除/移动您的%post(或%posttrans) scriptlet中的.rpmnew文件,但我不知道是否可能(按时间顺序)。

#2


1  

Those backups are done for good reasons and only if those files were altered. Here is described when is created .rpmsave and when .rpmnew: http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html

这些备份是有充分理由的,而且只有当这些文件被修改时才会这样做。这里描述了何时创建。rpmsave,何时创建。rpmnew: http://www- uxsup.cs.cam.ac.uk/ ~jw35/docs/rpm_config.html

There exist tool rpmconf, which can help find, merge and delete those files. But since it query rpm database (and because it is interactive) you should not call it from rpm scriptlet.

存在rpmconf工具,可以帮助查找、合并和删除这些文件。但是由于它查询rpm数据库(由于它是交互式的),所以不应该从rpm scriptlet调用它。

If the 3rd party SW reads everything in /opt/lmd/conf/* then I will call that bug, because best practice is to read just /opt/lmd/conf/.conf This way e.g. httpd - reading /etc/httpd/conf.d/.conf. So contact your supplier and report it as bug.

如果第三方软件在/opt/lmd/conf/*中读取所有内容,那么我将调用该错误,因为最佳实践是只读/opt/lmd/conf/。以这种方式连接httpd -读取/etc/httpd/conf.d/.conf。因此,请与您的供应商联系,并将其报告为bug。

#3


1  

Another option would be to have your configuration file that you drop into the directory do nothing by default, i.e. all your options are commented out.

另一种选择是让你放入目录的配置文件默认不做任何事情,也就是说,你所有的选项都被注释掉了。

(I still think this is not a problem you should be solving, but the other vendor should... because this will be a problem for anybody who packages config files.)

(我仍然认为这不是一个你应该解决的问题,但是其他供应商应该……)因为这对任何打包配置文件的人来说都是一个问题。

#1


1  

Not that I'm aware of. This (and the human-made equivalents .bak, .off, .tmp etc.) is why most tools glob *.conf or similar when they read configuration files.

我不知道。这就是为什么大多数工具都使用glob *。当他们读取配置文件时,conf或类似的。

If you can't modify the third-party tool to fix that problem then you really can't do much about this short of not installing to that directory directly and making the user do the copying.

如果您不能修改第三方工具来解决这个问题,那么除了不直接安装到该目录并让用户进行复制之外,您真的不能做太多事情。

(You could package the old file too or sums of the old config file and check those against the current file in %post, etc. but that's ugly, manual and prone to possible failures.)

(您也可以打包旧文件或旧配置文件的总和,并根据%post等中的当前文件检查这些文件,但这很难看,手工操作,并且很容易发生故障。)

You might be able to manually remove/move the .rpmnew files in your %post (or %posttrans) scriptlet but I don't know if that's actually possible (timing-wise).

您可能可以手动删除/移动您的%post(或%posttrans) scriptlet中的.rpmnew文件,但我不知道是否可能(按时间顺序)。

#2


1  

Those backups are done for good reasons and only if those files were altered. Here is described when is created .rpmsave and when .rpmnew: http://www-uxsup.csx.cam.ac.uk/~jw35/docs/rpm_config.html

这些备份是有充分理由的,而且只有当这些文件被修改时才会这样做。这里描述了何时创建。rpmsave,何时创建。rpmnew: http://www- uxsup.cs.cam.ac.uk/ ~jw35/docs/rpm_config.html

There exist tool rpmconf, which can help find, merge and delete those files. But since it query rpm database (and because it is interactive) you should not call it from rpm scriptlet.

存在rpmconf工具,可以帮助查找、合并和删除这些文件。但是由于它查询rpm数据库(由于它是交互式的),所以不应该从rpm scriptlet调用它。

If the 3rd party SW reads everything in /opt/lmd/conf/* then I will call that bug, because best practice is to read just /opt/lmd/conf/.conf This way e.g. httpd - reading /etc/httpd/conf.d/.conf. So contact your supplier and report it as bug.

如果第三方软件在/opt/lmd/conf/*中读取所有内容,那么我将调用该错误,因为最佳实践是只读/opt/lmd/conf/。以这种方式连接httpd -读取/etc/httpd/conf.d/.conf。因此,请与您的供应商联系,并将其报告为bug。

#3


1  

Another option would be to have your configuration file that you drop into the directory do nothing by default, i.e. all your options are commented out.

另一种选择是让你放入目录的配置文件默认不做任何事情,也就是说,你所有的选项都被注释掉了。

(I still think this is not a problem you should be solving, but the other vendor should... because this will be a problem for anybody who packages config files.)

(我仍然认为这不是一个你应该解决的问题,但是其他供应商应该……)因为这对任何打包配置文件的人来说都是一个问题。