]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/openzfs/rpm/generic/zfs-dkms.spec.in
Update OpenZFS to 2.0.0-rc3-gfc5966
[FreeBSD/FreeBSD.git] / sys / contrib / openzfs / rpm / generic / zfs-dkms.spec.in
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
13 Name:           %{module}-dkms
14
15 Version:        @VERSION@
16 Release:        @RELEASE@%{?dist}
17 Summary:        Kernel module(s) (dkms)
18
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)
24 BuildArch:      noarch
25
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
30 Obsoletes:      spl-dkms
31 %endif
32 Provides:       %{module}-kmod = %{version}
33 AutoReqProv:    no
34
35 %description
36 This package contains the dkms ZFS kernel modules.
37
38 %prep
39 %setup -q -n %{module}-%{version}
40
41 %build
42 %{mkconf} -n %{module} -v %{version} -f dkms.conf
43
44 %install
45 if [ "$RPM_BUILD_ROOT" != "/" ]; then
46     rm -rf $RPM_BUILD_ROOT
47 fi
48 mkdir -p $RPM_BUILD_ROOT/usr/src/
49 cp -rf ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
50
51 %clean
52 if [ "$RPM_BUILD_ROOT" != "/" ]; then
53     rm -rf $RPM_BUILD_ROOT
54 fi
55
56 %files
57 %defattr(-,root,root)
58 /usr/src/%{module}-%{version}
59
60 %post
61 for POSTINST in /usr/lib/dkms/common.postinst; do
62     if [ -f $POSTINST ]; then
63         $POSTINST %{module} %{version}
64         exit $?
65     fi
66     echo "WARNING: $POSTINST does not exist."
67 done
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."
72 exit 1
73
74 %preun
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.
82                 true
83         else
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.
88                 exit 0
89         fi
90 fi
91
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
98     echo -e
99     echo -e "Uninstall of %{module} module ($SPEC_META_ALIAS) beginning:"
100     dkms remove -m %{module} -v %{version} --all %{!?not_rpm:--rpm_safe_upgrade}
101 fi
102 exit 0