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