2 %global _libdir /%{_lib}
4 # Set the default udev directory based on distribution.
5 %if %{undefined _udevdir}
6 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
7 %global _udevdir %{_prefix}/lib/udev
9 %global _udevdir /lib/udev
13 # Set the default udevrule directory based on distribution.
14 %if %{undefined _udevruledir}
15 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
16 %global _udevruledir %{_prefix}/lib/udev/rules.d
18 %global _udevruledir /lib/udev/rules.d
22 # Set the default dracut directory based on distribution.
23 %if %{undefined _dracutdir}
24 %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
25 %global _dracutdir %{_prefix}/lib/dracut
27 %global _dracutdir %{_prefix}/share/dracut
31 %if %{undefined _initconfdir}
32 %global _initconfdir /etc/sysconfig
35 %if %{undefined _unitdir}
36 %global _unitdir %{_prefix}/lib/systemd/system
39 %if %{undefined _presetdir}
40 %global _presetdir %{_prefix}/lib/systemd/system-preset
43 %if %{undefined _modulesloaddir}
44 %global _modulesloaddir %{_prefix}/lib/modules-load.d
47 %if %{undefined _systemdgeneratordir}
48 %global _systemdgeneratordir %{_prefix}/lib/systemd/system-generators
51 %if %{undefined _pkgconfigdir}
52 %global _pkgconfigdir %{_prefix}/%{_lib}/pkgconfig
61 # Generic enable switch for systemd
66 # RHEL >= 7 comes with systemd
71 # Fedora >= 15 comes with systemd, but only >= 18 has
77 # opensuse >= 12.1 comes with systemd, but only >= 13.1
78 # has the proper macros
79 %if 0%{?suse_version} >= 1310
83 # When not specified default to distribution provided version. This
84 # is normally Python 3, but for RHEL <= 7 only Python 2 is provided.
85 %if %{undefined __use_python}
86 %if 0%{?rhel} && 0%{?rhel} <= 7
87 %define __python /usr/bin/python2
88 %define __python_pkg_version 2
89 %define __python_cffi_pkg python-cffi
90 %define __python_setuptools_pkg python-setuptools
92 %define __python /usr/bin/python3
93 %define __python_pkg_version 3
94 %define __python_cffi_pkg python3-cffi
95 %define __python_setuptools_pkg python3-setuptools
98 %define __python %{__use_python}
99 %define __python_pkg_version %{__use_python_pkg_version}
100 %define __python_cffi_pkg python%{__python_pkg_version}-cffi
101 %define __python_setuptools_pkg python%{__python_pkg_version}-setuptools
103 %define __python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
105 # By default python-pyzfs is enabled, with the exception of
106 # RHEL 6 which by default uses Python 2.6 which is too old.
115 Release: @RELEASE@%{?dist}
116 Summary: Commands to control the kernel modules and libraries
118 Group: System Environment/Kernel
119 License: @ZFS_META_LICENSE@
120 URL: https://zfsonlinux.org/
121 Source0: %{name}-%{version}.tar.gz
122 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
123 Requires: libzpool2 = %{version}
124 Requires: libnvpair1 = %{version}
125 Requires: libuutil1 = %{version}
126 Requires: libzfs2 = %{version}
127 Requires: %{name}-kmod = %{version}
128 Provides: %{name}-kmod-common = %{version}
131 # zfs-fuse provides the same commands and man pages that ZoL does. Renaming
132 # those on either side would conflict with all available documentation.
135 %if 0%{?rhel}%{?fedora}%{?suse_version}
136 BuildRequires: gcc, make
137 BuildRequires: zlib-devel
138 BuildRequires: libuuid-devel
139 BuildRequires: libblkid-devel
140 BuildRequires: libudev-devel
141 BuildRequires: libattr-devel
142 BuildRequires: openssl-devel
143 %if 0%{?fedora} >= 28 || 0%{?rhel} >= 8 || 0%{?centos} >= 8
144 BuildRequires: libtirpc-devel
148 BuildRequires: systemd
153 Requires(post): systemd
154 Requires(preun): systemd
155 Requires(postun): systemd
158 # The zpool iostat/status -c scripts call some utilities like lsblk and iostat
163 This package contains the core ZFS command line utilities.
165 %package -n libzpool2
166 Summary: Native ZFS pool library for Linux
167 Group: System Environment/Kernel
169 %description -n libzpool2
170 This package contains the zpool library, which provides support
173 %post -n libzpool2 -p /sbin/ldconfig
174 %postun -n libzpool2 -p /sbin/ldconfig
176 %package -n libnvpair1
177 Summary: Solaris name-value library for Linux
178 Group: System Environment/Kernel
180 %description -n libnvpair1
181 This package contains routines for packing and unpacking name-value
182 pairs. This functionality is used to portably transport data across
183 process boundaries, between kernel and user space, and can be used
184 to write self describing data structures on disk.
186 %post -n libnvpair1 -p /sbin/ldconfig
187 %postun -n libnvpair1 -p /sbin/ldconfig
189 %package -n libuutil1
190 Summary: Solaris userland utility library for Linux
191 Group: System Environment/Kernel
193 %description -n libuutil1
194 This library provides a variety of compatibility functions for ZFS on Linux:
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
200 * libefi: The Extensible Firmware Interface library for GUID disk
202 * libshare: NFS, SMB, and iSCSI service integration for ZFS.
204 %post -n libuutil1 -p /sbin/ldconfig
205 %postun -n libuutil1 -p /sbin/ldconfig
208 Summary: Native ZFS filesystem library for Linux
209 Group: System Environment/Kernel
211 %description -n libzfs2
212 This package provides support for managing ZFS filesystems
214 %post -n libzfs2 -p /sbin/ldconfig
215 %postun -n libzfs2 -p /sbin/ldconfig
217 %package -n libzfs2-devel
218 Summary: Development headers
219 Group: System Environment/Kernel
220 Requires: libzfs2 = %{version}
221 Requires: libzpool2 = %{version}
222 Requires: libnvpair1 = %{version}
223 Requires: libuutil1 = %{version}
224 Provides: libzpool2-devel
225 Provides: libnvpair1-devel
226 Provides: libuutil1-devel
229 %description -n libzfs2-devel
230 This package contains the header files needed for building additional
231 applications against the ZFS libraries.
234 Summary: Test infrastructure
235 Group: System Environment/Kernel
236 Requires: %{name}%{?_isa} = %{version}-%{release}
247 Requires: python%{__python_pkg_version}
248 %if 0%{?rhel}%{?fedora}%{?suse_version}
249 BuildRequires: libaio-devel
254 This package contains test infrastructure and support scripts for
255 validating the file system.
258 Summary: Dracut module
259 Group: System Environment/Kernel
261 Requires: %{name} >= %{version}
263 Requires: /usr/bin/awk
267 This package contains a dracut module used to construct an initramfs
268 image which is ZFS aware.
271 %package -n python%{__python_pkg_version}-pyzfs
272 Summary: Python %{python_version} wrapper for libzfs_core
273 Group: Development/Languages/Python
276 Requires: libzfs2 = %{version}
277 Requires: libnvpair1 = %{version}
279 Requires: python%{__python_pkg_version}
280 Requires: %{__python_cffi_pkg}
281 %if 0%{?rhel}%{?fedora}%{?suse_version}
282 BuildRequires: python%{__python_pkg_version}-devel
283 BuildRequires: %{__python_cffi_pkg}
284 BuildRequires: %{__python_setuptools_pkg}
285 BuildRequires: libffi-devel
288 %description -n python%{__python_pkg_version}-pyzfs
289 This package provides a python wrapper for the libzfs_core C library.
294 Summary: Initramfs module
295 Group: System Environment/Kernel
296 Requires: %{name}%{?_isa} = %{version}-%{release}
297 Requires: %{name} = %{version}-%{release}
298 Requires: initramfs-tools
300 %description initramfs
301 This package contains a initramfs module used to construct an initramfs
302 image which is ZFS aware.
307 %define debug --enable-debug
309 %define debug --disable-debug
312 %if %{with debuginfo}
313 %define debuginfo --enable-debuginfo
315 %define debuginfo --disable-debuginfo
319 %define asan --enable-asan
321 %define asan --disable-asan
325 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --with-systemdmodulesloaddir=%{_modulesloaddir} --with-systemdgeneratordir=%{_systemdgeneratordir} --disable-sysvinit
326 %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
328 %define systemd --enable-sysvinit --disable-systemd
332 %define pyzfs --enable-pyzfs
334 %define pyzfs --disable-pyzfs
338 %define pam --enable-pam
340 %define pam --disable-pam
348 --with-udevdir=%{_udevdir} \
349 --with-udevruledir=%{_udevruledir} \
350 --with-dracutdir=%{_dracutdir} \
351 --with-pamconfigsdir=%{_datadir}/pam-configs \
352 --with-pammoduledir=%{_libdir}/security \
353 --with-python=%{__python} \
354 --with-pkgconfigdir=%{_pkgconfigdir} \
365 %{__rm} -rf $RPM_BUILD_ROOT
366 make install DESTDIR=%{?buildroot}
367 find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
368 %if 0%{!?__brp_mangle_shebangs:1}
369 find %{?buildroot}%{_bindir} \
370 \( -name arc_summary -or -name arcstat -or -name dbufstat \) \
371 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
372 find %{?buildroot}%{_datadir} \
373 \( -name test-runner.py -or -name zts-report.py \) \
374 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
379 %if 0%{?systemd_post:1}
380 %systemd_post %{systemd_svcs}
382 if [ "$1" = "1" -o "$1" = "install" ] ; then
383 # Initial installation
384 systemctl preset %{systemd_svcs} >/dev/null || true
388 if [ -x /sbin/chkconfig ]; then
389 /sbin/chkconfig --add zfs-import
390 /sbin/chkconfig --add zfs-mount
391 /sbin/chkconfig --add zfs-share
392 /sbin/chkconfig --add zfs-zed
397 # On RHEL/CentOS 7 the static nodes aren't refreshed by default after
398 # installing a package. This is the default behavior for Fedora.
400 %if 0%{?rhel} == 7 || 0%{?centos} == 7
401 systemctl restart kmod-static-nodes
402 systemctl restart systemd-tmpfiles-setup-dev
408 %if 0%{?systemd_preun:1}
409 %systemd_preun %{systemd_svcs}
411 if [ "$1" = "0" -o "$1" = "remove" ] ; then
412 # Package removal, not upgrade
413 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
414 systemctl stop %{systemd_svcs} >/dev/null || true
418 if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
419 /sbin/chkconfig --del zfs-import
420 /sbin/chkconfig --del zfs-mount
421 /sbin/chkconfig --del zfs-share
422 /sbin/chkconfig --del zfs-zed
429 %if 0%{?systemd_postun:1}
430 %systemd_postun %{systemd_svcs}
432 systemctl --system daemon-reload >/dev/null || true
439 %{_bindir}/raidz_test
440 %{_bindir}/zgenhostid
442 # Optional Python 2/3 scripts
443 %{_bindir}/arc_summary
450 # Configuration files and scripts
451 %{_libexecdir}/%{name}
454 %{_udevdir}/rules.d/*
455 %if ! 0%{?_systemd} || 0%{?_initramfs}
456 # Files needed for sysvinit and initramfs-tools
457 %{_sysconfdir}/%{name}/zfs-functions
458 %config(noreplace) %{_initconfdir}/zfs
460 %exclude %{_sysconfdir}/%{name}/zfs-functions
461 %exclude %{_initconfdir}/zfs
467 %{_systemdgeneratordir}/*
469 %config(noreplace) %{_sysconfdir}/init.d/*
471 %config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
472 %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
473 %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
474 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
476 %{_libdir}/security/*
477 %{_datadir}/pam-configs/*
481 %{_libdir}/libzpool.so.*
484 %{_libdir}/libnvpair.so.*
487 %{_libdir}/libuutil.so.*
490 %{_libdir}/libzfs*.so.*
492 %files -n libzfs2-devel
493 %{_pkgconfigdir}/libzfs.pc
494 %{_pkgconfigdir}/libzfsbootenv.pc
495 %{_pkgconfigdir}/libzfs_core.pc
498 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
504 %doc contrib/dracut/README.dracut.markdown
505 %{_dracutdir}/modules.d/*
508 %files -n python%{__python_pkg_version}-pyzfs
509 %doc contrib/pyzfs/README
510 %doc contrib/pyzfs/LICENSE
511 %defattr(-,root,root,-)
512 %{__python_sitelib}/libzfs_core/*
513 %{__python_sitelib}/pyzfs*
518 %doc contrib/initramfs/README.initramfs.markdown
519 /usr/share/initramfs-tools/*
521 # Since we're not building the initramfs package,
522 # ignore those files.
523 %exclude /usr/share/initramfs-tools