Yum
RPM 規範文件案例更新
我正在嘗試創建 rpm 包。規格文件有下一個宏:
%postun systemctl stop metrics_haproxy.service systemctl stop checker_haproxy.service systemctl stop keep_alive.service systemctl disable metrics_haproxy.service systemctl disable checker_haproxy.service systemctl disable keep_alive.service rm -f /etc/httpd/conf.d/haproxy-wi.conf rm -f /etc/rsyslog.d/metric.conf rm -f /etc/rsyslog.d/checker.conf rm -f /etc/rsyslog.d/keep_alive.conf rm -f /etc/logrotate.d/metric rm -f /etc/logrotate.d/checker rm -f /etc/logrotate.d/keep_alive systemctl restart rsyslog systemctl daemon-reload %post systemctl daemon-reload systemctl restart rsyslog systemctl restart metrics_haproxy.service systemctl restart checker_haproxy.service systemctl restart keep_alive.service systemctl restart httpd systemctl enable metrics_haproxy.service systemctl enable checker_haproxy.service systemctl enable keep_alive.service systemctl enable httpd
但面臨一個問題:當我用新版本的 rpm 更新時,yum 首先創建所有服務,然後刪除。而且我在更新後沒有執行和啟用的服務
有一些解決方法嗎?
您應該閱讀此頁面以了解在 rpm 安裝時執行的腳本的順序。最重要的是:
- %post 新包
- 舊包的%postun
所以
%postun
你的舊包的腳本在你的新包的腳本之後%post
執行。您可能想要做的是:%postun if [ $1 = 0 ] then # the package is really being uninstalled, not upgraded fi
但是由於您的舊軟體包已經安裝,因此
%postun
舊軟體包的腳本仍將執行。因此,要修復此問題,我認為最簡單的解決方案是進行更改%post
,%posttrans
使其在腳本之後執行。%postun