-%define module @PACKAGE@
+%bcond_without servers
+%bcond_without zfs
+%bcond_with ldiskfs
+
+# Set the package name prefix
+%if %{with servers}
+ %if %{with zfs}
+ %if %{with ldiskfs}
+ %define module @PACKAGE@-all
+ %else
+ %define module @PACKAGE@-zfs
+ %endif
+ %else
+ %if %{without ldiskfs}
+ %define module @PACKAGE@-BADSTATE
+ %else
+ %define module @PACKAGE@-ldiskfs
+ %endif
+ %endif
+ %define lustre_name @PACKAGE@
+
+%else
+ %define module @PACKAGE@-client
+ %define lustre_name @PACKAGE@-client
+%endif
+
+%if %{_vendor}=="redhat" || %{_vendor}=="fedora"
+ %global kmod_name kmod-%{lustre_name}
+ %define mkconf_options %{nil}
+%else #for Suse / Ubuntu
+ %global kmod_name %{lustre_name}-kmp
+ %define mkconf_options "-k updates"
+%endif
+
%define buildid 1
%define mkconf lustre/scripts/dkms.mkconf
+# There should be a better (non-arch dependent) way to require ext4
+# sources
+%define ext4_source_rpm kernel-debuginfo-common-x86_64
+
Name: %{module}-dkms
Version: @VERSION@
Group: System Environment/Kernel
License: GPLv2+
URL: http://lustre.opensfs.org/
-Source0: %{module}-%{version}.tar.gz
+Source0: @PACKAGE@-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: dkms >= 2.2.0.2
-Requires: spl-dkms >= 0.6.1
-Requires: zfs-dkms >= 0.6.1
+# DKMS >= 2.2.0.3-28.git.7c3e7c5 to fully support inter-modules deps
+# (ie, "BUILD_DEPENDS[#]=<pkg>"), and have latest DKMS fixes integrated
+# for bugs that prevented our module to build/install.
+Requires: dkms >= 2.2.0.3-28.git.7c3e7c5
+# for lnetctl
+Requires: libyaml-devel
+Requires: zlib-devel
+%if %{with servers}
+# If client package is installed when installing server, remove it since
+# the server package also includes the client. This can be removed if/when
+# the packages are split into independent client/server/common packages.
+Obsoletes: @PACKAGE@-client < %{version}
+%if %{with zfs}
+Requires: zfs-dkms >= 0.6.5
+Requires: @PACKAGE@-osd-zfs-mount
+Conflicts: @PACKAGE@-ldiskfs-dkms
+Conflicts: @PACKAGE@-client-dkms
+# lustre-zfs-dkms replicates the functionality old lustre-dkms package
+Provides: @PACKAGE@-dkms
+Obsoletes: @PACKAGE@-dkms
+%endif
+%if %{with ldiskfs}
+Requires: patch
+Requires: %{ext4_source_rpm}
+Requires: @PACKAGE@-osd-ldiskfs-mount
+Conflicts: @PACKAGE@-zfs-dkms
+Conflicts: @PACKAGE@-client-dkms
+%if "%{module}" != "@PACKAGE@-all"
+Conflicts: @PACKAGE@-dkms
+%endif
+%endif
+%if "%{module}" != "@PACKAGE@-all"
+Conflicts: @PACKAGE@-all-dkms
+%endif
+%endif
Requires: gcc, make, perl
Requires: kernel-devel
-Provides: %{module}-kmod = %{version}
-Provides: %{module}-modules = %{version}
+Provides: %{kmod_name} = %{version}
+Provides: @PACKAGE@-modules = %{version}
+%if %{with servers}
+%if %{with zfs}
+Provides: @PACKAGE@-osd-zfs = %{version}
+%endif
+%if %{with ldiskfs}
+Provides: @PACKAGE@-osd-ldiskfs = %{version}
+%endif
+Provides: @PACKAGE@-osd
+%else
+Provides: @PACKAGE@-client
+%endif
%description
This package contains the dkms Lustre kernel modules.
+%if %{with ldiskfs}
+
+The required %{ext4_source_rpm} package is available from
+the repository with other debuginfo rpms.
+%endif
%prep
-%setup -q -n %{module}-%{version}
+%setup -q -n @PACKAGE@-%{version}
%build
-%{mkconf} -n %{module} -v %{version} -f dkms.conf
-sed -i 's/BUILDID[[:print:]]*/BUILDID = %{buildid}/' META
-sed -i 's/PRISTINE[[:print:]]*/PRISTINE = 1/' META
-cp META ldiskfs/META
+%{mkconf} -n %{module} -v %{version} -f dkms.conf %{mkconf_options}
%install
if [ "$RPM_BUILD_ROOT" != "/" ]; then
rm -rf $RPM_BUILD_ROOT
fi
mkdir -p $RPM_BUILD_ROOT/usr/src/
-cp -rfp ${RPM_BUILD_DIR}/%{module}-%{version} $RPM_BUILD_ROOT/usr/src/
+cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
+mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
%clean
if [ "$RPM_BUILD_ROOT" != "/" ]; then
exit 0
%changelog
-* Fri Apr 8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
+* Wed May 16 2018 Joe Grund <joe.grund@intel.com>
+- Add patch requirement
+* Mon Aug 1 2016 Nathaniel Clark <nathaniel.l.clark@intel.com>
+- Add option to build either ldiskfs or zfs flavour of server version
+* Sat Jan 23 2016 Bruno Faccini <bruno.faccini@intel.com>
+ - detect and handle cases where [spl,zfs]-dkms packages are not built
+ - also handle on-target configure issues
+* Wed Oct 7 2015 Bruno Faccini <bruno.faccini@intel.com>
+ - adapted for Lustre Client DKMS creation
+ - allow for on-target reconfig to prevent static deps requires
+* Mon Apr 8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
- First DKMS packages.