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