Whamcloud - gitweb
LU-6142 lustre: use list_first_entry() in lustre subdirectory.
[fs/lustre-release.git] / lustre-dkms.spec.in
1 %bcond_without servers
2 %bcond_without zfs
3 %bcond_with ldiskfs
4
5 # Set the package name prefix
6 %if %{with servers}
7     %if %{with zfs}
8         %if %{with ldiskfs}
9             %define module @PACKAGE@-all
10         %else
11             %define module @PACKAGE@-zfs
12         %endif
13     %else
14         %if %{without ldiskfs}
15             %define module @PACKAGE@-BADSTATE
16         %else
17             %define module @PACKAGE@-ldiskfs
18         %endif
19     %endif
20     %define lustre_name @PACKAGE@
21
22 %else
23     %define module @PACKAGE@-client
24     %define lustre_name @PACKAGE@-client
25 %endif
26
27 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
28         %global kmod_name kmod-%{lustre_name}
29         %define mkconf_options %{nil}
30 %else   #for Suse / Ubuntu
31         %global kmod_name %{lustre_name}-kmp
32         %define mkconf_options "-k updates"
33 %endif
34
35 %define buildid 1
36 %define mkconf  lustre/scripts/dkms.mkconf
37
38 # There should be a better (non-arch dependent) way to require ext4
39 # sources
40 %define ext4_source_rpm kernel-debuginfo-common-x86_64
41
42 Name:           %{module}-dkms
43
44 Version:        @VERSION@
45 Release:        %{buildid}%{?dist}
46 Summary:        Kernel module(s) (dkms)
47
48 Group:          System Environment/Kernel
49 License:        GPLv2+
50 URL:            http://lustre.opensfs.org/
51 Source0:        @PACKAGE@-%{version}.tar.gz
52 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
53 BuildArch:      noarch
54
55 # DKMS >= 2.2.0.3-28.git.7c3e7c5 to fully support inter-modules deps
56 # (ie, "BUILD_DEPENDS[#]=<pkg>"), and have latest DKMS fixes integrated
57 # for bugs that prevented our module to build/install.
58 Requires:       dkms >= 2.2.0.3-28.git.7c3e7c5
59 # for lnetctl
60 Requires:       libyaml-devel
61 Requires:       zlib-devel
62 # for netlink support
63 Requires:       libnl3-devel
64 %if %{with servers}
65 # If client package is installed when installing server, remove it since
66 # the server package also includes the client.  This can be removed if/when
67 # the packages are split into independent client/server/common packages.
68 Obsoletes:      @PACKAGE@-client < %{version}
69 %if %{with zfs}
70 Requires:       zfs-dkms >= 0.6.5
71 Requires:       @PACKAGE@-osd-zfs-mount
72 Conflicts:      @PACKAGE@-ldiskfs-dkms
73 Conflicts:      @PACKAGE@-client-dkms
74 # lustre-zfs-dkms replicates the functionality old lustre-dkms package
75 Provides:       @PACKAGE@-dkms
76 Obsoletes:      @PACKAGE@-dkms
77 %endif
78 %if %{with ldiskfs}
79 Requires:       patch
80 Requires:       %{ext4_source_rpm}
81 Requires:       @PACKAGE@-osd-ldiskfs-mount
82 Conflicts:      @PACKAGE@-zfs-dkms
83 Conflicts:      @PACKAGE@-client-dkms
84 %if "%{module}" != "@PACKAGE@-all"
85 Conflicts:      @PACKAGE@-dkms
86 %endif
87 %endif
88 %if "%{module}" != "@PACKAGE@-all"
89 Conflicts:      @PACKAGE@-all-dkms
90 %endif
91 %endif
92 Requires:       gcc, make, perl
93 Requires:       kernel-devel
94 Provides:       %{kmod_name} = %{version}
95 Provides:       @PACKAGE@-modules = %{version}
96 %if %{with servers}
97 %if %{with zfs}
98 Provides:       @PACKAGE@-osd-zfs = %{version}
99 %endif
100 %if %{with ldiskfs}
101 Provides:       @PACKAGE@-osd-ldiskfs = %{version}
102 %endif
103 Provides:       @PACKAGE@-osd
104 %else
105 Provides:       @PACKAGE@-client
106 %endif
107
108 %description
109 This package contains the dkms Lustre kernel modules.
110 %if %{with ldiskfs}
111
112 The required %{ext4_source_rpm} package is available from
113 the repository with other debuginfo rpms.
114 %endif
115
116 %prep
117 %setup -q -n @PACKAGE@-%{version}
118
119 %build
120 %{mkconf} -n %{module} -v %{version} -f dkms.conf %{mkconf_options}
121
122 %install
123 if [ "$RPM_BUILD_ROOT" != "/" ]; then
124     rm -rf $RPM_BUILD_ROOT
125 fi
126 mkdir -p $RPM_BUILD_ROOT/usr/src/
127 cp -rfp ${RPM_BUILD_DIR}/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/
128 mv $RPM_BUILD_ROOT/usr/src/@PACKAGE@-%{version} $RPM_BUILD_ROOT/usr/src/%{module}-%{version}
129
130 %clean
131 if [ "$RPM_BUILD_ROOT" != "/" ]; then
132     rm -rf $RPM_BUILD_ROOT
133 fi
134
135 %files
136 %defattr(-,root,root)
137 /usr/src/%{module}-%{version}
138
139 %post
140 for POSTINST in /usr/lib/dkms/common.postinst; do
141     if [ -f $POSTINST ]; then
142         $POSTINST %{module} %{version}
143         exit $?
144     fi
145     echo "WARNING: $POSTINST does not exist."
146 done
147 echo -e "ERROR: DKMS version is too old and %{module} was not"
148 echo -e "built with legacy DKMS support."
149 echo -e "You must either rebuild %{module} with legacy postinst"
150 echo -e "support or upgrade DKMS to a more current version."
151 exit 1
152
153 %preun
154 dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade
155 exit 0
156
157 %changelog
158 * Wed May 16 2018 Joe Grund <joe.grund@intel.com>
159 - Add patch requirement
160 * Mon Aug  1 2016 Nathaniel Clark <nathaniel.l.clark@intel.com>
161 - Add option to build either ldiskfs or zfs flavour of server version
162 * Sat Jan 23 2016 Bruno Faccini <bruno.faccini@intel.com>
163  - detect and handle cases where [spl,zfs]-dkms packages are not built
164  - also handle on-target configure issues
165 * Wed Oct  7 2015 Bruno Faccini <bruno.faccini@intel.com>
166  - adapted for Lustre Client DKMS creation
167  - allow for on-target reconfig to prevent static deps requires
168 * Mon Apr  8 2013 Brian Behlendorf <behlendorf1@llnl.gov> - 2.3.63-1
169 - First DKMS packages.