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