1 %{?!packager: %define packager Brian Behlendorf <behlendorf1@llnl.gov>}
3 %if ! 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}
7 # Exclude input files from mangling
8 %global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$
10 %define module @PACKAGE@
11 %define mkconf scripts/dkms.mkconf
16 Release: @RELEASE@%{?dist}
17 Summary: Kernel module(s) (dkms)
19 Group: System Environment/Kernel
20 License: @ZFS_META_LICENSE@
21 URL: https://github.com/openzfs/zfs
22 Source0: %{module}-%{version}.tar.gz
23 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
26 Requires: dkms >= 2.2.0.3
27 Requires: gcc, make, perl, diffutils
28 %if 0%{?rhel}%{?fedora}%{?mageia}%{?suse_version}
29 Requires: kernel-devel
32 Provides: %{module}-kmod = %{version}
36 This package contains the dkms ZFS kernel modules.
39 %setup -q -n %{module}-%{version}
42 %{mkconf} -n %{module} -v %{version} -f dkms.conf
45 if [ "$RPM_BUILD_ROOT" != "/" ]; then
46 rm -rf $RPM_BUILD_ROOT
48 mkdir -p $RPM_BUILD_ROOT/usr/src/
49 cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
52 if [ "$RPM_BUILD_ROOT" != "/" ]; then
53 rm -rf $RPM_BUILD_ROOT
58 /usr/src/%{module}-%{version}
61 for POSTINST in /usr/lib/dkms/common.postinst; do
62 if [ -f $POSTINST ]; then
63 $POSTINST %{module} %{version}
66 echo "WARNING: $POSTINST does not exist."
68 echo -e "ERROR: DKMS version is too old and %{module} was not"
69 echo -e "built with legacy DKMS support."
70 echo -e "You must either rebuild %{module} with legacy postinst"
71 echo -e "support or upgrade DKMS to a more current version."
75 # Are we doing an upgrade?
76 if [ "$1" = "1" -o "$1" = "upgrade" ] ; then
77 # Yes we are. Are we upgrading to a new ZFS version?
78 NEWEST_VER=$(dkms status zfs | sed 's/,//g' | sort -r -V | awk '/installed/{print $2; exit}')
79 if [ "$NEWEST_VER" != "%{version}" ] ; then
80 # Yes, it's a new ZFS version. We'll uninstall the old module
81 # later on in this script.
84 # No, it's probably an upgrade of the same ZFS version
85 # to a new distro (zfs-dkms-0.7.12.fc28->zfs-dkms-0.7.12.fc29).
86 # Don't remove our modules, since the rebuild for the new
87 # distro will automatically delete the old modules.
92 # If we're here then we're doing an uninstall (not upgrade).
93 CONFIG_H="/var/lib/dkms/%{module}/%{version}/*/*/%{module}_config.h"
94 SPEC_META_ALIAS="@PACKAGE@-@VERSION@-@RELEASE@"
95 DKMS_META_ALIAS=`cat $CONFIG_H 2>/dev/null |
96 awk -F'"' '/META_ALIAS\s+"/ { print $2; exit 0 }'`
97 if [ "$SPEC_META_ALIAS" = "$DKMS_META_ALIAS" ]; then
99 echo -e "Uninstall of %{module} module ($SPEC_META_ALIAS) beginning:"
100 dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade}