Skip to content

Commit

Permalink
Fix dkms installation of deb packages created with Alien.
Browse files Browse the repository at this point in the history
Alien does not seem to honour the %posttrans hook.
So move the dkms uninstall/install scripts to the
 %pre/%post hooks in case of package install/upgrade.
In case of package removal, handle that in %preun.
Also add more verbose messages about what we are doing.

Signed-off-by: Mart Frauenlob <[email protected]>
  • Loading branch information
AllKind committed Oct 18, 2023
1 parent c0e5899 commit 3a65659
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions rpm/generic/zfs-dkms.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,37 @@ fi
%defattr(-,root,root)
/usr/src/%{module}-%{version}

%preun
dkms remove -m %{module} -v %{version} --all
%pre
# Uninstall this version of zfs dkms modules before installation of the package.
echo "Running pre installation script: $0"
if [ `dkms status -m zfs -v %{version} | grep -c zfs` -gt 0 ]; then
echo "Removing %{module} dkms modules version %{version} from all kernels."
dkms remove -m %{module} -v %{version} --all
fi

%post
# After installing the package, dkms install this zfs version
# (if not there yet) for the current kernel.
echo "Running post installation script: $0"
if [ `dkms status -m zfs -v %{version} | grep -c zfs` -eq 0 ]; then
echo "Installing %{module} dkms modules version %{version} for the current kernel."
dkms install -m %{module} -v %{version}
fi

%posttrans
/usr/lib/dkms/common.postinst %{module} %{version}
%preun
# Check if we uninstall the package. In that case remove the dkms modules.
# '0' is the value for the first parameter for rpm packages.
# 'remove' or 'purge' are the possible names for deb packages.
echo "Running pre uninstall script: $0"
if [ "$1" = "0" -o "$1" = "remove" -o "$1" = "purge" ] ; then
echo "Removing %{module} dkms modules version %{version} from all kernels."
dkms remove -m %{module} -v %{version} --all
else
# If the above check fails, i.e. rpm or deb script invocation parameters changed,
# fall back to checking dkms status.
if [ `dkms status -m zfs -v %{version} | grep -c zfs` -gt 0 ]; then
echo "Removing %{module} dkms modules version %{version} from all kernels."
dkms remove -m %{module} -v %{version} --all
fi
fi

0 comments on commit 3a65659

Please sign in to comment.