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