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