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