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