1%{?!packager: %define packager Brian Behlendorf <behlendorf1@llnl.gov>} 2 3%if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version} 4%define not_rpm 1 5%endif 6 7# Exclude input files from mangling 8%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$ 9 10%define module @PACKAGE@ 11%define mkconf scripts/dkms.mkconf 12 13Name: %{module}-dkms 14 15Version: @VERSION@ 16Release: @RELEASE@%{?dist} 17Summary: Kernel module(s) (dkms) 18 19Group: System Environment/Kernel 20License: @ZFS_META_LICENSE@ 21URL: https://github.com/openzfs/zfs 22Source0: %{module}-%{version}.tar.gz 23BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 24BuildArch: noarch 25 26Requires: dkms >= 2.2.0.3 27Requires: gcc, make, perl, diffutils 28%if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version} 29Requires: kernel-devel >= @ZFS_META_KVER_MIN@, kernel-devel <= @ZFS_META_KVER_MAX@.999 30Obsoletes: spl-dkms 31%endif 32Provides: %{module}-kmod = %{version} 33AutoReqProv: no 34 35%if 0%{?rhel}%{?fedora}%{?suse_version} 36# We don't directly use it, but if this isn't installed, rpmbuild as root can 37# crash+corrupt rpmdb 38# See issue #12071 39BuildRequires: ncompress 40%endif 41 42%description 43This package contains the dkms ZFS kernel modules. 44 45%prep 46%setup -q -n %{module}-%{version} 47 48%build 49%{mkconf} -n %{module} -v %{version} -f dkms.conf 50 51%install 52if [ "$RPM_BUILD_ROOT" != "/" ]; then 53 rm -rf $RPM_BUILD_ROOT 54fi 55mkdir -p $RPM_BUILD_ROOT/usr/src/ 56cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/ 57 58%clean 59if [ "$RPM_BUILD_ROOT" != "/" ]; then 60 rm -rf $RPM_BUILD_ROOT 61fi 62 63%files 64%defattr(-,root,root) 65/usr/src/%{module}-%{version} 66 67%post 68for POSTINST in /usr/lib/dkms/common.postinst; do 69 if [ -f $POSTINST ]; then 70 $POSTINST %{module} %{version} 71 exit $? 72 fi 73 echo "WARNING: $POSTINST does not exist." 74done 75echo -e "ERROR: DKMS version is too old and %{module} was not" 76echo -e "built with legacy DKMS support." 77echo -e "You must either rebuild %{module} with legacy postinst" 78echo -e "support or upgrade DKMS to a more current version." 79exit 1 80 81%preun 82# Are we doing an upgrade? 83if [ "$1" = "1" -o "$1" = "upgrade" ] ; then 84 # Yes we are. Are we upgrading to a new ZFS version? 85 NEWEST_VER=$(dkms status zfs | sed 's/,//g' | sort -r -V | awk '/installed/{print $2; exit}') 86 if [ "$NEWEST_VER" != "%{version}" ] ; then 87 # Yes, it's a new ZFS version. We'll uninstall the old module 88 # later on in this script. 89 true 90 else 91 # No, it's probably an upgrade of the same ZFS version 92 # to a new distro (zfs-dkms-0.7.12.fc28->zfs-dkms-0.7.12.fc29). 93 # Don't remove our modules, since the rebuild for the new 94 # distro will automatically delete the old modules. 95 exit 0 96 fi 97fi 98 99# If we're here then we're doing an uninstall (not upgrade). 100CONFIG_H="/var/lib/dkms/%{module}/%{version}/*/*/%{module}_config.h" 101SPEC_META_ALIAS="@PACKAGE@-@VERSION@-@RELEASE@" 102DKMS_META_ALIAS=`cat $CONFIG_H 2>/dev/null | 103 awk -F'"' '/META_ALIAS\s+"/ { print $2; exit 0 }'` 104if [ "$SPEC_META_ALIAS" = "$DKMS_META_ALIAS" ]; then 105 echo -e 106 echo -e "Uninstall of %{module} module ($SPEC_META_ALIAS) beginning:" 107 dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade} 108fi 109exit 0 110