From 66b402292a303f2b447d298c93b496cc858b3dd5 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-qla2xxx.spec b/SPECS/kmod-qla2xxx.spec index 26e6c24..1f53d11 100644 --- a/SPECS/kmod-qla2xxx.spec +++ b/SPECS/kmod-qla2xxx.spec @@ -111,11 +111,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