%config(noreplace)文件上发生意外的RPM冲突 [英] Unexpected RPM conflict on %config(noreplace) files

查看:125
本文介绍了%config(noreplace)文件上发生意外的RPM冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 rpmbuild 创建自己的 RPM .
我的RPM 包含配置文件,即使RPM包含这些配置文件的新版本,该文件也应该永远不会被覆盖.

I'm creating my own RPM using rpmbuild.
My RPM contains config files which should never get overridden, even if the RPM contains a new version of these config files.

要对此存档,我用

%config(noreplace) /opt/mypackage/etc/*

在规格文件中.

根据文档和此站点,在这种情况下,本地修改的文件将永远不会被覆盖,这正是我想要的.

According to the documentation and this site, a locally modified file will never get overridden in this case which is exactly what I want.

但是,当执行以下操作时:

However, when doing the following operations:

  1. 安装RPM版本1
  2. 更改配置文件 etc/myconfig
  3. 使用RPM版本2更新程序包

我遇到了冲突:

$ rpm --prefix ~/rpmroot/ -ih dist/mypackage-1.0.1-1.x86_64.rpm
########################################### [100%]
file /home/user/rpmroot/mypackage/etc/myconfig from install of mypackage-1.0.2-1.x86_64 conflicts with file from package mypackage-1.0.1-1.x86_64

问题:

  • 如何解释这种冲突?(我希望配置文件的新版本将存储为 myconfig.rpmnew ,而现有的保持不变)
  • 我做错了什么?


更新(其他信息)

rpm -qcp dist/mypackage-1.0.1-1.x86_64.rpm 的输出为:

/opt/mypackage/etc/config1.xml
/opt/mypackage/etc/config2.xml
/opt/mypackage/etc/run.sh
/opt/mypackage/etc/config3.xml

完整的%files 部分:

%files
%defattr(0444,root,root)
/opt/mypackage/java/*

#dba
%defattr(0444,root,root)
/opt/mypackage/dba/sql/*
%defattr(0555,root,root)
/opt/mypackage/dba/script/*

#srv
%defattr(0555,root,root)
/opt/mypackage/srv/bin/*
/opt/mypackage/srv/lib/*

#etc
%defattr(0664,root,root)
%config(noreplace) /opt/mypackage/etc/*

推荐答案

如果实际上是您的问题,您可能会踢自己...

If this is actually your issue, you may kick yourself ...

我认为这可能只是因为您正在安装"而不是升级"将 -ih 替换为 -Uh

I think this may be just because you are "installing" and not "upgrading" replace -ih with -Uh

我用类似的设置创建了一个测试RPM,结果如下:

I created a test RPM with similar setup, here are the results:

与-ih一样,

$ sudo rpm-前缀〜/rpmroot/-ih/home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

$ sudo rpm --prefix ~/rpmroot/ -ih /home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

包含来自包ptst-1.0.0-1.x86_64文件的文件安装ptst-1.1.0-1.x86_64时的/home/nhed/rpmroot/etc/b发生冲突与软件包ptst-1.0.0-1.x86_64中的文件一起使用安装ptst-1.1.0-1.x86_64时的/home/nhed/rpmroot/etc/c冲突包ptst-1.0.0-1.x86_64中的文件

with file from package ptst-1.0.0-1.x86_64 file /home/nhed/rpmroot/etc/b from install of ptst-1.1.0-1.x86_64 conflicts with file from package ptst-1.0.0-1.x86_64 file /home/nhed/rpmroot/etc/c from install of ptst-1.1.0-1.x86_64 conflicts with file from package ptst-1.0.0-1.x86_64

使用-Uh

$ sudo rpm-前缀〜/rpmroot/-嗯/home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

$ sudo rpm --prefix ~/rpmroot/ -Uh /home/nhed/rpmbuild/RPMS/x86_64/ptst-1.1.0-1.x86_64.rpm

警告:/home/nhed/rpmroot/etc/a创建为/home/nhed/rpmroot/etc/a.rpmnew

warning: /home/nhed/rpmroot/etc/a created as /home/nhed/rpmroot/etc/a.rpmnew

这篇关于%config(noreplace)文件上发生意外的RPM冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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