From 3ee8b1e6d04203c0c465f3b9ef700ac259524f4b Mon Sep 17 00:00:00 2001 From: Peter Georg Date: Aug 06 2021 06:36:35 +0000 Subject: Run scripts only once in case multiple kmods are being installed --- diff --git a/SPECS/kmod-skge.spec b/SPECS/kmod-skge.spec index f18d48d..f6ab18c 100644 --- a/SPECS/kmod-skge.spec +++ b/SPECS/kmod-skge.spec @@ -106,11 +106,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