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