Files
mirror_zfs/rpm/generic/zfs-dkms.spec.in
T

110 lines
3.2 KiB
Plaintext
Raw Normal View History

2014-05-29 13:36:24 -07:00
%{?!packager: %define packager Brian Behlendorf <behlendorf1@llnl.gov>}
%if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}
%define not_rpm 1
%endif
2020-07-19 13:19:08 -04:00
# Exclude input files from mangling
%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$
2018-11-11 18:06:36 -08:00
2013-02-17 12:10:17 -08: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@
URL: https://github.com/openzfs/zfs
2013-02-17 12:10:17 -08:00
Source0: %{module}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: dkms >= 2.2.0.3
2019-02-20 10:04:05 -08:00
Requires: gcc, make, perl, diffutils
%if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}
Requires: kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999
2018-02-15 17:53:18 -08:00
Obsoletes: spl-dkms
%endif
2013-02-17 12:10:17 -08:00
Provides: %{module}-kmod = %{version}
AutoReqProv: no
2013-02-17 12:10:17 -08:00
2021-06-11 11:38:23 -04:00
%if 0%{?rhel}%{?fedora}%{?suse_version}
# 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-17 12:10:17 -08: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}
%post
for POSTINST in /usr/lib/dkms/common.postinst; do
if [ -f $POSTINST ]; then
$POSTINST %{module} %{version}
exit $?
fi
echo "WARNING: $POSTINST does not exist."
done
echo -e "ERROR: DKMS version is too old and %{module} was not"
echo -e "built with legacy DKMS support."
echo -e "You must either rebuild %{module} with legacy postinst"
echo -e "support or upgrade DKMS to a more current version."
exit 1
%preun
2019-01-08 09:26:45 -08:00
# Are we doing an upgrade?
if [ "$1" = "1" -o "$1" = "upgrade" ] ; then
2019-01-08 09:26:45 -08:00
# 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).
2015-09-30 20:36:18 -04:00
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 |
2020-05-14 22:51:33 -05:00
awk -F'"' '/META_ALIAS\s+"/ { print $2; exit 0 }'`
2015-09-30 20:36:18 -04:00
if [ "$SPEC_META_ALIAS" = "$DKMS_META_ALIAS" ]; then
2014-05-29 13:36:24 -07:00
echo -e
2015-09-30 20:36:18 -04:00
echo -e "Uninstall of %{module} module ($SPEC_META_ALIAS) beginning:"
dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade}
2014-05-29 13:36:24 -07:00
fi
2013-02-17 12:10:17 -08:00
exit 0