]> git.proxmox.com Git - mirror_zfs.git/blame - rpm/generic/zfs.spec.in
contrib: bash_completion.d: install, fix dist
[mirror_zfs.git] / rpm / generic / zfs.spec.in
CommitLineData
f3757573
BB
1%global _sbindir /sbin
2%global _libdir /%{_lib}
2ee4e7da
TF
3
4# Set the default udev directory based on distribution.
5d2107d8 5%if %{undefined _udevdir}
8a7c4efd 6%if 0%{?fedora}%{?rhel}%{?centos}
f3757573 7%global _udevdir %{_prefix}/lib/udev
f3757573
BB
8%else
9%global _udevdir /lib/udev
2ee4e7da
TF
10%endif
11%endif
12
13# Set the default udevrule directory based on distribution.
5d2107d8 14%if %{undefined _udevruledir}
8a7c4efd 15%if 0%{?fedora}%{?rhel}%{?centos}
5d2107d8 16%global _udevruledir %{_prefix}/lib/udev/rules.d
2ee4e7da 17%else
5d2107d8 18%global _udevruledir /lib/udev/rules.d
2ee4e7da
TF
19%endif
20%endif
21
22# Set the default dracut directory based on distribution.
5d2107d8 23%if %{undefined _dracutdir}
8a7c4efd 24%if 0%{?fedora}%{?rhel}%{?centos}
2ee4e7da
TF
25%global _dracutdir %{_prefix}/lib/dracut
26%else
4788a01d 27%global _dracutdir %{_prefix}/share/dracut
f3757573 28%endif
2ee4e7da 29%endif
f3757573 30
3b79cef2
BB
31%if %{undefined _initconfdir}
32%global _initconfdir /etc/sysconfig
33%endif
34
ecd3728b
BB
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
4d61ade1
AS
51%if %{undefined _pkgconfigdir}
52%global _pkgconfigdir %{_prefix}/%{_lib}/pkgconfig
53%endif
54
f3757573 55%bcond_with debug
fed90353
BB
56%bcond_with debuginfo
57%bcond_with asan
63652e15 58%bcond_with ubsan
881f45c6 59%bcond_with systemd
221e6704 60%bcond_with pam
8a7c4efd 61%bcond_without pyzfs
f3757573 62
881f45c6
RE
63# Generic enable switch for systemd
64%if %{with systemd}
65%define _systemd 1
66%endif
67
8a7c4efd
DS
68# Distros below support systemd
69%if 0%{?rhel}%{?fedora}%{?centos}%{?suse_version}
8b974ba0
BA
70%define _systemd 1
71%endif
72
8a7c4efd 73# When not specified default to distribution provided version.
6e72a5b9 74%if %{undefined __use_python}
e34cd80d
BB
75%define __python /usr/bin/python3
76%define __python_pkg_version 3
6e72a5b9 77%else
e34cd80d
BB
78%define __python %{__use_python}
79%define __python_pkg_version %{__use_python_pkg_version}
6e72a5b9 80%endif
02fad926 81%define __python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
6e72a5b9 82
f3757573
BB
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@
d0249a4b 90URL: https://github.com/openzfs/zfs
f3757573
BB
91Source0: %{name}-%{version}.tar.gz
92BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
fe6babce 93Requires: libzpool5 = %{version}
8434017a
AR
94Requires: libnvpair3 = %{version}
95Requires: libuutil3 = %{version}
fe6babce 96Requires: libzfs5 = %{version}
28967367 97Requires: %{name}-kmod = %{version}
f3757573 98Provides: %{name}-kmod-common = %{version}
93ce2b4c 99Obsoletes: spl
f3757573 100
1966e959
AZ
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.
f12971e6
RE
103Conflicts: zfs-fuse
104
8a7c4efd 105%if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}
d7bda38c 106BuildRequires: gcc, make
f3757573
BB
107BuildRequires: zlib-devel
108BuildRequires: libuuid-devel
f3757573 109BuildRequires: libblkid-devel
de0ef912
BB
110BuildRequires: libudev-devel
111BuildRequires: libattr-devel
4807c0ba 112BuildRequires: openssl-devel
1a345d64
RE
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
8a7c4efd 117%if 0%{?fedora} || 0%{?rhel} >= 8 || 0%{?centos} >= 8
1a62a305
TH
118BuildRequires: libtirpc-devel
119%endif
1a345d64 120
4807c0ba 121Requires: openssl
ee410eef 122%if 0%{?_systemd}
123BuildRequires: systemd
124%endif
8d6a598a 125
f3757573 126%endif
ee410eef 127
881f45c6
RE
128%if 0%{?_systemd}
129Requires(post): systemd
130Requires(preun): systemd
131Requires(postun): systemd
881f45c6 132%endif
f3757573 133
d6418de0
TH
134# The zpool iostat/status -c scripts call some utilities like lsblk and iostat
135Requires: util-linux
136Requires: sysstat
137
f3757573 138%description
6e72a5b9 139This package contains the core ZFS command line utilities.
f3757573 140
fe6babce 141%package -n libzpool5
c9b5cc8c
TF
142Summary: Native ZFS pool library for Linux
143Group: System Environment/Kernel
f67bebbc 144Obsoletes: libzpool2
d5ef91af 145Obsoletes: libzpool4
c9b5cc8c 146
fe6babce 147%description -n libzpool5
c9b5cc8c
TF
148This package contains the zpool library, which provides support
149for managing zpools
150
91971455
BB
151%if %{defined ldconfig_scriptlets}
152%ldconfig_scriptlets -n libzpool5
153%else
fe6babce
BB
154%post -n libzpool5 -p /sbin/ldconfig
155%postun -n libzpool5 -p /sbin/ldconfig
91971455 156%endif
c9b5cc8c 157
8434017a 158%package -n libnvpair3
c9b5cc8c
TF
159Summary: Solaris name-value library for Linux
160Group: System Environment/Kernel
f67bebbc 161Obsoletes: libnvpair1
c9b5cc8c 162
8434017a 163%description -n libnvpair3
c9b5cc8c
TF
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
91971455
BB
169%if %{defined ldconfig_scriptlets}
170%ldconfig_scriptlets -n libnvpair3
171%else
8434017a
AR
172%post -n libnvpair3 -p /sbin/ldconfig
173%postun -n libnvpair3 -p /sbin/ldconfig
91971455 174%endif
c9b5cc8c 175
8434017a 176%package -n libuutil3
c9b5cc8c
TF
177Summary: Solaris userland utility library for Linux
178Group: System Environment/Kernel
f67bebbc 179Obsoletes: libuutil1
c9b5cc8c 180
8434017a 181%description -n libuutil3
d0249a4b 182This library provides a variety of compatibility functions for OpenZFS:
c9b5cc8c
TF
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
91971455
BB
192%if %{defined ldconfig_scriptlets}
193%ldconfig_scriptlets -n libuutil3
194%else
8434017a
AR
195%post -n libuutil3 -p /sbin/ldconfig
196%postun -n libuutil3 -p /sbin/ldconfig
91971455 197%endif
c9b5cc8c 198
3e660534
BB
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.
fe6babce 202%package -n libzfs5
c9b5cc8c
TF
203Summary: Native ZFS filesystem library for Linux
204Group: System Environment/Kernel
f67bebbc 205Obsoletes: libzfs2
d5ef91af 206Obsoletes: libzfs4
c9b5cc8c 207
fe6babce 208%description -n libzfs5
c9b5cc8c
TF
209This package provides support for managing ZFS filesystems
210
91971455
BB
211%if %{defined ldconfig_scriptlets}
212%ldconfig_scriptlets -n libzfs5
213%else
fe6babce
BB
214%post -n libzfs5 -p /sbin/ldconfig
215%postun -n libzfs5 -p /sbin/ldconfig
91971455 216%endif
c9b5cc8c 217
fe6babce 218%package -n libzfs5-devel
f3757573
BB
219Summary: Development headers
220Group: System Environment/Kernel
fe6babce
BB
221Requires: libzfs5 = %{version}
222Requires: libzpool5 = %{version}
8434017a
AR
223Requires: libnvpair3 = %{version}
224Requires: libuutil3 = %{version}
fe6babce 225Provides: libzpool5-devel
8434017a
AR
226Provides: libnvpair3-devel
227Provides: libuutil3-devel
c9b5cc8c 228Obsoletes: zfs-devel
f67bebbc 229Obsoletes: libzfs2-devel
3e660534 230Obsoletes: libzfs4-devel
f3757573 231
fe6babce 232%description -n libzfs5-devel
f3757573
BB
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
6bb24f4d 244Requires: ksh
13589da9
BB
245Requires: fio
246Requires: acl
247Requires: sudo
248Requires: sysstat
3905cace 249Requires: libaio
6e72a5b9 250Requires: python%{__python_pkg_version}
8a7c4efd 251%if 0%{?rhel}%{?centos}%{?fedora}%{?suse_version}
55972a67 252BuildRequires: libaio-devel
644e01a2 253%endif
13589da9 254AutoReqProv: no
f3757573
BB
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
ca4e5a78
GB
263BuildArch: noarch
264Requires: %{name} >= %{version}
f3757573 265Requires: dracut
3905cace
BB
266Requires: /usr/bin/awk
267Requires: grep
f3757573
BB
268
269%description dracut
270This package contains a dracut module used to construct an initramfs
271image which is ZFS aware.
272
6e72a5b9 273%if %{with pyzfs}
8a7c4efd
DS
274# Enforce `python36-` package prefix for CentOS 7
275# since dependencies come from EPEL and are named this way
6e72a5b9
BB
276%package -n python%{__python_pkg_version}-pyzfs
277Summary: Python %{python_version} wrapper for libzfs_core
85ce3f4f 278Group: Development/Languages/Python
279License: Apache-2.0
280BuildArch: noarch
fe6babce 281Requires: libzfs5 = %{version}
8434017a 282Requires: libnvpair3 = %{version}
85ce3f4f 283Requires: libffi
6e72a5b9 284Requires: python%{__python_pkg_version}
8a7c4efd
DS
285
286%if 0%{?centos} == 7
287Requires: python36-cffi
08cd0717 288%else
8a7c4efd 289Requires: python%{__python_pkg_version}-cffi
08cd0717 290%endif
8a7c4efd
DS
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
6e72a5b9 300BuildRequires: python%{__python_pkg_version}-devel
8a7c4efd
DS
301BuildRequires: python%{__python_pkg_version}-cffi
302BuildRequires: python%{__python_pkg_version}-setuptools
303%endif
304
85ce3f4f 305BuildRequires: libffi-devel
306%endif
307
6e72a5b9 308%description -n python%{__python_pkg_version}-pyzfs
85ce3f4f 309This package provides a python wrapper for the libzfs_core C library.
310%endif
311
2cac7f5f
TF
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
3ce3d305
CL
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
f3757573
BB
338%prep
339%if %{with debug}
340 %define debug --enable-debug
341%else
342 %define debug --disable-debug
343%endif
fed90353
BB
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
63652e15
DS
357%if %{with ubsan}
358 %define ubsan --enable-ubsan
359%else
360 %define ubsan --disable-ubsan
361%endif
362
881f45c6 363%if 0%{?_systemd}
ecd3728b 364 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --with-systemdmodulesloaddir=%{_modulesloaddir} --with-systemdgeneratordir=%{_systemdgeneratordir} --disable-sysvinit
26b60474 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
881f45c6
RE
366%else
367 %define systemd --enable-sysvinit --disable-systemd
368%endif
f3757573 369
6e72a5b9
BB
370%if %{with pyzfs}
371 %define pyzfs --enable-pyzfs
372%else
373 %define pyzfs --disable-pyzfs
374%endif
375
221e6704
FD
376%if %{with pam}
377 %define pam --enable-pam
378%else
379 %define pam --disable-pam
380%endif
381
f3757573
BB
382%setup -q
383
384%build
385%configure \
386 --with-config=user \
387 --with-udevdir=%{_udevdir} \
2ee4e7da 388 --with-udevruledir=%{_udevruledir} \
f3757573 389 --with-dracutdir=%{_dracutdir} \
2f571dbe
RM
390 --with-pamconfigsdir=%{_datadir}/pam-configs \
391 --with-pammoduledir=%{_libdir}/security \
6e72a5b9 392 --with-python=%{__python} \
4d61ade1 393 --with-pkgconfigdir=%{_pkgconfigdir} \
f3757573
BB
394 --disable-static \
395 %{debug} \
fed90353
BB
396 %{debuginfo} \
397 %{asan} \
63652e15 398 %{ubsan} \
221e6704 399 %{systemd} \
2f571dbe 400 %{pam} \
6e72a5b9 401 %{pyzfs}
f3757573
BB
402make %{?_smp_mflags}
403
404%install
405%{__rm} -rf $RPM_BUILD_ROOT
406make install DESTDIR=%{?buildroot}
407find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
4f342e45
RM
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
f3757573 416
ba661a6e 417%post
881f45c6 418%if 0%{?_systemd}
fbd42542 419%if 0%{?systemd_post:1}
b3c159fe 420%systemd_post %{systemd_svcs}
881f45c6 421%else
fbd42542 422if [ "$1" = "1" -o "$1" = "install" ] ; then
423 # Initial installation
424 systemctl preset %{systemd_svcs} >/dev/null || true
425fi
426%endif
427%else
2a34db1b
TF
428if [ -x /sbin/chkconfig ]; then
429 /sbin/chkconfig --add zfs-import
f04b9762 430 /sbin/chkconfig --add zfs-load-key
2a34db1b
TF
431 /sbin/chkconfig --add zfs-mount
432 /sbin/chkconfig --add zfs-share
433 /sbin/chkconfig --add zfs-zed
434fi
881f45c6 435%endif
168d056c 436exit 0
ba661a6e 437
a6cc9756
BB
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
ba661a6e 447%preun
881f45c6 448%if 0%{?_systemd}
fbd42542 449%if 0%{?systemd_preun:1}
b3c159fe 450%systemd_preun %{systemd_svcs}
881f45c6 451%else
fbd42542 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
2a34db1b 460 /sbin/chkconfig --del zfs-import
f04b9762 461 /sbin/chkconfig --del zfs-load-key
2a34db1b
TF
462 /sbin/chkconfig --del zfs-mount
463 /sbin/chkconfig --del zfs-share
464 /sbin/chkconfig --del zfs-zed
ba661a6e 465fi
881f45c6 466%endif
168d056c 467exit 0
f3757573 468
881f45c6 469%postun
881f45c6 470%if 0%{?_systemd}
fbd42542 471%if 0%{?systemd_postun:1}
b3c159fe 472%systemd_postun %{systemd_svcs}
fbd42542 473%else
474systemctl --system daemon-reload >/dev/null || true
475%endif
881f45c6 476%endif
f3757573
BB
477
478%files
6e72a5b9 479# Core utilities
f3757573 480%{_sbindir}/*
6e72a5b9 481%{_bindir}/raidz_test
0ae733c7 482%{_sbindir}/zgenhostid
26b60474 483%{_bindir}/zvol_wait
8a7c4efd 484# Optional Python 3 scripts
6e72a5b9
BB
485%{_bindir}/arc_summary
486%{_bindir}/arcstat
487%{_bindir}/dbufstat
488# Man pages
f3757573 489%{_mandir}/man1/*
2badb345 490%{_mandir}/man4/*
f3757573 491%{_mandir}/man5/*
2badb345 492%{_mandir}/man7/*
f3757573 493%{_mandir}/man8/*
6e72a5b9
BB
494# Configuration files and scripts
495%{_libexecdir}/%{name}
f3757573
BB
496%{_udevdir}/vdev_id
497%{_udevdir}/zvol_id
498%{_udevdir}/rules.d/*
658fb802 499%{_datadir}/%{name}/compatibility.d
9323aad1
MN
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
881f45c6 508%if 0%{?_systemd}
881f45c6
RE
509%{_unitdir}/*
510%{_presetdir}/*
ecd3728b
BB
511%{_modulesloaddir}/*
512%{_systemdgeneratordir}/*
881f45c6 513%else
2a34db1b 514%config(noreplace) %{_sysconfdir}/init.d/*
881f45c6 515%endif
9323aad1
MN
516%config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
517%config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
518%config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
099700d9 519%attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
f3757573 520
612b8dff
AZ
521%config(noreplace) %{_sysconfdir}/bash_completion.d/zfs
522
fe6babce 523%files -n libzpool5
c9b5cc8c
TF
524%{_libdir}/libzpool.so.*
525
8434017a 526%files -n libnvpair3
c9b5cc8c
TF
527%{_libdir}/libnvpair.so.*
528
8434017a 529%files -n libuutil3
c9b5cc8c
TF
530%{_libdir}/libuutil.so.*
531
fe6babce 532%files -n libzfs5
c9b5cc8c
TF
533%{_libdir}/libzfs*.so.*
534
fe6babce 535%files -n libzfs5-devel
4d61ade1 536%{_pkgconfigdir}/libzfs.pc
1db9e6e4 537%{_pkgconfigdir}/libzfsbootenv.pc
4d61ade1 538%{_pkgconfigdir}/libzfs_core.pc
f3757573
BB
539%{_libdir}/*.so
540%{_includedir}/*
93ce2b4c 541%doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
f3757573
BB
542
543%files test
658fb802
CB
544%{_datadir}/%{name}/zfs-tests
545%{_datadir}/%{name}/test-runner
546%{_datadir}/%{name}/runfiles
547%{_datadir}/%{name}/*.sh
f3757573
BB
548
549%files dracut
4a4e1683 550%doc contrib/dracut/README.md
f3757573
BB
551%{_dracutdir}/modules.d/*
552
6e72a5b9
BB
553%if %{with pyzfs}
554%files -n python%{__python_pkg_version}-pyzfs
85ce3f4f 555%doc contrib/pyzfs/README
556%doc contrib/pyzfs/LICENSE
557%defattr(-,root,root,-)
02fad926
ST
558%{__python_sitelib}/libzfs_core/*
559%{__python_sitelib}/pyzfs*
85ce3f4f 560%endif
561
2cac7f5f
TF
562%if 0%{?_initramfs}
563%files initramfs
4a4e1683 564%doc contrib/initramfs/README.md
2cac7f5f
TF
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
3ce3d305
CL
571
572%if %{with pam}
573%files -n pam_zfs_key
574%{_libdir}/security/*
575%{_datadir}/pam-configs/*
576%endif