2014-05-30 00:36:24 +04:00
|
|
|
%{?!packager: %define packager Brian Behlendorf <behlendorf1@llnl.gov>}
|
|
|
|
|
2022-11-29 20:27:22 +03:00
|
|
|
%if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}%{?openEuler}
|
2017-10-15 23:00:44 +03:00
|
|
|
%define not_rpm 1
|
|
|
|
%endif
|
|
|
|
|
2020-07-19 20:19:08 +03:00
|
|
|
# Exclude input files from mangling
|
|
|
|
%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$
|
2018-11-12 05:06:36 +03:00
|
|
|
|
2013-02-18 00:10:17 +04:00
|
|
|
%define module @PACKAGE@
|
|
|
|
%define mkconf scripts/dkms.mkconf
|
|
|
|
|
|
|
|
Name: %{module}-dkms
|
|
|
|
|
|
|
|
Version: @VERSION@
|
|
|
|
Release: @RELEASE@%{?dist}
|
|
|
|
Summary: Kernel module(s) (dkms)
|
|
|
|
|
|
|
|
Group: System Environment/Kernel
|
|
|
|
License: @ZFS_META_LICENSE@
|
2020-10-09 06:10:13 +03:00
|
|
|
URL: https://github.com/openzfs/zfs
|
2013-02-18 00:10:17 +04:00
|
|
|
Source0: %{module}-%{version}.tar.gz
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
|
|
|
BuildArch: noarch
|
|
|
|
|
2017-10-15 23:00:44 +03:00
|
|
|
Requires: dkms >= 2.2.0.3
|
2023-11-07 22:27:29 +03:00
|
|
|
Requires(pre): dkms >= 2.2.0.3
|
2021-12-12 22:15:25 +03:00
|
|
|
Requires(post): dkms >= 2.2.0.3
|
|
|
|
Requires(preun): dkms >= 2.2.0.3
|
2019-02-20 21:04:05 +03:00
|
|
|
Requires: gcc, make, perl, diffutils
|
2021-12-12 22:15:25 +03:00
|
|
|
Requires(post): gcc, make, perl, diffutils
|
2022-11-29 20:27:22 +03:00
|
|
|
%if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}%{?openEuler}
|
2021-05-28 09:06:45 +03:00
|
|
|
Requires: kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999
|
2021-12-12 22:15:25 +03:00
|
|
|
Requires(post): kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999
|
2022-07-11 21:35:01 +03:00
|
|
|
Obsoletes: spl-dkms <= %{version}
|
2017-10-15 23:00:44 +03:00
|
|
|
%endif
|
2013-02-18 00:10:17 +04:00
|
|
|
Provides: %{module}-kmod = %{version}
|
2017-11-07 21:59:27 +03:00
|
|
|
AutoReqProv: no
|
2013-02-18 00:10:17 +04:00
|
|
|
|
2022-11-29 20:27:22 +03:00
|
|
|
%if (0%{?fedora}%{?suse_version}%{?openEuler}) || (0%{?rhel} && 0%{?rhel} < 9)
|
2021-06-11 18:38:23 +03:00
|
|
|
# We don't directly use it, but if this isn't installed, rpmbuild as root can
|
|
|
|
# crash+corrupt rpmdb
|
|
|
|
# See issue #12071
|
|
|
|
BuildRequires: ncompress
|
|
|
|
%endif
|
|
|
|
|
2013-02-18 00:10:17 +04:00
|
|
|
%description
|
|
|
|
This package contains the dkms ZFS kernel modules.
|
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q -n %{module}-%{version}
|
|
|
|
|
|
|
|
%build
|
|
|
|
%{mkconf} -n %{module} -v %{version} -f dkms.conf
|
|
|
|
|
|
|
|
%install
|
|
|
|
if [ "$RPM_BUILD_ROOT" != "/" ]; then
|
|
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
fi
|
|
|
|
mkdir -p $RPM_BUILD_ROOT/usr/src/
|
|
|
|
cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
|
|
|
|
|
|
|
|
%clean
|
|
|
|
if [ "$RPM_BUILD_ROOT" != "/" ]; then
|
|
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
fi
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
|
|
|
/usr/src/%{module}-%{version}
|
|
|
|
|
2023-11-07 22:27:29 +03:00
|
|
|
%pre
|
|
|
|
echo "Running pre installation script: $0. Parameters: $*"
|
|
|
|
# We don't want any other versions lingering around in dkms.
|
|
|
|
# Tests with 'dnf' showed that in case of reinstall, or upgrade
|
|
|
|
# the preun scriptlet removed the version we are trying to install.
|
|
|
|
# Because of this, find all zfs dkms sources in /var/lib/dkms and
|
|
|
|
# remove them, if we find a matching version in dkms.
|
|
|
|
|
|
|
|
dkms_root=/var/lib/dkms
|
|
|
|
if [ -d ${dkms_root}/%{module} ]; then
|
|
|
|
cd ${dkms_root}/%{module}
|
|
|
|
for x in [[:digit:]]*; do
|
|
|
|
[ -d "$x" ] || continue
|
|
|
|
otherver="$x"
|
|
|
|
opath="${dkms_root}/%{module}/${otherver}"
|
|
|
|
if [ "$otherver" != %{version} ]; then
|
|
|
|
# This is a workaround for a broken 'dkms status', we caused in a previous version.
|
|
|
|
# One day it might be not needed anymore, but it does not hurt to keep it.
|
|
|
|
if dkms status -m %{module} -v "$otherver" 2>&1 | grep "${opath}/source/dkms.conf does not exist"
|
|
|
|
then
|
|
|
|
echo "ERROR: dkms status is broken!" >&2
|
|
|
|
if [ -L "${opath}/source" -a ! -d "${opath}/source" ]
|
|
|
|
then
|
|
|
|
echo "Trying to fix it by removing the symlink: ${opath}/source" >&2
|
|
|
|
echo "You should manually remove ${opath}" >&2
|
|
|
|
rm -f "${opath}/source" || echo "Removal failed!" >&2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ `dkms status -m %{module} -v "$otherver" | grep -c %{module}` -gt 0 ]; then
|
|
|
|
echo "Removing old %{module} dkms modules version $otherver from all kernels."
|
|
|
|
dkms remove -m %{module} -v "$otherver" --all ||:
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Uninstall this version of zfs dkms modules before installation of the package.
|
|
|
|
if [ `dkms status -m %{module} -v %{version} | grep -c %{module}` -gt 0 ]; then
|
|
|
|
echo "Removing %{module} dkms modules version %{version} from all kernels."
|
|
|
|
dkms remove -m %{module} -v %{version} --all ||:
|
|
|
|
fi
|
|
|
|
|
|
|
|
%post
|
|
|
|
echo "Running post installation script: $0. Parameters: $*"
|
|
|
|
# Add the module to dkms, as reccommended in the dkms man page.
|
|
|
|
# This is generally rpm specfic.
|
|
|
|
# But this also may help, if we have a broken 'dkms status'.
|
|
|
|
# Because, if the sources are available and only the symlink pointing
|
|
|
|
# to them is missing, this will resolve the situation
|
|
|
|
echo "Adding %{module} dkms modules version %{version} to dkms."
|
|
|
|
dkms add -m %{module} -v %{version} %{!?not_rpm:--rpm_safe_upgrade} ||:
|
|
|
|
|
|
|
|
# After installing the package, dkms install this zfs version for the current kernel.
|
|
|
|
# Force the overwriting of old modules to avoid diff warnings in dkms status.
|
|
|
|
# Or in case of a downgrade to overwrite newer versions.
|
|
|
|
# Or if some other backed up versions have been restored before.
|
|
|
|
echo "Installing %{module} dkms modules version %{version} for the current kernel."
|
|
|
|
dkms install --force -m %{module} -v %{version} ||:
|
|
|
|
|
2013-02-18 00:10:17 +04:00
|
|
|
%preun
|
2023-11-07 22:27:29 +03:00
|
|
|
dkms_root="/var/lib/dkms/%{module}/%{version}"
|
|
|
|
echo "Running pre uninstall script: $0. Parameters: $*"
|
|
|
|
# In case of upgrade we do nothing. See above comment in pre hook.
|
|
|
|
if [ "$1" = "1" -o "$1" = "upgrade" ] ; then
|
|
|
|
echo "This is an upgrade. Skipping pre uninstall action."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
if [ "$1" = "0" -o "$1" = "remove" -o "$1" = "purge" ] ; then
|
|
|
|
if [ `dkms status -m %{module} -v %{version} | grep -c %{module}` -gt 0 ]; then
|
|
|
|
echo "Removing %{module} dkms modules version %{version} from all kernels."
|
|
|
|
dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade} && exit 0
|
|
|
|
fi
|
|
|
|
# If removing the modules failed, it might be because of the broken 'dkms status'.
|
|
|
|
if dkms status -m %{module} -v %{version} 2>&1 | grep "${dkms_root}/source/dkms.conf does not exist"
|
|
|
|
then
|
|
|
|
echo "ERROR: dkms status is broken!" >&2
|
|
|
|
echo "You should manually remove ${dkms_root}" >&2
|
|
|
|
echo "WARNING: installed modules in /lib/modules/`uname -r`/extra could not be removed automatically!" >&2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Script parameter $1 did not match any removal condition."
|
|
|
|
fi
|
zfs-dkms rpm: simplify scriptlets, fix uninstall
Two problems led to unexpected behaviour of the scriptlets:
1) Newer DKMS versions change the formatting of "dkms status":
(old) zfs, 2.1.2, 5.14.10-300.fc35.x86_64, x86_64: installed
(new) zfs/2.1.2, 5.14.10-300.fc35.x86_64, x86_64: installed
Which broke a conditional determining whether to uninstall.
2) zfs_config.h not packaged properly, but was attempted to be read
in the %preun scriptlet:
CONFIG_H="/var/lib/dkms/zfs/2.1.2/*/*/zfs_config.h"
Which broke the uninstallation of the module, which left behind a
dangling symlink, which broke DKMS entirely with this error:
Error! Could not locate dkms.conf file.
File: /var/lib/dkms/zfs/2.1.1/source/dkms.conf does not exist.
This change attempts to simplify life by:
* Avoiding parsing anything (less prone to future breakage)
* Uses %posttrans instead of %post for module installation, because
%post happens before %preun, while %posttrans happens afterwards
* Unconditionally reinstall module on upgrade, which is less
efficient but the trade-off is that it's more reliable
Alternative approaches could involve fixing the existing parsing bugs
or improving the logic, but this comes at the cost of complexity and
possible future bugs.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jeremy Visser <jeremyvisser@google.com>
Closes #10463
Closes #13182
2022-03-28 19:55:57 +03:00
|
|
|
|
2023-11-07 22:27:29 +03:00
|
|
|
exit 0
|
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 <ralf@skytale.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #6902
Closes #8216
2019-01-08 20:26:45 +03:00
|
|
|
|