From 5c502778693f1066d750d9706a5f4b45c2d16e3e Mon Sep 17 00:00:00 2001 From: Peter Georg Date: Aug 06 2021 06:45:32 +0000 Subject: Run scripts only once in case multiple kmods are being installed --- diff --git a/SPECS/kmod-mpt3sas.spec b/SPECS/kmod-mpt3sas.spec index 72e964e..13a4737 100644 --- a/SPECS/kmod-mpt3sas.spec +++ b/SPECS/kmod-mpt3sas.spec @@ -104,11 +104,39 @@ find %{buildroot}/lib/modules -type f -name \*.ko -exec chmod u+x \{\} \+ %post -/usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch} +mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods +touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} + + +%preun +mkdir -p %{_localstatedir}/lib/rpm-state/sig-kmods +touch %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} %postun -/usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch} +if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ] +then + if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ] + then + /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch} + fi + + rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} + rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods +fi + + +%posttrans +if [ -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} ] +then + if [ -f /lib/modules/%{kernel_version}.%{_arch}/System.map ] + then + /usr/sbin/depmod -aeF /lib/modules/%{kernel_version}.%{_arch}/System.map %{kernel_version}.%{_arch} + fi + + rm -f %{_localstatedir}/lib/rpm-state/sig-kmods/%{kernel_version}.%{_arch} + rmdir --ignore-fail-on-non-empty %{_localstatedir}/lib/rpm-state/sig-kmods +fi %files