centos – 避免rpm包中的文件冲突

前端之家收集整理的这篇文章主要介绍了centos – 避免rpm包中的文件冲突前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个rpm包.spec文件的一部分如下
%install    
mkdir -p ${RPM_BUILD_ROOT}/etc/xyz    
cp -rf %{BDIR}/console ${RPM_BUILD_ROOT}/etc/xyz

%files    
/etc/xyz/console

因此XYZ包将控制台目录复制到/ etc / xyz目录. console dir还包含一些其他目录.

安装工作完全正常,但当我删除包rpm时不删除/ etc / xyz / console目录下的文件和目录.

所以在重新安装rpm包时,它说文件正在发生冲突.

我们如何清理dir下的所有文件

更新:

目录结构:

console-
   -dashboard.html
   -index.html
   -login.html
   -logout.html

   -cgi-bin
   -cgi-bin/authenticate.py
   -cgi-bin/login.py
   -cgi-bin/logout.py

   -media
   -media/script/application.js
   -media/script/bootstrap.js
   -media/script/jquery.min.js960.css
   -media/script/jquery.flot.js

   -media/css/bootstrap.css
   -media/css/style.css
   -media/css/jquery-ui-1.10.0.custom.css

   -media/image/logo.png
   -media/image/banner.png

规范文件

%install

[ "$(cd "${RPM_BUILD_ROOT}" && pwd)" != "/" ] && rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/css
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/css/images
mkdir -p ${RPM_BUILD_ROOT}/etc/application/console/media/script


cp %{BDIR}/console/dashboard.html ${RPM_BUILD_ROOT}/etc/application/console/dashboard.html
cp %{BDIR}/console/index.html ${RPM_BUILD_ROOT}/etc/application/console/index.html
cp %{BDIR}/console/login.html ${RPM_BUILD_ROOT}/etc/application/console/login.html
cp %{BDIR}/console/logout.html ${RPM_BUILD_ROOT}/etc/application/console/logout.html


cp %{BDIR}/console/cgi-bin/authenticate.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/authenticate.py
cp %{BDIR}/console/cgi-bin/login.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/login.py
cp %{BDIR}/console/cgi-bin/logout.py ${RPM_BUILD_ROOT}/etc/application/console/cgi-bin/logout.py

cp %{BDIR}/console/media/css/boostrap.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/boostrap.css
cp %{BDIR}/console/media/css/style.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/style.css
cp %{BDIR}/console/media/css/jquery-ui-1.10.0.custom.css ${RPM_BUILD_ROOT}/etc/application/console/media/css/jquery-ui-1.10.0.custom.css

cp %{BDIR}/console/media/css/images/logo.png ${RPM_BUILD_ROOT}/etc/application/console/media/css/images/logo.png
cp %{BDIR}/console/media/css/images/banner.png ${RPM_BUILD_ROOT}/etc/application/console/media/css/images/banner.png

%files
%defattr(0700,root,root)

/etc/application/console/dashboard.html
/etc/application/console/index.html
/etc/application/console/login.html
/etc/application/console/logout.html

/etc/application/console/cgi-bin/authenticate.py
/etc/application/console/cgi-bin/authenticate.pyc
/etc/application/console/cgi-bin/authenticate.pyo
/etc/application/console/cgi-bin/login.py
/etc/application/console/cgi-bin/login.pyc
/etc/application/console/cgi-bin/login.pyo
/etc/application/console/cgi-bin/logout.py
/etc/application/console/cgi-bin/logout.pyc
/etc/application/console/cgi-bin/logout.pyo

/etc/application/console/media/css/boostrap.css
/etc/application/console/media/css/style.css
/etc/application/console/media/css/jquery-ui-1.10.0.custom.css

/etc/application/console/media/css/images/logo.png
/etc/application/console/media/css/images/banner.png


%post
echo "post install executing"

%preun

%postun
echo "post remove executing"

rm -rf /etc/application/console/cgi-bin/authenticate.py*
rm -rf /etc/application/console/cgi-bin/login.py*
rm -rf /etc/application/console/cgi-bin/logout.py*

错误

file /etc/application/console/cgi-bin/login.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64
file /etc/application/console/cgi-bin/logout.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64
file /etc/application/console/cgi-bin/authenticate.py from install of applicationconsole-1.0-1.x86_64 conflicts with file from package application_console-1.0-1.x86_64

更详细的删除输出

D:     erase: waitpid(31098) rc 31098 status 0 secs 0.179    
    D: fini      100700  1 (   0,0)      4827 /etc/application/console/cgi-bin/login.py skip
    D: fini      100700  1 (   0,0)      1195 /etc/application/console/cgi-bin/logout.py
skip
    D: fini      100700  1 (   0,0)      7227 /etc/application/console/cgi-bin/authenticate.py skip
    D: fini      100700  1 (   0,0)     33550 /etc/cacheBox/console/application.html
    D: fini      100700  1 (   0,0)     33550 /etc/cacheBox/console/login.html
    D: fini      100700  1 (   0,0)     33550 /etc/cacheBox/console/logout.html

如果你注意到rpm包管理器正在跳过一些文件.问题是为什么?

RPM只会删除“%files”指令下指定的文件,但前提是该目录下没有文件.
如果你想“rpm -e”删除“/ etc / xyz / console”下的所有文件,你必须在“%files”指令下明确指定它们.

RPM不会删除任何故意无法识别的内容,因为它不安全,因此只需删除软件包就不会丢失数据,例如考虑更新中的配置文件.
总有一种简单的方法可以看到RPM被提供到操作系统中的内容“rpm -qpl your_package.rpm”
在您的情况下,有两种方法可以删除文件

1)在“%files”下明确指定它们

2)或运行“%postun”脚本,删除您想要的文件和目录.

希望这可以帮助.

原文链接:https://www.f2er.com/centos/373589.html

猜你在找的CentOS相关文章