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