From 4f866f9fece5b824accc0d23719a86a5d6369092 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-mptsas.spec b/SPECS/kmod-mptsas.spec index 450fce3..47fe44e 100644 --- a/SPECS/kmod-mptsas.spec +++ b/SPECS/kmod-mptsas.spec @@ -102,11 +102,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