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