]> git.proxmox.com Git - mirror_zfs.git/blame - rpm/generic/zfs.spec.in
Exclude test-runner.py from the rpmbuild shebang check
[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}
2ee4e7da 6%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
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}
2ee4e7da 15%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
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}
2ee4e7da
TF
24%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
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
f3757573 51%bcond_with debug
fed90353
BB
52%bcond_with debuginfo
53%bcond_with asan
881f45c6 54%bcond_with systemd
f3757573 55
466f5533
TH
56# Exclude test-runner.py from the rpmbuild shebang check to allow it to run
57# under Python 2 and 3.
58%global __brp_mangle_shebangs_exclude_from test-runner.py
59
881f45c6
RE
60# Generic enable switch for systemd
61%if %{with systemd}
62%define _systemd 1
63%endif
64
8b974ba0
BA
65# RHEL >= 7 comes with systemd
66%if 0%{?rhel} >= 7
67%define _systemd 1
68%endif
69
881f45c6
RE
70# Fedora >= 15 comes with systemd, but only >= 18 has
71# the proper macros
72%if 0%{?fedora} >= 18
73%define _systemd 1
74%endif
75
76# opensuse >= 12.1 comes with systemd, but only >= 13.1
77# has the proper macros
78%if 0%{?suse_version} >= 1310
79%define _systemd 1
80%endif
f3757573 81
6e72a5b9
BB
82# When not specified default to distribution provided version. This
83# is normally Python 3, but for RHEL <= 7 only Python 2 is provided.
84%if %{undefined __use_python}
85%if 0%{?rhel} && 0%{?rhel} <= 7
e34cd80d
BB
86%define __python /usr/bin/python2
87%define __python_pkg_version 2
88%define __python_cffi_pkg python-cffi
89%define __python_setuptools_pkg python-setuptools
6e72a5b9 90%else
e34cd80d
BB
91%define __python /usr/bin/python3
92%define __python_pkg_version 3
93%define __python_cffi_pkg python3-cffi
94%define __python_setuptools_pkg python3-setuptools
6e72a5b9
BB
95%endif
96%else
e34cd80d
BB
97%define __python %{__use_python}
98%define __python_pkg_version %{__use_python_pkg_version}
99%define __python_cffi_pkg python%{__python_pkg_version}-cffi
100%define __python_setuptools_pkg python%{__python_pkg_version}-setuptools
6e72a5b9
BB
101%endif
102
103# By default python-pyzfs is enabled, with the exception of
104# RHEL 6 which by default uses Python 2.6 which is too old.
105%if 0%{?rhel} == 6
106%bcond_with pyzfs
107%else
108%bcond_without pyzfs
109%endif
110
f3757573
BB
111Name: @PACKAGE@
112Version: @VERSION@
113Release: @RELEASE@%{?dist}
114Summary: Commands to control the kernel modules and libraries
115
116Group: System Environment/Kernel
117License: @ZFS_META_LICENSE@
118URL: http://zfsonlinux.org/
119Source0: %{name}-%{version}.tar.gz
120BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
c9b5cc8c
TF
121Requires: libzpool2 = %{version}
122Requires: libnvpair1 = %{version}
123Requires: libuutil1 = %{version}
124Requires: libzfs2 = %{version}
28967367 125Requires: %{name}-kmod = %{version}
f3757573 126Provides: %{name}-kmod-common = %{version}
93ce2b4c 127Obsoletes: spl
f3757573 128
f12971e6
RE
129# zfs-fuse provides the same commands and man pages that ZoL does. Renaming
130# those on either side would conflict with all available documentation.
131Conflicts: zfs-fuse
132
f3757573 133%if 0%{?rhel}%{?fedora}%{?suse_version}
d7bda38c 134BuildRequires: gcc, make
f3757573
BB
135BuildRequires: zlib-devel
136BuildRequires: libuuid-devel
f3757573 137BuildRequires: libblkid-devel
de0ef912
BB
138BuildRequires: libudev-devel
139BuildRequires: libattr-devel
4807c0ba 140BuildRequires: openssl-devel
1a62a305
TH
141%if 0%{?fedora} >= 28
142BuildRequires: libtirpc-devel
143%endif
4807c0ba 144Requires: openssl
ee410eef 145%if 0%{?_systemd}
146BuildRequires: systemd
147%endif
f3757573 148%endif
ee410eef 149
881f45c6
RE
150%if 0%{?_systemd}
151Requires(post): systemd
152Requires(preun): systemd
153Requires(postun): systemd
881f45c6 154%endif
f3757573 155
d6418de0
TH
156# The zpool iostat/status -c scripts call some utilities like lsblk and iostat
157Requires: util-linux
158Requires: sysstat
159
f3757573 160%description
6e72a5b9 161This package contains the core ZFS command line utilities.
f3757573 162
c9b5cc8c
TF
163%package -n libzpool2
164Summary: Native ZFS pool library for Linux
165Group: System Environment/Kernel
166
167%description -n libzpool2
168This package contains the zpool library, which provides support
169for managing zpools
170
c0ba93de 171%post -n libzpool2 -p /sbin/ldconfig
c9b5cc8c
TF
172%postun -n libzpool2 -p /sbin/ldconfig
173
174%package -n libnvpair1
175Summary: Solaris name-value library for Linux
176Group: System Environment/Kernel
177
178%description -n libnvpair1
179This package contains routines for packing and unpacking name-value
180pairs. This functionality is used to portably transport data across
181process boundaries, between kernel and user space, and can be used
182to write self describing data structures on disk.
183
c0ba93de 184%post -n libnvpair1 -p /sbin/ldconfig
c9b5cc8c
TF
185%postun -n libnvpair1 -p /sbin/ldconfig
186
187%package -n libuutil1
188Summary: Solaris userland utility library for Linux
189Group: System Environment/Kernel
190
191%description -n libuutil1
192This library provides a variety of compatibility functions for ZFS on Linux:
193 * libspl: The Solaris Porting Layer userland library, which provides APIs
194 that make it possible to run Solaris user code in a Linux environment
195 with relatively minimal modification.
196 * libavl: The Adelson-Velskii Landis balanced binary tree manipulation
197 library.
198 * libefi: The Extensible Firmware Interface library for GUID disk
199 partitioning.
200 * libshare: NFS, SMB, and iSCSI service integration for ZFS.
201
c0ba93de 202%post -n libuutil1 -p /sbin/ldconfig
c9b5cc8c
TF
203%postun -n libuutil1 -p /sbin/ldconfig
204
205%package -n libzfs2
206Summary: Native ZFS filesystem library for Linux
207Group: System Environment/Kernel
208
209%description -n libzfs2
210This package provides support for managing ZFS filesystems
211
c0ba93de 212%post -n libzfs2 -p /sbin/ldconfig
c9b5cc8c
TF
213%postun -n libzfs2 -p /sbin/ldconfig
214
215%package -n libzfs2-devel
f3757573
BB
216Summary: Development headers
217Group: System Environment/Kernel
c9b5cc8c
TF
218Requires: libzfs2 = %{version}
219Requires: libzpool2 = %{version}
220Requires: libnvpair1 = %{version}
221Requires: libuutil1 = %{version}
222Provides: libzpool2-devel
223Provides: libnvpair1-devel
224Provides: libuutil1-devel
225Obsoletes: zfs-devel
f3757573 226
c9b5cc8c 227%description -n libzfs2-devel
f3757573
BB
228This package contains the header files needed for building additional
229applications against the ZFS libraries.
230
231%package test
232Summary: Test infrastructure
233Group: System Environment/Kernel
234Requires: %{name}%{?_isa} = %{version}-%{release}
235Requires: parted
236Requires: lsscsi
237Requires: mdadm
238Requires: bc
6bb24f4d 239Requires: ksh
13589da9
BB
240Requires: fio
241Requires: acl
242Requires: sudo
243Requires: sysstat
3905cace 244Requires: libaio
6e72a5b9 245Requires: python%{__python_pkg_version}
644e01a2 246%if 0%{?rhel}%{?fedora}%{?suse_version}
55972a67 247BuildRequires: libaio-devel
644e01a2 248%endif
13589da9 249AutoReqProv: no
f3757573
BB
250
251%description test
252This package contains test infrastructure and support scripts for
253validating the file system.
254
255%package dracut
256Summary: Dracut module
257Group: System Environment/Kernel
258Requires: %{name}%{?_isa} = %{version}-%{release}
259Requires: dracut
3905cace
BB
260Requires: /usr/bin/awk
261Requires: grep
f3757573
BB
262
263%description dracut
264This package contains a dracut module used to construct an initramfs
265image which is ZFS aware.
266
6e72a5b9
BB
267%if %{with pyzfs}
268%package -n python%{__python_pkg_version}-pyzfs
269Summary: Python %{python_version} wrapper for libzfs_core
85ce3f4f 270Group: Development/Languages/Python
271License: Apache-2.0
272BuildArch: noarch
273Requires: libzfs2 = %{version}
274Requires: libnvpair1 = %{version}
275Requires: libffi
6e72a5b9
BB
276Requires: python%{__python_pkg_version}
277Requires: %{__python_cffi_pkg}
85ce3f4f 278%if 0%{?rhel}%{?fedora}%{?suse_version}
6e72a5b9 279BuildRequires: python%{__python_pkg_version}-devel
e34cd80d
BB
280BuildRequires: %{__python_cffi_pkg}
281BuildRequires: %{__python_setuptools_pkg}
85ce3f4f 282BuildRequires: libffi-devel
283%endif
284
6e72a5b9 285%description -n python%{__python_pkg_version}-pyzfs
85ce3f4f 286This package provides a python wrapper for the libzfs_core C library.
287%endif
288
2cac7f5f
TF
289%if 0%{?_initramfs}
290%package initramfs
291Summary: Initramfs module
292Group: System Environment/Kernel
293Requires: %{name}%{?_isa} = %{version}-%{release}
294Requires: %{name} = %{version}-%{release}
295Requires: initramfs-tools
296
297%description initramfs
298This package contains a initramfs module used to construct an initramfs
299image which is ZFS aware.
300%endif
301
f3757573
BB
302%prep
303%if %{with debug}
304 %define debug --enable-debug
305%else
306 %define debug --disable-debug
307%endif
fed90353
BB
308
309%if %{with debuginfo}
310 %define debuginfo --enable-debuginfo
311%else
312 %define debuginfo --disable-debuginfo
313%endif
314
315%if %{with asan}
316 %define asan --enable-asan
317%else
318 %define asan --disable-asan
319%endif
320
881f45c6 321%if 0%{?_systemd}
ecd3728b 322 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --with-systemdmodulesloaddir=%{_modulesloaddir} --with-systemdgeneratordir=%{_systemdgeneratordir} --disable-sysvinit
9920950c 323 %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
881f45c6
RE
324%else
325 %define systemd --enable-sysvinit --disable-systemd
326%endif
f3757573 327
6e72a5b9
BB
328%if %{with pyzfs}
329 %define pyzfs --enable-pyzfs
330%else
331 %define pyzfs --disable-pyzfs
332%endif
333
f3757573
BB
334%setup -q
335
336%build
337%configure \
338 --with-config=user \
339 --with-udevdir=%{_udevdir} \
2ee4e7da 340 --with-udevruledir=%{_udevruledir} \
f3757573 341 --with-dracutdir=%{_dracutdir} \
6e72a5b9 342 --with-python=%{__python} \
f3757573
BB
343 --disable-static \
344 %{debug} \
fed90353
BB
345 %{debuginfo} \
346 %{asan} \
6e72a5b9
BB
347 %{systemd}\
348 %{pyzfs}
f3757573
BB
349make %{?_smp_mflags}
350
351%install
352%{__rm} -rf $RPM_BUILD_ROOT
353make install DESTDIR=%{?buildroot}
354find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
355
ba661a6e 356%post
881f45c6 357%if 0%{?_systemd}
fbd42542 358%if 0%{?systemd_post:1}
b3c159fe 359%systemd_post %{systemd_svcs}
881f45c6 360%else
fbd42542 361if [ "$1" = "1" -o "$1" = "install" ] ; then
362 # Initial installation
363 systemctl preset %{systemd_svcs} >/dev/null || true
364fi
365%endif
366%else
2a34db1b
TF
367if [ -x /sbin/chkconfig ]; then
368 /sbin/chkconfig --add zfs-import
369 /sbin/chkconfig --add zfs-mount
370 /sbin/chkconfig --add zfs-share
371 /sbin/chkconfig --add zfs-zed
372fi
881f45c6 373%endif
168d056c 374exit 0
ba661a6e 375
a6cc9756
BB
376# On RHEL/CentOS 7 the static nodes aren't refreshed by default after
377# installing a package. This is the default behavior for Fedora.
378%posttrans
379%if 0%{?rhel} == 7 || 0%{?centos} == 7
380systemctl restart kmod-static-nodes
381systemctl restart systemd-tmpfiles-setup-dev
382udevadm trigger
383%endif
384
ba661a6e 385%preun
881f45c6 386%if 0%{?_systemd}
fbd42542 387%if 0%{?systemd_preun:1}
b3c159fe 388%systemd_preun %{systemd_svcs}
881f45c6 389%else
fbd42542 390if [ "$1" = "0" -o "$1" = "remove" ] ; then
391 # Package removal, not upgrade
392 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
393 systemctl stop %{systemd_svcs} >/dev/null || true
394fi
395%endif
396%else
397if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
2a34db1b
TF
398 /sbin/chkconfig --del zfs-import
399 /sbin/chkconfig --del zfs-mount
400 /sbin/chkconfig --del zfs-share
401 /sbin/chkconfig --del zfs-zed
ba661a6e 402fi
881f45c6 403%endif
168d056c 404exit 0
f3757573 405
881f45c6 406%postun
881f45c6 407%if 0%{?_systemd}
fbd42542 408%if 0%{?systemd_postun:1}
b3c159fe 409%systemd_postun %{systemd_svcs}
fbd42542 410%else
411systemctl --system daemon-reload >/dev/null || true
412%endif
881f45c6 413%endif
f3757573
BB
414
415%files
6e72a5b9 416# Core utilities
f3757573 417%{_sbindir}/*
6e72a5b9
BB
418%{_bindir}/raidz_test
419%{_bindir}/zgenhostid
420# Optional Python 2/3 scripts
421%{_bindir}/arc_summary
422%{_bindir}/arcstat
423%{_bindir}/dbufstat
424# Man pages
f3757573
BB
425%{_mandir}/man1/*
426%{_mandir}/man5/*
427%{_mandir}/man8/*
6e72a5b9
BB
428# Configuration files and scripts
429%{_libexecdir}/%{name}
f3757573
BB
430%{_udevdir}/vdev_id
431%{_udevdir}/zvol_id
432%{_udevdir}/rules.d/*
881f45c6 433%if 0%{?_systemd}
881f45c6
RE
434%{_unitdir}/*
435%{_presetdir}/*
ecd3728b
BB
436%{_modulesloaddir}/*
437%{_systemdgeneratordir}/*
881f45c6 438%else
2a34db1b
TF
439%config(noreplace) %{_sysconfdir}/init.d/*
440%config(noreplace) %{_initconfdir}/zfs
881f45c6 441%endif
2a34db1b 442%config(noreplace) %{_sysconfdir}/%{name}
099700d9 443%attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
f3757573 444
c9b5cc8c
TF
445%files -n libzpool2
446%{_libdir}/libzpool.so.*
447
448%files -n libnvpair1
449%{_libdir}/libnvpair.so.*
450
451%files -n libuutil1
452%{_libdir}/libuutil.so.*
453
454%files -n libzfs2
455%{_libdir}/libzfs*.so.*
456
457%files -n libzfs2-devel
c3f8dc2a
TF
458%{_datadir}/pkgconfig/libzfs.pc
459%{_datadir}/pkgconfig/libzfs_core.pc
f3757573
BB
460%{_libdir}/*.so
461%{_includedir}/*
93ce2b4c 462%doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
f3757573
BB
463
464%files test
465%{_datadir}/%{name}
466
467%files dracut
cc492505 468%doc contrib/dracut/README.dracut.markdown
f3757573
BB
469%{_dracutdir}/modules.d/*
470
6e72a5b9
BB
471%if %{with pyzfs}
472%files -n python%{__python_pkg_version}-pyzfs
85ce3f4f 473%doc contrib/pyzfs/README
474%doc contrib/pyzfs/LICENSE
475%defattr(-,root,root,-)
476%{python_sitelib}/libzfs_core/*
477%{python_sitelib}/pyzfs*
478%endif
479
2cac7f5f
TF
480%if 0%{?_initramfs}
481%files initramfs
482%doc contrib/initramfs/README.initramfs.markdown
483/usr/share/initramfs-tools/*
484%else
485# Since we're not building the initramfs package,
486# ignore those files.
487%exclude /usr/share/initramfs-tools
488%endif