ZTS: Increase zpool_import_parallel_pos import margin
[zfs.git] / rpm / generic / zfs.spec.in
blobd0d850af262992a3357669ea83dac96bf4bfb0c2
1 %global _sbindir /sbin
2 %global _libdir /%{_lib}
4 # Set the default udev directory based on distribution.
5 %if %{undefined _udevdir}
6 %if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}%{?openEuler}
7 %global _udevdir %{_prefix}/lib/udev
8 %else
9 %global _udevdir /lib/udev
10 %endif
11 %endif
13 # Set the default udevrule directory based on distribution.
14 %if %{undefined _udevruledir}
15 %if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}%{?openEuler}
16 %global _udevruledir %{_prefix}/lib/udev/rules.d
17 %else
18 %global _udevruledir /lib/udev/rules.d
19 %endif
20 %endif
22 # Set the default _bashcompletiondir directory based on distribution.
23 %if %{undefined _bashcompletiondir}
24 %if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}%{?openEuler}
25 %global _bashcompletiondir /etc/bash_completion.d
26 %else
27 %global _bashcompletiondir /usr/share/bash-completion
28 %endif
29 %endif
31 # Set the default dracut directory based on distribution.
32 %if %{undefined _dracutdir}
33 %if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}%{?openEuler}
34 %global _dracutdir %{_prefix}/lib/dracut
35 %else
36 %global _dracutdir %{_prefix}/share/dracut
37 %endif
38 %endif
40 %if %{undefined _initconfdir}
41 %global _initconfdir /etc/sysconfig
42 %endif
44 %if %{undefined _unitdir}
45 %global _unitdir %{_prefix}/lib/systemd/system
46 %endif
48 %if %{undefined _presetdir}
49 %global _presetdir %{_prefix}/lib/systemd/system-preset
50 %endif
52 %if %{undefined _modulesloaddir}
53 %global _modulesloaddir %{_prefix}/lib/modules-load.d
54 %endif
56 %if %{undefined _systemdgeneratordir}
57 %global _systemdgeneratordir %{_prefix}/lib/systemd/system-generators
58 %endif
60 %if %{undefined _pkgconfigdir}
61 %global _pkgconfigdir %{_prefix}/%{_lib}/pkgconfig
62 %endif
64 %bcond_with debug
65 %bcond_with debuginfo
66 %bcond_with asan
67 %bcond_with ubsan
68 %bcond_with systemd
69 %bcond_with pam
70 %bcond_without pyzfs
72 # Generic enable switch for systemd
73 %if %{with systemd}
74 %define _systemd 1
75 %endif
77 # Distros below support systemd
78 %if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}%{?openEuler}
79 %define _systemd 1
80 %endif
82 # When not specified default to distribution provided version.
83 %if %{undefined __use_python}
84 %define __python /usr/bin/python3
85 %define __python_pkg_version 3
86 %else
87 %define __python %{__use_python}
88 %define __python_pkg_version %{__use_python_pkg_version}
89 %endif
90 %define __python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())" 2>/dev/null || %{__python} -Esc "import sysconfig; print(sysconfig.get_path('purelib'))")
92 Name: @PACKAGE@
93 Version: @VERSION@
94 Release: @RELEASE@%{?dist}
95 Summary: Commands to control the kernel modules and libraries
97 Group: System Environment/Kernel
98 License: @ZFS_META_LICENSE@
99 URL: https://github.com/openzfs/zfs
100 Source0: %{name}-%{version}.tar.gz
101 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
102 Requires: libzpool6%{?_isa} = %{version}-%{release}
103 Requires: libnvpair3%{?_isa} = %{version}-%{release}
104 Requires: libuutil3%{?_isa} = %{version}-%{release}
105 Requires: libzfs6%{?_isa} = %{version}-%{release}
106 Requires: %{name}-kmod = %{version}
107 Provides: %{name}-kmod-common = %{version}-%{release}
108 Obsoletes: spl <= %{version}
110 # zfs-fuse provides the same commands and man pages that OpenZFS does.
111 # Renaming those on either side would conflict with all available documentation.
112 Conflicts: zfs-fuse
114 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
115 BuildRequires: gcc, make
116 BuildRequires: zlib-devel
117 BuildRequires: libuuid-devel
118 BuildRequires: libblkid-devel
119 BuildRequires: libudev-devel
120 BuildRequires: libattr-devel
121 BuildRequires: openssl-devel
122 %if 0%{?fedora}%{?suse_version}%{?openEuler} || 0%{?rhel} >= 8 || 0%{?centos} >= 8
123 BuildRequires: libtirpc-devel
124 %endif
126 %if (0%{?fedora}%{?suse_version}%{?openEuler}) || (0%{?rhel} && 0%{?rhel} < 9)
127 # We don't directly use it, but if this isn't installed, rpmbuild as root can
128 # crash+corrupt rpmdb
129 # See issue #12071
130 BuildRequires: ncompress
131 %endif
133 Requires: openssl
134 %if 0%{?_systemd}
135 BuildRequires: systemd
136 %endif
138 %endif
140 %if 0%{?_systemd}
141 Requires(post): systemd
142 Requires(preun): systemd
143 Requires(postun): systemd
144 %endif
146 # The zpool iostat/status -c scripts call some utilities like lsblk and iostat
147 Requires: util-linux
148 Requires: sysstat
150 %description
151 This package contains the core ZFS command line utilities.
153 %package -n libzpool6
154 Summary: Native ZFS pool library for Linux
155 Group: System Environment/Kernel
156 Obsoletes: libzpool2 <= %{version}
157 Obsoletes: libzpool4 <= %{version}
158 Obsoletes: libzpool5 <= %{version}
160 %description -n libzpool6
161 This package contains the zpool library, which provides support
162 for managing zpools
164 %if %{defined ldconfig_scriptlets}
165 %ldconfig_scriptlets -n libzpool6
166 %else
167 %post -n libzpool6 -p /sbin/ldconfig
168 %postun -n libzpool6 -p /sbin/ldconfig
169 %endif
171 %package -n libnvpair3
172 Summary: Solaris name-value library for Linux
173 Group: System Environment/Kernel
174 Obsoletes: libnvpair1 <= %{version}
176 %description -n libnvpair3
177 This package contains routines for packing and unpacking name-value
178 pairs. This functionality is used to portably transport data across
179 process boundaries, between kernel and user space, and can be used
180 to write self describing data structures on disk.
182 %if %{defined ldconfig_scriptlets}
183 %ldconfig_scriptlets -n libnvpair3
184 %else
185 %post -n libnvpair3 -p /sbin/ldconfig
186 %postun -n libnvpair3 -p /sbin/ldconfig
187 %endif
189 %package -n libuutil3
190 Summary: Solaris userland utility library for Linux
191 Group: System Environment/Kernel
192 Obsoletes: libuutil1 <= %{version}
194 %description -n libuutil3
195 This library provides a variety of compatibility functions for OpenZFS:
196 * libspl: The Solaris Porting Layer userland library, which provides APIs
197 that make it possible to run Solaris user code in a Linux environment
198 with relatively minimal modification.
199 * libavl: The Adelson-Velskii Landis balanced binary tree manipulation
200 library.
201 * libefi: The Extensible Firmware Interface library for GUID disk
202 partitioning.
203 * libshare: NFS, SMB, and iSCSI service integration for ZFS.
205 %if %{defined ldconfig_scriptlets}
206 %ldconfig_scriptlets -n libuutil3
207 %else
208 %post -n libuutil3 -p /sbin/ldconfig
209 %postun -n libuutil3 -p /sbin/ldconfig
210 %endif
212 # The library version is encoded in the package name. When updating the
213 # version information it is important to add an obsoletes line below for
214 # the previous version of the package.
215 %package -n libzfs6
216 Summary: Native ZFS filesystem library for Linux
217 Group: System Environment/Kernel
218 Obsoletes: libzfs2 <= %{version}
219 Obsoletes: libzfs4 <= %{version}
220 Obsoletes: libzfs5 <= %{version}
222 %description -n libzfs6
223 This package provides support for managing ZFS filesystems
225 %if %{defined ldconfig_scriptlets}
226 %ldconfig_scriptlets -n libzfs6
227 %else
228 %post -n libzfs6 -p /sbin/ldconfig
229 %postun -n libzfs6 -p /sbin/ldconfig
230 %endif
232 %package -n libzfs6-devel
233 Summary: Development headers
234 Group: System Environment/Kernel
235 Requires: libzfs6%{?_isa} = %{version}-%{release}
236 Requires: libzpool6%{?_isa} = %{version}-%{release}
237 Requires: libnvpair3%{?_isa} = %{version}-%{release}
238 Requires: libuutil3%{?_isa} = %{version}-%{release}
239 Provides: libzpool6-devel = %{version}-%{release}
240 Provides: libnvpair3-devel = %{version}-%{release}
241 Provides: libuutil3-devel = %{version}-%{release}
242 Obsoletes: zfs-devel <= %{version}
243 Obsoletes: libzfs2-devel <= %{version}
244 Obsoletes: libzfs4-devel <= %{version}
245 Obsoletes: libzfs5-devel <= %{version}
247 %description -n libzfs6-devel
248 This package contains the header files needed for building additional
249 applications against the ZFS libraries.
251 %package test
252 Summary: Test infrastructure
253 Group: System Environment/Kernel
254 Requires: %{name}%{?_isa} = %{version}-%{release}
255 Requires: parted
256 Requires: lsscsi
257 Requires: mdadm
258 Requires: bc
259 Requires: ksh
260 Requires: fio
261 Requires: acl
262 Requires: sudo
263 Requires: sysstat
264 Requires: libaio
265 Requires: python%{__python_pkg_version}
266 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
267 BuildRequires: libaio-devel
268 %endif
269 AutoReqProv: no
271 %description test
272 This package contains test infrastructure and support scripts for
273 validating the file system.
275 %package dracut
276 Summary: Dracut module
277 Group: System Environment/Kernel
278 BuildArch: noarch
279 Requires: %{name} >= %{version}
280 Requires: dracut
281 Requires: /usr/bin/awk
282 Requires: grep
284 %description dracut
285 This package contains a dracut module used to construct an initramfs
286 image which is ZFS aware.
288 %if %{with pyzfs}
289 # Enforce `python36-` package prefix for CentOS 7
290 # since dependencies come from EPEL and are named this way
291 %package -n python%{__python_pkg_version}-pyzfs
292 Summary: Python %{python_version} wrapper for libzfs_core
293 Group: Development/Languages/Python
294 License: Apache-2.0
295 BuildArch: noarch
296 Requires: libzfs6 = %{version}-%{release}
297 Requires: libnvpair3 = %{version}-%{release}
298 Requires: libffi
299 Requires: python%{__python_pkg_version}
301 %if 0%{?centos} == 7
302 Requires: python36-cffi
303 %else
304 Requires: python%{__python_pkg_version}-cffi
305 %endif
307 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
308 %if 0%{?centos} == 7
309 BuildRequires: python36-packaging
310 BuildRequires: python36-devel
311 BuildRequires: python36-cffi
312 BuildRequires: python36-setuptools
313 %else
314 BuildRequires: python%{__python_pkg_version}-packaging
315 BuildRequires: python%{__python_pkg_version}-devel
316 BuildRequires: python%{__python_pkg_version}-cffi
317 BuildRequires: python%{__python_pkg_version}-setuptools
318 %endif
320 BuildRequires: libffi-devel
321 %endif
323 %description -n python%{__python_pkg_version}-pyzfs
324 This package provides a python wrapper for the libzfs_core C library.
325 %endif
327 %if 0%{?_initramfs}
328 %package initramfs
329 Summary: Initramfs module
330 Group: System Environment/Kernel
331 Requires: %{name}%{?_isa} = %{version}-%{release}
332 Requires: initramfs-tools
334 %description initramfs
335 This package contains a initramfs module used to construct an initramfs
336 image which is ZFS aware.
337 %endif
339 %if %{with pam}
340 %package -n pam_zfs_key
341 Summary: PAM module for encrypted ZFS datasets
343 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
344 BuildRequires: pam-devel
345 %endif
347 %description -n pam_zfs_key
348 This package contains the pam_zfs_key PAM module, which provides
349 support for unlocking datasets on user login.
350 %endif
352 %prep
353 %if %{with debug}
354 %define debug --enable-debug
355 %else
356 %define debug --disable-debug
357 %endif
359 %if %{with debuginfo}
360 %define debuginfo --enable-debuginfo
361 %else
362 %define debuginfo --disable-debuginfo
363 %endif
365 %if %{with asan}
366 %define asan --enable-asan
367 %else
368 %define asan --disable-asan
369 %endif
371 %if %{with ubsan}
372 %define ubsan --enable-ubsan
373 %else
374 %define ubsan --disable-ubsan
375 %endif
377 %if 0%{?_systemd}
378 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --with-systemdmodulesloaddir=%{_modulesloaddir} --with-systemdgeneratordir=%{_systemdgeneratordir} --disable-sysvinit
379 %define systemd_svcs zfs-import-cache.service zfs-import-scan.service zfs-mount.service zfs-share.service zfs-zed.service zfs.target zfs-import.target zfs-volume-wait.service zfs-volumes.target
380 %else
381 %define systemd --enable-sysvinit --disable-systemd
382 %endif
384 %if %{with pyzfs}
385 %define pyzfs --enable-pyzfs
386 %else
387 %define pyzfs --disable-pyzfs
388 %endif
390 %if %{with pam}
391 %define pam --enable-pam
392 %else
393 %define pam --disable-pam
394 %endif
396 %setup -q
398 %build
399 %configure \
400 --with-config=user \
401 --with-udevdir=%{_udevdir} \
402 --with-udevruledir=%{_udevruledir} \
403 --with-dracutdir=%{_dracutdir} \
404 --with-pamconfigsdir=%{_datadir}/pam-configs \
405 --with-pammoduledir=%{_libdir}/security \
406 --with-python=%{__python} \
407 --with-pkgconfigdir=%{_pkgconfigdir} \
408 --disable-static \
409 %{debug} \
410 %{debuginfo} \
411 %{asan} \
412 %{ubsan} \
413 %{systemd} \
414 %{pam} \
415 %{pyzfs}
416 make %{?_smp_mflags}
418 %install
419 %{__rm} -rf $RPM_BUILD_ROOT
420 make install DESTDIR=%{?buildroot}
421 find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
422 %if 0%{!?__brp_mangle_shebangs:1}
423 find %{?buildroot}%{_bindir} \
424 \( -name arc_summary -or -name arcstat -or -name dbufstat \
425 -or -name zilstat \) \
426 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
427 find %{?buildroot}%{_datadir} \
428 \( -name test-runner.py -or -name zts-report.py \) \
429 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
430 %endif
432 %post
433 %if 0%{?_systemd}
434 %if 0%{?systemd_post:1}
435 %systemd_post %{systemd_svcs}
436 %else
437 if [ "$1" = "1" -o "$1" = "install" ] ; then
438 # Initial installation
439 systemctl preset %{systemd_svcs} >/dev/null || true
441 %endif
442 %else
443 if [ -x /sbin/chkconfig ]; then
444 /sbin/chkconfig --add zfs-import
445 /sbin/chkconfig --add zfs-load-key
446 /sbin/chkconfig --add zfs-mount
447 /sbin/chkconfig --add zfs-share
448 /sbin/chkconfig --add zfs-zed
450 %endif
451 exit 0
453 # On RHEL/CentOS 7 the static nodes aren't refreshed by default after
454 # installing a package. This is the default behavior for Fedora.
455 %posttrans
456 %if 0%{?rhel} == 7 || 0%{?centos} == 7
457 systemctl restart kmod-static-nodes
458 systemctl restart systemd-tmpfiles-setup-dev
459 udevadm trigger
460 %endif
462 %preun
463 %if 0%{?_systemd}
464 %if 0%{?systemd_preun:1}
465 %systemd_preun %{systemd_svcs}
466 %else
467 if [ "$1" = "0" -o "$1" = "remove" ] ; then
468 # Package removal, not upgrade
469 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
470 systemctl stop %{systemd_svcs} >/dev/null || true
472 %endif
473 %else
474 if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
475 /sbin/chkconfig --del zfs-import
476 /sbin/chkconfig --del zfs-load-key
477 /sbin/chkconfig --del zfs-mount
478 /sbin/chkconfig --del zfs-share
479 /sbin/chkconfig --del zfs-zed
481 %endif
482 exit 0
484 %postun
485 %if 0%{?_systemd}
486 %if 0%{?systemd_postun:1}
487 %systemd_postun %{systemd_svcs}
488 %else
489 systemctl --system daemon-reload >/dev/null || true
490 %endif
491 %endif
493 %files
494 # Core utilities
495 %{_sbindir}/*
496 %{_bindir}/raidz_test
497 %{_sbindir}/zgenhostid
498 %{_bindir}/zvol_wait
499 # Optional Python 3 scripts
500 %{_bindir}/arc_summary
501 %{_bindir}/arcstat
502 %{_bindir}/dbufstat
503 %{_bindir}/zilstat
504 # Man pages
505 %{_mandir}/man1/*
506 %{_mandir}/man4/*
507 %{_mandir}/man5/*
508 %{_mandir}/man7/*
509 %{_mandir}/man8/*
510 # Configuration files and scripts
511 %{_libexecdir}/%{name}
512 %{_udevdir}/vdev_id
513 %{_udevdir}/zvol_id
514 %{_udevdir}/rules.d/*
515 %{_datadir}/%{name}/compatibility.d
516 %if ! 0%{?_systemd} || 0%{?_initramfs}
517 # Files needed for sysvinit and initramfs-tools
518 %{_sysconfdir}/%{name}/zfs-functions
519 %config(noreplace) %{_initconfdir}/zfs
520 %else
521 %exclude %{_sysconfdir}/%{name}/zfs-functions
522 %exclude %{_initconfdir}/zfs
523 %endif
524 %if 0%{?_systemd}
525 %{_unitdir}/*
526 %{_presetdir}/*
527 %{_modulesloaddir}/*
528 %{_systemdgeneratordir}/*
529 %else
530 %config(noreplace) %{_sysconfdir}/init.d/*
531 %endif
532 %config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
533 %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
534 %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
535 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
537 %config(noreplace) %{_bashcompletiondir}/zfs
538 %config(noreplace) %{_bashcompletiondir}/zpool
540 %files -n libzpool6
541 %{_libdir}/libzpool.so.*
543 %files -n libnvpair3
544 %{_libdir}/libnvpair.so.*
546 %files -n libuutil3
547 %{_libdir}/libuutil.so.*
549 %files -n libzfs6
550 %{_libdir}/libzfs*.so.*
552 %files -n libzfs6-devel
553 %{_pkgconfigdir}/libzfs.pc
554 %{_pkgconfigdir}/libzfsbootenv.pc
555 %{_pkgconfigdir}/libzfs_core.pc
556 %{_libdir}/*.so
557 %{_includedir}/*
558 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
560 %files test
561 %{_datadir}/%{name}/zfs-tests
562 %{_datadir}/%{name}/test-runner
563 %{_datadir}/%{name}/runfiles
564 %{_datadir}/%{name}/*.sh
566 %files dracut
567 %doc contrib/dracut/README.md
568 %{_dracutdir}/modules.d/*
570 %if %{with pyzfs}
571 %files -n python%{__python_pkg_version}-pyzfs
572 %doc contrib/pyzfs/README
573 %doc contrib/pyzfs/LICENSE
574 %defattr(-,root,root,-)
575 %{__python_sitelib}/libzfs_core/*
576 %{__python_sitelib}/pyzfs*
577 %endif
579 %if 0%{?_initramfs}
580 %files initramfs
581 %doc contrib/initramfs/README.md
582 /usr/share/initramfs-tools/*
583 %else
584 # Since we're not building the initramfs package,
585 # ignore those files.
586 %exclude /usr/share/initramfs-tools
587 %endif
589 %if %{with pam}
590 %files -n pam_zfs_key
591 %{_libdir}/security/*
592 %{_datadir}/pam-configs/*
593 %endif