参考RPM包rpmbuild SPEC文件深度说明

原文链接:http://hlee.iteye.com/blog/343499

非常感谢原文作者的spec文件说明,从中受益匪浅。不过对于升级包的使用,有些错误。在centos6.0 rpm-build-4.8.0-19.el6.x86_64 环境下。使用rpm -Uvh 命令升级包的过程如下;

执行new.rpm包中的 %pre -> %post 安装文件,然后执行old.rpm包中的%preun ->%postun 删除文件。

所以如果你在%preun或者%postun中,rm -rf 文件的话,更新包将会删除新安装的文件。

解决方法是 使用 $1变量进行判断,示例如下:

1 %postun
2 echo "start postun"
3 if [ "$1" = "0" ];
4 then
5     rm -rf /etc/init.d/httpd
6     rm -rf /opt/%{name}
7     echo "Uninstall AutoScale Success!"
8 fi                                                                                                      


这样就可以保证删除包时可以清除文件,而更新包时不会删除新安装的文件。

但是不理解为什么rpmbuild这样设计,为什么不是先删除旧包,在安装新包。或者只执行新包中的脚本。

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-08-10
  • 2021-11-30
  • 2021-04-01
猜你喜欢
  • 2022-02-21
  • 2021-06-28
  • 2021-10-31
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-05-13
相关资源
相似解决方案