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