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