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