]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rpm: deduplicate mgr module scriptlets with a macro
authorKefu Chai <k.chai@proxmox.com>
Thu, 21 May 2026 12:54:02 +0000 (20:54 +0800)
committerKefu Chai <k.chai@proxmox.com>
Mon, 1 Jun 2026 08:00:26 +0000 (16:00 +0800)
Define %ceph_mgr_module_scripts() to emit the identical %post/%postun
pair for each optional mgr module package, replacing the 5 existing
hand-written copies (dashboard, diskprediction-local, rook, k8sevents,
cephadm) with a single call site per package. Subsequent commits that
introduce new mgr module packages can use the macro from the start.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
ceph.spec.in

index 780889d5e738d876dfecc728dba58b50c4fc119e..a1022334fe199664813c1d21c6b03bc059915904 100644 (file)
   [ $jobs -lt 1 ] && jobs=1 \
   echo $jobs )
 
+# $1==1: fresh install; $1==0: removal. Skip try-restart on upgrade ($1>1).
+%define ceph_mgr_module_scripts() \
+%post %1\
+if [ $1 -eq 1 ] ; then\
+    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :\
+fi\
+\
+%postun %1\
+if [ $1 -eq 1 ] ; then\
+    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :\
+fi
+
 %if 0%{?_smp_ncpus_max} == 0
 %if 0%{?__isa_bits} == 32
 # 32-bit builds can use 3G memory max, which is not enough even for -j2
@@ -1968,28 +1980,12 @@ fi
 %files mgr-dashboard
 %{_datadir}/ceph/mgr/dashboard
 
-%post mgr-dashboard
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
-
-%postun mgr-dashboard
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
+%ceph_mgr_module_scripts mgr-dashboard
 
 %files mgr-diskprediction-local
 %{_datadir}/ceph/mgr/diskprediction_local
 
-%post mgr-diskprediction-local
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
-
-%postun mgr-diskprediction-local
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
+%ceph_mgr_module_scripts mgr-diskprediction-local
 
 %files mgr-modules-core
 %dir %{_datadir}/ceph/mgr
@@ -2026,41 +2022,17 @@ fi
 %files mgr-rook
 %{_datadir}/ceph/mgr/rook
 
-%post mgr-rook
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
-
-%postun mgr-rook
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
+%ceph_mgr_module_scripts mgr-rook
 
 %files mgr-k8sevents
 %{_datadir}/ceph/mgr/k8sevents
 
-%post mgr-k8sevents
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
-
-%postun mgr-k8sevents
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
+%ceph_mgr_module_scripts mgr-k8sevents
 
 %files mgr-cephadm
 %{_datadir}/ceph/mgr/cephadm
 
-%post mgr-cephadm
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
-
-%postun mgr-cephadm
-if [ $1 -eq 1 ] ; then
-    /usr/bin/systemctl try-restart ceph-mgr.target >/dev/null 2>&1 || :
-fi
+%ceph_mgr_module_scripts mgr-cephadm
 
 %files mon
 %{_bindir}/ceph-mon