aboutsummaryrefslogtreecommitdiffstats
path: root/rpm
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2019-01-08 09:26:45 -0800
committerBrian Behlendorf <[email protected]>2019-01-08 09:26:45 -0800
commit21e000ad3f5331a1c549905480e19d5ecbac0db3 (patch)
tree04f4d627096c11624f470b39c3a21252b5ab2a5c /rpm
parent4efb48eecb43717f70817bfb152bf86f7ed28b5b (diff)
Fix missing dkms modules after upgrades
If you were upgrading from say, fc28->fc29, on ZFS version X, the RPMs macros would get called like this: %post X.fc29 - This is the step where fc29 gets built by dkms. As part of the build, dkms automatically removes the previous modules before building the new ones. It then builds the new modules. %preun X.fc28 - Right before this step, X.fc29 is be built and installed, but since it has the same X, it's files get inadvertently removed by fc28's uninstall. %postun X.fc28 This patch updates %preun X.fc28 to see if we're upgrading or uninstalling. If we're uninstalling, then remove our files. If we're upgrading then do nothing, since will know dkms will have already removed our files in %post X.fc29. Note that since this fixes the %preun step, it's effect isn't going to be noticed immediately. It will only be seen when packages with this fix are upgraded to a newer version. Reviewed-by: Ralf Ertzinger <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #6902 Closes #8216
Diffstat (limited to 'rpm')
-rw-r--r--rpm/generic/zfs-dkms.spec.in18
1 files changed, 18 insertions, 0 deletions
diff --git a/rpm/generic/zfs-dkms.spec.in b/rpm/generic/zfs-dkms.spec.in
index 7b6612b89..6f2ae2c79 100644
--- a/rpm/generic/zfs-dkms.spec.in
+++ b/rpm/generic/zfs-dkms.spec.in
@@ -72,6 +72,24 @@ echo -e "support or upgrade DKMS to a more current version."
exit 1
%preun
+# Are we doing an upgrade?
+if [ $1 -ne 0 ] ; then
+ # Yes we are. Are we upgrading to a new ZFS version?
+ NEWEST_VER=$(dkms status zfs | sed 's/,//g' | sort -r -V | awk '/installed/{print $2; exit}')
+ if [ "$NEWEST_VER" != "%{version}" ] ; then
+ # Yes, it's a new ZFS version. We'll uninstall the old module
+ # later on in this script.
+ true
+ else
+ # No, it's probably an upgrade of the same ZFS version
+ # to a new distro (zfs-dkms-0.7.12.fc28->zfs-dkms-0.7.12.fc29).
+ # Don't remove our modules, since the rebuild for the new
+ # distro will automatically delete the old modules.
+ exit 0
+ fi
+fi
+
+# If we're here then we're doing an uninstall (not upgrade).
CONFIG_H="/var/lib/dkms/%{module}/%{version}/*/*/%{module}_config.h"
SPEC_META_ALIAS="@PACKAGE@-@VERSION@-@RELEASE@"
DKMS_META_ALIAS=`cat $CONFIG_H 2>/dev/null |