构建rpm包时如何解决文件冲突

时间:2019-11-07 12:52:25

标签: rpm rpmbuild

我正在尝试将需要另一个软件包的rpm软件包打包。我想替换所需包中的两个文件,并在%post部分中对其进行编辑。但是我得到一个错误

file /etc/puppetlabs/puppet/puppet.conf from install of puppet-agent-install-5.0.1-1.noarch conflicts with file from package puppet-agent-5.0.1-1.el7.x86_64
  file /etc/sysconfig/puppet from install of puppet-agent-install-5.0.1-1.noarch conflicts with file from package puppet-agent-5.0.1-1.el7.x86_64

我的规格文件:

Name:   puppet-agent-in

#wersja
Version:        5.0.1
Vendor:         01
Summary:        02
Release:        1
License:        Apache License, Version 2.0

Requires(pre):  telnet, puppet-agent >= 5.0

BuildArchitectures:     noarch

BuildRoot:      %{_tmppath}/BuildRoot

Source1:        cer_pem.crt
Source2:        cer_corpo_pem.crt
Source3:        puppet.conf
Source4:        puppet

Conflicts:      puppet-agent-install < %{version}
Conflicts:      puppet-agent-install > %{version}
Conflicts:      puppet-agent-opl

%description


%install:

%{__install} -d -m 755 $RPM_BUILD_ROOT/etc/puppetlabs/puppet/dir_ssl
%{__install} -d -m 755 $RPM_BUILD_ROOT/etc/sysconfig

%{__install} -m 644 %{_sourcedir}/cer_corpo_pem.crt $RPM_BUILD_ROOT/etc/puppetlabs/puppet/dir_ssl/cer_corpo_pem.crt
%{__install} -m 644 %{_sourcedir}/cer_pem.crt $RPM_BUILD_ROOT/etc/puppetlabs/puppet/dir_ssl/cer_pem.crt
%{__install} -m 644 %{_sourcedir}/puppet.conf $RPM_BUILD_ROOT/etc/puppetlabs/puppet/puppet.conf
%{__install} -m 644 %{_sourcedir}/puppet $RPM_BUILD_ROOT/etc/sysconfig/puppet


%files

%defattr(-, root, root)
/etc/puppetlabs/puppet/dir_ssl/cer_corpo_pem.crt
/etc/puppetlabs/puppet/dir_ssl/cer_pem.crt
/etc/sysconfig/puppet
%config /etc/puppetlabs/puppet/puppet.conf

%post
#edit puppet.conf and puppet file

是否有可能解决此冲突?

1 个答案:

答案 0 :(得分:1)

两个软件包不能提供相同的文件。您必须找到解决方法:

  • 可以将配置放在conf.d目录中吗?
  • 不要使用默认配置运行人偶。自己启动p,然后指向您的配置文件(在其他位置)。我没有玩过木偶的经验,但类似:puppet -c /path/to/your/puppet.conf

是的,不可靠的解决方法,不推荐

再次:我不推荐这样做,但是您可以通过提供/path/to/your/puppet.conf来破解,然后在post部分中破坏真实的配置文件:

%post
mv /etc/puppetlabs/puppet/puppet.conf{,.backup}
ln -s /path/to/your/puppet.conf /etc/puppetlabs/puppet/puppet.conf

%postun
if [ $1 == 0 ]; then #uninstall
    # restore file from backup when your package is uninstalled
    mv /etc/puppetlabs/puppet/puppet.conf{.backup,}
fi

注意:这将对您的安装有效,但是当puppet本身更新时;您将丢失配置文件,因为它将再次被puppet rpm的/etc/puppetlabs/puppet/puppet.conf覆盖。