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