Whamcloud - gitweb
LU-10858 build: handle yaml library packaging on SLES systems
[fs/lustre-release.git] / lustre.spec.in
1 # lustre.spec
2
3 # Declare rpmbuild --with/--without parameters
4 %bcond_without servers
5 %bcond_without ldiskfs
6 %bcond_with zfs
7 %bcond_without lustre_tests
8 %bcond_without lustre_utils
9 %bcond_without lustre_iokit
10 %bcond_without lustre_modules
11 %bcond_with snmp
12 %bcond_without gss_keyring
13 %bcond_without manpages
14 %bcond_without shared
15 %bcond_without static
16 %bcond_with    systemd
17
18 %if %{without servers}
19     # --without servers overrides --with {ldiskfs|zfs}
20     # so undefine the internal variables set by bcond_*
21     %undefine with_ldiskfs
22     %undefine with_zfs
23 %endif
24
25 %{!?version: %global version @VERSION@}
26 %{!?kver:    %global kver    %(uname -r)}
27 %{!?kdir:    %global kdir    /lib/modules/%{kver}/source}
28 %{!?kobjdir: %global kobjdir %(if [ "%{kdir}" = "/lib/modules/%{kver}/source" ]; then echo "/lib/modules/%{kver}/build"; else echo "%{kdir}"; fi)}
29
30 # as an alternative to this implementation we could simply "make -C $kdir kernelversion"
31 %{!?kversion: %global kversion %(files="include/generated/utsrelease.h include/linux/utsrelease.h include/linux/version.h"; for f in $files; do if test -r %{kobjdir}/$f && grep UTS_RELEASE %{kobjdir}/$f >/dev/null; then sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %{kobjdir}/$f; break; fi; done)}
32
33 # We set this because kernel_module_package has its own method of identifying
34 # which kernel to build against, and it is unlikely that its decision will
35 # match with Lustre's method of selecting which kernel to build against.
36 # By setting this variable, we override kernel_module_package's kernel
37 # selection with our selection.
38 %{!?kernel_version: %global kernel_version %kversion}
39
40 # in order to get kernel symset and/or kernel module dependencies into
41 # the RPM, in order to support weak-modules, the internal dependency gen-
42 # erator needs to be disabled
43 # this is done with (reduce the double % down to a single %):
44 #
45 # %%global _use_internal_dependency_generator 0
46 #
47 # on SLES10, /usr/lib/rpm/macros already sets this, so no harm in also
48 # defining it here (until Suse changes their mind)
49 #
50 # on RHEL5, however, we do need to explicitly disable the internal dep-
51 # endency generator and allow the external one be used
52 # but since RedHat's kABI is only a subset of the total kernel ABI, it
53 # doesn't include all of the symbols we (or OFED for that matter) need
54 # until RedHat includes all of the symbols we need in their symsets we
55 # cannot support weak-modules
56 # we did e-mail the maintainer of all of this stuff @redhat but got no
57 # response from them
58 #%%global _use_internal_dependency_generator 0
59
60 # Set the package name prefix
61 %if %{undefined lustre_name}
62     %if %{with servers}
63         %global lustre_name lustre
64     %else
65         %global lustre_name lustre-client
66     %endif
67 %endif
68
69 %if %{undefined kmoddir}
70     %if %{defined kernel_module_package_moddir}
71         %global kmoddir %{kernel_module_package_moddir}
72     %else
73         %if %{defined suse_kernel_module_package}
74             %global kmoddir updates
75         %else
76             %global kmoddir extra
77         %endif
78     %endif
79 %endif
80
81 %global modules_fs_path /lib/modules/%{kversion}/%{kmoddir}
82
83 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
84         %global requires_yaml_name libyaml
85         %global requires_kmod_name kmod-%{lustre_name}
86         %if %{with lustre_tests}
87                 %global requires_kmod_tests_name kmod-%{lustre_name}-tests
88         %endif
89         %global requires_kmod_version %{version}
90 %else   #for Suse
91         %global requires_yaml_name libyaml-0-2
92         %global requires_kmod_name %{lustre_name}-kmp
93         %if %{with lustre_tests}
94                 %global requires_kmod_tests_name %{lustre_name}-tests-kmp
95         %endif
96         %define krequires %(echo %{kversion} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/[-.]ppc64$//' -e 's/\.aarch64$//' -e 's/-default$//')
97         %if 0%{?suse_version} >= 1200
98                 %global requires_kmod_version %{version}_k%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;')
99         %else
100                 %global requires_kmod_version %{version}_%(echo %{krequires} | sed -r 'y/-/_/; s/^(2\.6\.[0-9]+)_/\\1.0_/;')
101         %endif
102 %endif
103
104 # RHEL >= 7 comes with systemd
105 %if 0%{?rhel} >= 7
106 %define with_systemd 1
107 %endif
108
109 # Fedora >= 15 comes with systemd, but only >= 18 has
110 # the proper macros
111 %if 0%{?fedora} >= 18
112 %define with_systemd 1
113 %endif
114
115 # opensuse >= 12.1 comes with systemd, but only >= 13.1
116 # has the proper macros
117 %if 0%{?suse_version} >= 1310
118 %define with_systemd 1
119 %endif
120
121 Summary: Lustre File System
122 Name: %{lustre_name}
123 Version: %{version}
124 Release: 1%{?dist}
125 License: GPL
126 Group: System Environment/Kernel
127 Source: lustre-%{version}.tar.gz
128 Source1: kmp-lustre.preamble
129 Source2: kmp-lustre.files
130 Source3: kmp-lustre-osd-ldiskfs.preamble
131 Source4: kmp-lustre-osd-ldiskfs.files
132 Source5: kmp-lustre-osd-zfs.preamble
133 Source6: kmp-lustre-osd-zfs.files
134 Source7: kmp-lustre-tests.files
135 URL: https://wiki.hpdd.intel.com/
136 BuildRoot: %{_tmppath}/lustre-%{version}-root
137 Requires: %{requires_kmod_name} = %{requires_kmod_version} zlib
138 Requires: %{requires_yaml_name}
139 BuildRequires: libtool libyaml-devel zlib-devel
140 %if %{with servers}
141 Requires: lustre-osd
142 Requires: lustre-osd-mount
143 Obsoletes: lustre-client < %{version}
144 Provides: lustre-client = %{version}-%{release}
145 %endif
146 # GSS requires this: BuildRequires: pkgconfig, libgssapi-devel >= 0.10
147 %if %{_vendor}=="redhat" || %{_vendor}=="fedora"
148 #suse don't support selinux
149 BuildRequires: libselinux-devel
150 Requires: libselinux
151 %endif
152 %if %{with lustre_modules}
153 BuildRequires: %kernel_module_package_buildreqs
154 %if %{_vendor}=="redhat"
155 BuildRequires: redhat-rpm-config
156 %endif
157 %endif
158
159 %if %{with systemd}
160 Requires(post): systemd
161 Requires(preun): systemd
162 Requires(postun): systemd
163 BuildRequires: systemd
164 %endif
165
166 %description
167 Userspace tools and files for the Lustre file system.
168
169 %if %{with lustre_modules}
170 %kernel_module_package -n %{name} -p %SOURCE1 -f %SOURCE2 default
171
172 %if %{with ldiskfs}
173 %kernel_module_package -n %{name}-osd-ldiskfs -p %SOURCE3 -f %SOURCE4 default
174 %if %{with lustre_utils}
175 %package osd-ldiskfs-mount
176 Summary: osd-ldiskfs-mount contains mount's ldiskfs specific dso.
177 Provides: lustre-osd-mount = %{version}-%{fullrelease}
178 Group: System Environment/Kernel
179
180 %description osd-ldiskfs-mount
181 LDISKFS hooks for mount/mkfs into a dynamic library.
182
183 %endif  # with lustre_utils
184 %endif  # with ldiskfs
185
186 %if %{with zfs}
187 %kernel_module_package -n %{name}-osd-zfs -p %SOURCE5 -f %SOURCE6 default
188 %if %{with lustre_utils}
189 %package osd-zfs-mount
190 Summary: osd-zfs-mount contains mount's zfs specific dso.
191 Provides: lustre-osd-mount = %{version}-%{fullrelease}
192 Group: System Environment/Kernel
193
194 %description osd-zfs-mount
195 ZFS hooks for mount/mkfs into a dynamic library.
196
197 %endif  # with lustre_utils
198 %endif  # with zfs
199
200 %endif # with lustre_modules
201
202 %if %{with servers}
203 %package resource-agents
204 Summary: HA Resuable Cluster Resource Scripts for Lustre
205 Group: System Environment/Base
206 Requires: lustre
207 Requires: resource-agents
208
209 %description resource-agents
210 A set of scripts to operate Lustre resources in a High Availablity
211 environment for both Pacemaker and rgmanager.
212 %endif
213
214 %if %{with lustre_tests}
215 %package tests
216 Summary: Lustre testing framework
217 Group: System Environment/Kernel
218 Provides: %{name}-tests = %{version}
219 %if %{with lustre_iokit}
220 Requires: %{name} = %{version}, lustre-iokit
221 %else
222 Requires: %{name} = %{version}
223 %endif
224 Requires: %{requires_kmod_name} = %{requires_kmod_version}
225 Requires: %{requires_kmod_tests_name} = %{requires_kmod_version}
226 Requires: attr, rsync, perl, lsof, /usr/bin/getconf
227
228 %description tests
229 This package contains a set of test binaries and scripts that are intended
230 to be used by the Lustre testing framework.
231
232 %if %{with lustre_modules}
233 %kernel_module_package -n %{name}-tests -f %SOURCE7 default
234 %endif
235 %endif
236
237 %if %{with lustre_iokit}
238 %package -n lustre-iokit
239 Summary: The Lustre IO-Kit is a collection of benchmark tools for a cluster with the Lustre file system.
240 Group: Applications/System
241 Requires: python > 2.2, sg3_utils
242
243 %description -n lustre-iokit
244 This package includes five tools:
245 sgpdd-survey:
246 A test of the 'bare metal' performance, bypassing as much of the kernel as we can. Uses the sgp_dd utility.
247
248 obdfilter-survey
249 This survey can be run in 3 modes to test disk I/O including the filesystem,
250 network I/O, and disk I/O via the network.  The script does sequential I/O
251 with varying numbers of threads and objects (files) by using lctl::test_brw
252 to drive the echo_client connected to local or remote obdfilter instances,
253 or remote obdecho instances.
254
255 ost-survey
256 This survey tests the client-to-disk performance of individual OSTs, and
257 ranks then for comparison.
258
259 stats-collect
260 This script will collect IO stats on a defined set of nodes.
261
262 ior-survey:
263 A script to run the IOR benchmark. The latest version can be downloaded from
264 http://www.llnl.gov/asci/purple/benchmarks/limited/ior/
265
266 mds-survey:
267 This survey tests the local metadata performance using the echo_client to drive
268 the MDD layer to perform operations. It is run with multiple threads (to
269 simulate MDT service threads) locally on the MDS node, and does not need Lustre
270 clients in order to run
271 %endif
272
273 %if 0%{?suse_version}
274 %debug_package
275 %endif
276 %prep
277 %setup -qn lustre-%{version}
278 ln lustre/ChangeLog ChangeLog-lustre
279 ln lnet/ChangeLog ChangeLog-lnet
280
281 %build
282 # Set an explicit path to our Linux tree, if we can.
283 cd $RPM_BUILD_DIR/lustre-%{version}
284 # override %optflags so that the vendor's overzealous flags don't create
285 # build failures
286 %define optflags -g -O2 -Werror
287
288 CONFIGURE_ARGS="%{?configure_args}"
289 if [ -n "$CONFIGURE_ARGS" ]; then
290         # make sure %%kdir and %%kobjdir are not in the configure arguments
291         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
292         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//')
293         # remove --with-kmp-moddir from configure arguments,
294         # it will be set --with-kmp-moddir=%%kmoddir
295         CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-kmp-moddir=[^ ][^ ]* \?//')
296 fi
297
298 # we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
299 # string in it which we don't want word splitted by the shell
300 # also remove (build|host|target) options because they will be specified
301 # inside $CONFIGURE_ARGS
302 # kmod tools/scripts require %{name} directory with kernel modules
303 %define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
304
305 %eval_configure $CONFIGURE_ARGS \
306         %{?with_lustre_tests:--enable-tests}%{!?with_lustre_tests:--disable-tests} \
307         %{?with_lustre_utils:--enable-utils}%{!?with_lustre_utils:--disable-utils} \
308         %{?with_lustre_modules:--enable-modules}%{!?with_lustre_modules:--disable-modules} \
309         %{!?with_shared:--disable-shared} \
310         %{!?with_static:--disable-static} \
311         %{!?with_lustre_iokit:--disable-iokit} \
312         %{!?with_ldiskfs:--disable-ldiskfs} \
313         %{!?with_servers:--disable-server} \
314         %{!?with_zfs:--without-zfs} \
315         %{!?with_snmp:--disable-snmp} \
316         %{!?with_gss_keyring:--disable-gss-keyring} \
317         %{!?with_manpages:--disable-manpages} \
318         %{!?with_systemd:--with-systemdsystemunitdir=no} \
319         %{?with_systemd:--with-systemdsystemunitdir=%{_unitdir}} \
320         --with-linux=%{kdir} \
321         --with-linux-obj=%{kobjdir} \
322         --with-kmp-moddir=%{kmoddir}/%{name}
323
324 make %{?_smp_mflags} -s %{?make_args}
325
326 %install
327 make install DESTDIR=$RPM_BUILD_ROOT
328
329 # RHEL's kernel_module_path macro expects that all the modules
330 # in a kmod package will be in modules_fs_path/<sub packagename>
331 # but Lustre installs all of the modules in a single pass into
332 # a shared location.  Since this is a restriction imposed by
333 # RHEL, we handle this here in the spec file rather than in
334 # Lustre's build system.  This is not expected to bother SLES's
335 # kernel_module_path macro.
336 basemodpath=$RPM_BUILD_ROOT%{modules_fs_path}/%{lustre_name}
337 %if %{with ldiskfs}
338 mkdir -p $basemodpath-osd-ldiskfs/fs
339 mv $basemodpath/fs/osd_ldiskfs.ko $basemodpath-osd-ldiskfs/fs/osd_ldiskfs.ko
340 mv $basemodpath/fs/ldiskfs.ko $basemodpath-osd-ldiskfs/fs/ldiskfs.ko
341 %endif
342 %if %{with zfs}
343 mkdir -p $basemodpath-osd-zfs/fs
344 mv $basemodpath/fs/osd_zfs.ko $basemodpath-osd-zfs/fs/osd_zfs.ko
345 %endif
346 %if %{with lustre_tests}
347 mkdir -p $basemodpath-tests/fs
348 mv $basemodpath/fs/llog_test.ko $basemodpath-tests/fs/llog_test.ko
349 mkdir -p $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/
350 mv $basemodpath/fs/kinode.ko $RPM_BUILD_ROOT%{_libdir}/lustre/tests/kernel/
351 %endif
352
353 :> lustre.files
354
355 %if %{with servers} && %{with lustre_utils}
356 # The .ha_v2 extension identifies the heartbeat resource agent as using
357 # legacy syntax. Install a compatibility symlink to avoid conflicts when
358 # newer-style agents are added.
359 ln -s Lustre.ha_v2 $RPM_BUILD_ROOT%{_sysconfdir}/ha.d/resource.d/Lustre
360 echo '%{_sysconfdir}/ha.d/resource.d/Lustre.ha_v2' >>lustre.files
361 echo '%{_sysconfdir}/ha.d/resource.d/Lustre' >>lustre.files
362 %endif
363
364 # systemd is on redhat, fedora, and suse
365 %if %{with systemd}
366 echo '%{_unitdir}/lnet.service' >>lustre.files
367 %endif
368
369 %if %{_vendor}=="redhat"
370 # The following scripts are Red Hat specific
371 %if %{with servers}
372 echo '%{_sysconfdir}/init.d/lustre' >>lustre.files
373 echo '%{_sysconfdir}/sysconfig/lustre' >>lustre.files
374 %if %{with gss_keyring}
375 echo '%{_sysconfdir}/init.d/lsvcgss' >>lustre.files
376 echo '%{_sysconfdir}/sysconfig/lsvcgss' >>lustre.files
377 %endif
378 %endif
379
380 %if %{without systemd}
381 echo '%{_sysconfdir}/init.d/lnet' >>lustre.files
382 %endif
383 %endif
384
385 CONFIGURE_ARGS="%{?configure_args}"
386 if [ -z "$(echo $CONFIGURE_ARGS | grep "\-\-disable\-gss\-keyring")" ]; then
387     echo '%config(noreplace) %{_sysconfdir}/request-key.d/lgssc.conf' >>lustre.files
388 fi
389
390 %if %{with servers}
391 mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/lustre/
392 install -m 0755 contrib/scripts/pacemaker/* $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/lustre/
393 %endif
394
395 # fc18 needs 'x' permission for library files
396 find $RPM_BUILD_ROOT -name \*.so -type f -exec chmod +x {} \;
397
398 rm -f $RPM_BUILD_ROOT%{_libdir}/liblnetconfig.la
399 %if %{with static}
400 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.a' >>lustre.files
401 %endif
402 %if %{with shared}
403 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so' >>lustre.files
404 echo '%attr(-, root, root) %{_libdir}/liblnetconfig.so.*' >>lustre.files
405 %endif
406
407 %if %{with ldiskfs}
408 echo '%{_libdir}/libiam.a' >>lustre.files
409 %endif
410
411 %if %{with snmp}
412 mkdir -p $RPM_BUILD_ROOT/%{_libdir}/lustre/snmp
413 echo '%{_libdir}/lustre/snmp' >>lustre.files
414 %endif
415
416 %if %{with lustre_utils}
417 mkdir -p $RPM_BUILD_ROOT/%{_datadir}/lustre
418 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre ] ; then
419         find $RPM_BUILD_ROOT%{_libdir}/@PACKAGE@ -name \*.la -type f -exec rm -f {} \;
420 fi
421 %endif
422
423 %if %{with lustre_modules}
424 # mark modules executable for find-debuginfo.sh
425 find $RPM_BUILD_ROOT/lib/modules -name \*.ko -type f -exec chmod u+x {} \;
426 %endif
427
428 rm -f $RPM_BUILD_ROOT%{_libdir}/liblustreapi.la
429
430 %if %{with lustre_tests}
431 :> lustre-tests.files
432 echo '%{_libdir}/lustre/tests/*' >>lustre-tests.files
433 echo '%{_bindir}/mcreate' >>lustre-tests.files
434 echo '%{_bindir}/munlink' >>lustre-tests.files
435 echo '%{_sbindir}/wirecheck' >>lustre-tests.files
436 echo '%{_sbindir}/wiretest' >>lustre-tests.files
437 %endif
438
439 %files -f lustre.files
440 %defattr(-,root,root)
441 %{_sbindir}/*
442 %if %{with lustre_tests}
443 %exclude %{_sbindir}/wirecheck
444 %exclude %{_sbindir}/wiretest
445 %endif
446 %if %{with zfs}
447 %exclude %{_sbindir}/zfsobj2fid
448 %endif
449 %if %{with lustre_utils}
450 %if %{with servers}
451 %{_libexecdir}/lustre/lc_common
452 %{_libexecdir}/lustre/haconfig
453 %{_bindir}/lustre_req_history
454 %endif
455
456 %{_bindir}/llobdstat
457 %{_bindir}/llstat
458 %{_bindir}/plot-llstat
459
460 %{_bindir}/lfs
461 %{_bindir}/lfs_migrate
462 /sbin/mount.lustre
463 %if %{with static}
464 %{_libdir}/liblustreapi.a
465 %endif
466 %if %{with shared}
467 %{_libdir}/liblustreapi.so*
468 %endif
469 %if %{with manpages}
470 %{_mandir}/man?/*
471 %endif
472 %{_datadir}/lustre
473 %{_includedir}/lustre
474 %{_includedir}/linux/lnet
475 %{_includedir}/linux/lustre
476 %endif
477 %{_sysconfdir}/udev/rules.d/99-lustre.rules
478 %if %{with zfs}
479 %config(noreplace) %{_sysconfdir}/ldev.conf
480 %endif
481 %config(noreplace) %{_sysconfdir}/lnet.conf
482 %config(noreplace) %{_sysconfdir}/modprobe.d/ko2iblnd.conf
483 %if %{with lustre_utils}
484 %config(noreplace) %{_sysconfdir}/lnet_routes.conf
485 %endif
486 %if %{with lustre_modules}
487
488 %if %{with shared}
489 %if %{with ldiskfs}
490 %if %{with lustre_utils}
491 %files osd-ldiskfs-mount
492 %defattr(-,root,root)
493 %{_libdir}/@PACKAGE@/mount_osd_ldiskfs.so
494 %endif
495 %endif
496 %endif
497
498 %if %{with shared}
499 %if %{with zfs}
500 %if %{with lustre_utils}
501 %files osd-zfs-mount
502 %defattr(-,root,root)
503 %{_libdir}/@PACKAGE@/mount_osd_zfs.so
504 %{_sysconfdir}/zfs/zed.d/*
505 %endif
506 %endif
507 %endif
508
509 %endif # with lustre_modules
510
511 %if %{with servers}
512 %files resource-agents
513 %defattr(0755,root,root)
514 %{_prefix}/lib/ocf/resource.d/lustre/
515 %endif
516
517 %if %{with lustre_tests}
518 %files tests -f lustre-tests.files
519 %defattr(-,root,root)
520 %endif
521
522 %if %{with lustre_iokit}
523 %files -n lustre-iokit
524 %defattr(-, root, root)
525 %{_bindir}/iokit-config
526 %{_bindir}/iokit-gather-stats
527 %{_bindir}/iokit-libecho
528 %{_bindir}/iokit-lstats
529 %{_bindir}/iokit-parse-ior
530 %{_bindir}/iokit-plot-obdfilter
531 %{_bindir}/iokit-plot-ost
532 %{_bindir}/iokit-plot-sgpdd
533 %{_bindir}/ior-survey
534 %{_bindir}/mds-survey
535 %{_bindir}/obdfilter-survey
536 %{_bindir}/ost-survey
537 %{_bindir}/sgpdd-survey
538 %doc lustre-iokit/ior-survey/README.ior-survey
539 %doc lustre-iokit/mds-survey/README.mds-survey
540 %doc lustre-iokit/obdfilter-survey/README.obdfilter-survey
541 %doc lustre-iokit/ost-survey/README.ost-survey
542 %doc lustre-iokit/sgpdd-survey/README.sgpdd-survey
543 %doc lustre-iokit/stats-collect/README.iokit-lstats
544 %endif
545
546 %post
547 %if %{with systemd}
548 %systemd_post lnet.service
549 %endif
550
551 %preun
552 %if %{with systemd}
553 %systemd_preun lnet.service
554 %endif
555
556 %postun
557 %if %{with systemd}
558 %systemd_postun_with_restart lnet.service
559 %endif
560
561 %clean
562 rm -rf $RPM_BUILD_ROOT
563 rm -rf %{_tmppath}/kmp