Fix generation of kernel uevents for snapshot rename on linux
[zfs.git] / rpm / generic / zfs.spec.in
blobc7a00c61f6bbc8a2d15ec3f2aa8e3c1a69f3dca9
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: libzpool5%{?_isa} = %{version}-%{release}
103 Requires: libnvpair3%{?_isa} = %{version}-%{release}
104 Requires: libuutil3%{?_isa} = %{version}-%{release}
105 Requires: libzfs5%{?_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 libzpool5
154 Summary: Native ZFS pool library for Linux
155 Group: System Environment/Kernel
156 Obsoletes: libzpool2 <= %{version}
157 Obsoletes: libzpool4 <= %{version}
159 %description -n libzpool5
160 This package contains the zpool library, which provides support
161 for managing zpools
163 %if %{defined ldconfig_scriptlets}
164 %ldconfig_scriptlets -n libzpool5
165 %else
166 %post -n libzpool5 -p /sbin/ldconfig
167 %postun -n libzpool5 -p /sbin/ldconfig
168 %endif
170 %package -n libnvpair3
171 Summary: Solaris name-value library for Linux
172 Group: System Environment/Kernel
173 Obsoletes: libnvpair1 <= %{version}
175 %description -n libnvpair3
176 This package contains routines for packing and unpacking name-value
177 pairs. This functionality is used to portably transport data across
178 process boundaries, between kernel and user space, and can be used
179 to write self describing data structures on disk.
181 %if %{defined ldconfig_scriptlets}
182 %ldconfig_scriptlets -n libnvpair3
183 %else
184 %post -n libnvpair3 -p /sbin/ldconfig
185 %postun -n libnvpair3 -p /sbin/ldconfig
186 %endif
188 %package -n libuutil3
189 Summary: Solaris userland utility library for Linux
190 Group: System Environment/Kernel
191 Obsoletes: libuutil1 <= %{version}
193 %description -n libuutil3
194 This library provides a variety of compatibility functions for OpenZFS:
195 * libspl: The Solaris Porting Layer userland library, which provides APIs
196 that make it possible to run Solaris user code in a Linux environment
197 with relatively minimal modification.
198 * libavl: The Adelson-Velskii Landis balanced binary tree manipulation
199 library.
200 * libefi: The Extensible Firmware Interface library for GUID disk
201 partitioning.
202 * libshare: NFS, SMB, and iSCSI service integration for ZFS.
204 %if %{defined ldconfig_scriptlets}
205 %ldconfig_scriptlets -n libuutil3
206 %else
207 %post -n libuutil3 -p /sbin/ldconfig
208 %postun -n libuutil3 -p /sbin/ldconfig
209 %endif
211 # The library version is encoded in the package name. When updating the
212 # version information it is important to add an obsoletes line below for
213 # the previous version of the package.
214 %package -n libzfs5
215 Summary: Native ZFS filesystem library for Linux
216 Group: System Environment/Kernel
217 Obsoletes: libzfs2 <= %{version}
218 Obsoletes: libzfs4 <= %{version}
220 %description -n libzfs5
221 This package provides support for managing ZFS filesystems
223 %if %{defined ldconfig_scriptlets}
224 %ldconfig_scriptlets -n libzfs5
225 %else
226 %post -n libzfs5 -p /sbin/ldconfig
227 %postun -n libzfs5 -p /sbin/ldconfig
228 %endif
230 %package -n libzfs5-devel
231 Summary: Development headers
232 Group: System Environment/Kernel
233 Requires: libzfs5%{?_isa} = %{version}-%{release}
234 Requires: libzpool5%{?_isa} = %{version}-%{release}
235 Requires: libnvpair3%{?_isa} = %{version}-%{release}
236 Requires: libuutil3%{?_isa} = %{version}-%{release}
237 Provides: libzpool5-devel = %{version}-%{release}
238 Provides: libnvpair3-devel = %{version}-%{release}
239 Provides: libuutil3-devel = %{version}-%{release}
240 Obsoletes: zfs-devel <= %{version}
241 Obsoletes: libzfs2-devel <= %{version}
242 Obsoletes: libzfs4-devel <= %{version}
244 %description -n libzfs5-devel
245 This package contains the header files needed for building additional
246 applications against the ZFS libraries.
248 %package test
249 Summary: Test infrastructure
250 Group: System Environment/Kernel
251 Requires: %{name}%{?_isa} = %{version}-%{release}
252 Requires: parted
253 Requires: lsscsi
254 Requires: mdadm
255 Requires: bc
256 Requires: ksh
257 Requires: fio
258 Requires: acl
259 Requires: sudo
260 Requires: sysstat
261 Requires: libaio
262 Requires: python%{__python_pkg_version}
263 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
264 BuildRequires: libaio-devel
265 %endif
266 AutoReqProv: no
268 %description test
269 This package contains test infrastructure and support scripts for
270 validating the file system.
272 %package dracut
273 Summary: Dracut module
274 Group: System Environment/Kernel
275 BuildArch: noarch
276 Requires: %{name} >= %{version}
277 Requires: dracut
278 Requires: /usr/bin/awk
279 Requires: grep
281 %description dracut
282 This package contains a dracut module used to construct an initramfs
283 image which is ZFS aware.
285 %if %{with pyzfs}
286 # Enforce `python36-` package prefix for CentOS 7
287 # since dependencies come from EPEL and are named this way
288 %package -n python%{__python_pkg_version}-pyzfs
289 Summary: Python %{python_version} wrapper for libzfs_core
290 Group: Development/Languages/Python
291 License: Apache-2.0
292 BuildArch: noarch
293 Requires: libzfs5 = %{version}-%{release}
294 Requires: libnvpair3 = %{version}-%{release}
295 Requires: libffi
296 Requires: python%{__python_pkg_version}
298 %if 0%{?centos} == 7
299 Requires: python36-cffi
300 %else
301 Requires: python%{__python_pkg_version}-cffi
302 %endif
304 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
305 %if 0%{?centos} == 7
306 BuildRequires: python36-packaging
307 BuildRequires: python36-devel
308 BuildRequires: python36-cffi
309 BuildRequires: python36-setuptools
310 %else
311 BuildRequires: python%{__python_pkg_version}-packaging
312 BuildRequires: python%{__python_pkg_version}-devel
313 BuildRequires: python%{__python_pkg_version}-cffi
314 BuildRequires: python%{__python_pkg_version}-setuptools
315 %endif
317 BuildRequires: libffi-devel
318 %endif
320 %description -n python%{__python_pkg_version}-pyzfs
321 This package provides a python wrapper for the libzfs_core C library.
322 %endif
324 %if 0%{?_initramfs}
325 %package initramfs
326 Summary: Initramfs module
327 Group: System Environment/Kernel
328 Requires: %{name}%{?_isa} = %{version}-%{release}
329 Requires: initramfs-tools
331 %description initramfs
332 This package contains a initramfs module used to construct an initramfs
333 image which is ZFS aware.
334 %endif
336 %if %{with pam}
337 %package -n pam_zfs_key
338 Summary: PAM module for encrypted ZFS datasets
340 %if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}%{?openEuler}
341 BuildRequires: pam-devel
342 %endif
344 %description -n pam_zfs_key
345 This package contains the pam_zfs_key PAM module, which provides
346 support for unlocking datasets on user login.
347 %endif
349 %prep
350 %if %{with debug}
351 %define debug --enable-debug
352 %else
353 %define debug --disable-debug
354 %endif
356 %if %{with debuginfo}
357 %define debuginfo --enable-debuginfo
358 %else
359 %define debuginfo --disable-debuginfo
360 %endif
362 %if %{with asan}
363 %define asan --enable-asan
364 %else
365 %define asan --disable-asan
366 %endif
368 %if %{with ubsan}
369 %define ubsan --enable-ubsan
370 %else
371 %define ubsan --disable-ubsan
372 %endif
374 %if 0%{?_systemd}
375 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --with-systemdmodulesloaddir=%{_modulesloaddir} --with-systemdgeneratordir=%{_systemdgeneratordir} --disable-sysvinit
376 %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
377 %else
378 %define systemd --enable-sysvinit --disable-systemd
379 %endif
381 %if %{with pyzfs}
382 %define pyzfs --enable-pyzfs
383 %else
384 %define pyzfs --disable-pyzfs
385 %endif
387 %if %{with pam}
388 %define pam --enable-pam
389 %else
390 %define pam --disable-pam
391 %endif
393 %setup -q
395 %build
396 %configure \
397 --with-config=user \
398 --with-udevdir=%{_udevdir} \
399 --with-udevruledir=%{_udevruledir} \
400 --with-dracutdir=%{_dracutdir} \
401 --with-pamconfigsdir=%{_datadir}/pam-configs \
402 --with-pammoduledir=%{_libdir}/security \
403 --with-python=%{__python} \
404 --with-pkgconfigdir=%{_pkgconfigdir} \
405 --disable-static \
406 %{debug} \
407 %{debuginfo} \
408 %{asan} \
409 %{ubsan} \
410 %{systemd} \
411 %{pam} \
412 %{pyzfs}
413 make %{?_smp_mflags}
415 %install
416 %{__rm} -rf $RPM_BUILD_ROOT
417 make install DESTDIR=%{?buildroot}
418 find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
419 %if 0%{!?__brp_mangle_shebangs:1}
420 find %{?buildroot}%{_bindir} \
421 \( -name arc_summary -or -name arcstat -or -name dbufstat \
422 -or -name zilstat \) \
423 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
424 find %{?buildroot}%{_datadir} \
425 \( -name test-runner.py -or -name zts-report.py \) \
426 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
427 %endif
429 %post
430 %if 0%{?_systemd}
431 %if 0%{?systemd_post:1}
432 %systemd_post %{systemd_svcs}
433 %else
434 if [ "$1" = "1" -o "$1" = "install" ] ; then
435 # Initial installation
436 systemctl preset %{systemd_svcs} >/dev/null || true
438 %endif
439 %else
440 if [ -x /sbin/chkconfig ]; then
441 /sbin/chkconfig --add zfs-import
442 /sbin/chkconfig --add zfs-load-key
443 /sbin/chkconfig --add zfs-mount
444 /sbin/chkconfig --add zfs-share
445 /sbin/chkconfig --add zfs-zed
447 %endif
448 exit 0
450 # On RHEL/CentOS 7 the static nodes aren't refreshed by default after
451 # installing a package. This is the default behavior for Fedora.
452 %posttrans
453 %if 0%{?rhel} == 7 || 0%{?centos} == 7
454 systemctl restart kmod-static-nodes
455 systemctl restart systemd-tmpfiles-setup-dev
456 udevadm trigger
457 %endif
459 %preun
460 %if 0%{?_systemd}
461 %if 0%{?systemd_preun:1}
462 %systemd_preun %{systemd_svcs}
463 %else
464 if [ "$1" = "0" -o "$1" = "remove" ] ; then
465 # Package removal, not upgrade
466 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
467 systemctl stop %{systemd_svcs} >/dev/null || true
469 %endif
470 %else
471 if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
472 /sbin/chkconfig --del zfs-import
473 /sbin/chkconfig --del zfs-load-key
474 /sbin/chkconfig --del zfs-mount
475 /sbin/chkconfig --del zfs-share
476 /sbin/chkconfig --del zfs-zed
478 %endif
479 exit 0
481 %postun
482 %if 0%{?_systemd}
483 %if 0%{?systemd_postun:1}
484 %systemd_postun %{systemd_svcs}
485 %else
486 systemctl --system daemon-reload >/dev/null || true
487 %endif
488 %endif
490 %files
491 # Core utilities
492 %{_sbindir}/*
493 %{_bindir}/raidz_test
494 %{_sbindir}/zgenhostid
495 %{_bindir}/zvol_wait
496 # Optional Python 3 scripts
497 %{_bindir}/arc_summary
498 %{_bindir}/arcstat
499 %{_bindir}/dbufstat
500 %{_bindir}/zilstat
501 # Man pages
502 %{_mandir}/man1/*
503 %{_mandir}/man4/*
504 %{_mandir}/man5/*
505 %{_mandir}/man7/*
506 %{_mandir}/man8/*
507 # Configuration files and scripts
508 %{_libexecdir}/%{name}
509 %{_udevdir}/vdev_id
510 %{_udevdir}/zvol_id
511 %{_udevdir}/rules.d/*
512 %{_datadir}/%{name}/compatibility.d
513 %if ! 0%{?_systemd} || 0%{?_initramfs}
514 # Files needed for sysvinit and initramfs-tools
515 %{_sysconfdir}/%{name}/zfs-functions
516 %config(noreplace) %{_initconfdir}/zfs
517 %else
518 %exclude %{_sysconfdir}/%{name}/zfs-functions
519 %exclude %{_initconfdir}/zfs
520 %endif
521 %if 0%{?_systemd}
522 %{_unitdir}/*
523 %{_presetdir}/*
524 %{_modulesloaddir}/*
525 %{_systemdgeneratordir}/*
526 %else
527 %config(noreplace) %{_sysconfdir}/init.d/*
528 %endif
529 %config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
530 %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
531 %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
532 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
534 %config(noreplace) %{_bashcompletiondir}/zfs
535 %config(noreplace) %{_bashcompletiondir}/zpool
537 %files -n libzpool5
538 %{_libdir}/libzpool.so.*
540 %files -n libnvpair3
541 %{_libdir}/libnvpair.so.*
543 %files -n libuutil3
544 %{_libdir}/libuutil.so.*
546 %files -n libzfs5
547 %{_libdir}/libzfs*.so.*
549 %files -n libzfs5-devel
550 %{_pkgconfigdir}/libzfs.pc
551 %{_pkgconfigdir}/libzfsbootenv.pc
552 %{_pkgconfigdir}/libzfs_core.pc
553 %{_libdir}/*.so
554 %{_includedir}/*
555 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
557 %files test
558 %{_datadir}/%{name}/zfs-tests
559 %{_datadir}/%{name}/test-runner
560 %{_datadir}/%{name}/runfiles
561 %{_datadir}/%{name}/*.sh
563 %files dracut
564 %doc contrib/dracut/README.md
565 %{_dracutdir}/modules.d/*
567 %if %{with pyzfs}
568 %files -n python%{__python_pkg_version}-pyzfs
569 %doc contrib/pyzfs/README
570 %doc contrib/pyzfs/LICENSE
571 %defattr(-,root,root,-)
572 %{__python_sitelib}/libzfs_core/*
573 %{__python_sitelib}/pyzfs*
574 %endif
576 %if 0%{?_initramfs}
577 %files initramfs
578 %doc contrib/initramfs/README.md
579 /usr/share/initramfs-tools/*
580 %else
581 # Since we're not building the initramfs package,
582 # ignore those files.
583 %exclude /usr/share/initramfs-tools
584 %endif
586 %if %{with pam}
587 %files -n pam_zfs_key
588 %{_libdir}/security/*
589 %{_datadir}/pam-configs/*
590 %endif