From f6d9e14315ed47bec31b57bfffdb37d007d6e7f5 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-aacraid.spec b/SPECS/kmod-aacraid.spec index 66450e3..e0633b6 100644 --- a/SPECS/kmod-aacraid.spec +++ b/SPECS/kmod-aacraid.spec @@ -161,11 +161,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