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