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