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