spec文件:%systemd_post()
%systemd_post()
的使用是在spec
文件中的%post
部分:
%systemd_post xxx.service
%systemd_post()
定义为:
%systemd_post() \
if [ $1 -eq 1 ] ; then \
# Initial installation \
systemctl --no-reload preset %{ ?*} &>/dev/null || : \
fi \
%{ nil}
其中的if
判断,$1
为当前执行的操作,
参考链接:https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/
根据上述表格,在%post
中调用%systemd_post()
时:
- 只有在安装软件包(系统还没有这个包)时才会执行预设的操作。
- 如果系统中已经安装了软件包,reinstall 或者 update 是不会执行 预设操作的。
如果想在update时,也执行预设操作,可以在spec的%post部分中添加:
if [ $1 -eq 2 ] ; then
# Upgrade installation
systemctl --no-reload preset xxx.service &>/dev/null || :
fi
等于: -eq
不等于: -ne
大于: -gt
小于: -lt
大于等于: -ge
小于等于: -le
参考链接:https://blog.csdn.net/xiaofei125145/article/details/40187031
还没有评论,来说两句吧...