config/dracut/90zfs: handle cases where hostid(1) returns all zeros
[zfs.git] / rpm / generic / zfs.spec.in
blob1ce47e1a177fb9695d672007ec111b42011ca8b5
1 %global _sbindir /sbin
2 %global _libdir /%{_lib}
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
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
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
31 %if %{undefined _initconfdir}
32 %global _initconfdir /etc/sysconfig
33 %endif
35 %if %{undefined _unitdir}
36 %global _unitdir %{_prefix}/lib/systemd/system
37 %endif
39 %if %{undefined _presetdir}
40 %global _presetdir %{_prefix}/lib/systemd/system-preset
41 %endif
43 %if %{undefined _modulesloaddir}
44 %global _modulesloaddir %{_prefix}/lib/modules-load.d
45 %endif
47 %if %{undefined _systemdgeneratordir}
48 %global _systemdgeneratordir %{_prefix}/lib/systemd/system-generators
49 %endif
51 %if %{undefined _pkgconfigdir}
52 %global _pkgconfigdir %{_prefix}/%{_lib}/pkgconfig
53 %endif
55 %bcond_with debug
56 %bcond_with debuginfo
57 %bcond_with asan
58 %bcond_with systemd
59 %bcond_with pam
61 # Generic enable switch for systemd
62 %if %{with systemd}
63 %define _systemd 1
64 %endif
66 # RHEL >= 7 comes with systemd
67 %if 0%{?rhel} >= 7
68 %define _systemd 1
69 %endif
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
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
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())")
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
113 Name: @PACKAGE@
114 Version: @VERSION@
115 Release: @RELEASE@%{?dist}
116 Summary: Commands to control the kernel modules and libraries
118 Group: System Environment/Kernel
119 License: @ZFS_META_LICENSE@
120 URL: https://github.com/openzfs/zfs
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
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
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
152 %if 0%{?_systemd}
153 Requires(post): systemd
154 Requires(preun): systemd
155 Requires(postun): systemd
156 %endif
158 # The zpool iostat/status -c scripts call some utilities like lsblk and iostat
159 Requires: util-linux
160 Requires: sysstat
162 %description
163 This package contains the core ZFS command line utilities.
165 %package -n libzpool2
166 Summary: Native ZFS pool library for Linux
167 Group: System Environment/Kernel
169 %description -n libzpool2
170 This package contains the zpool library, which provides support
171 for managing zpools
173 %post -n libzpool2 -p /sbin/ldconfig
174 %postun -n libzpool2 -p /sbin/ldconfig
176 %package -n libnvpair1
177 Summary: Solaris name-value library for Linux
178 Group: System Environment/Kernel
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.
186 %post -n libnvpair1 -p /sbin/ldconfig
187 %postun -n libnvpair1 -p /sbin/ldconfig
189 %package -n libuutil1
190 Summary: Solaris userland utility library for Linux
191 Group: System Environment/Kernel
193 %description -n libuutil1
194 This library provides a variety of compatibility functions for OpenZFS:
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.
204 %post -n libuutil1 -p /sbin/ldconfig
205 %postun -n libuutil1 -p /sbin/ldconfig
207 %package -n libzfs2
208 Summary: Native ZFS filesystem library for Linux
209 Group: System Environment/Kernel
211 %description -n libzfs2
212 This package provides support for managing ZFS filesystems
214 %post -n libzfs2 -p /sbin/ldconfig
215 %postun -n libzfs2 -p /sbin/ldconfig
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
229 %description -n libzfs2-devel
230 This package contains the header files needed for building additional
231 applications against the ZFS libraries.
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
253 %description test
254 This package contains test infrastructure and support scripts for
255 validating the file system.
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
266 %description dracut
267 This package contains a dracut module used to construct an initramfs
268 image which is ZFS aware.
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
288 %description -n python%{__python_pkg_version}-pyzfs
289 This package provides a python wrapper for the libzfs_core C library.
290 %endif
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
300 %description initramfs
301 This package contains a initramfs module used to construct an initramfs
302 image which is ZFS aware.
303 %endif
305 %prep
306 %if %{with debug}
307 %define debug --enable-debug
308 %else
309 %define debug --disable-debug
310 %endif
312 %if %{with debuginfo}
313 %define debuginfo --enable-debuginfo
314 %else
315 %define debuginfo --disable-debuginfo
316 %endif
318 %if %{with asan}
319 %define asan --enable-asan
320 %else
321 %define asan --disable-asan
322 %endif
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
331 %if %{with pyzfs}
332 %define pyzfs --enable-pyzfs
333 %else
334 %define pyzfs --disable-pyzfs
335 %endif
337 %if %{with pam}
338 %define pam --enable-pam
339 %else
340 %define pam --disable-pam
341 %endif
343 %setup -q
345 %build
346 %configure \
347 --with-config=user \
348 --with-udevdir=%{_udevdir} \
349 --with-udevruledir=%{_udevruledir} \
350 --with-dracutdir=%{_dracutdir} \
351 --with-pamconfigsdir=%{_datadir}/pam-configs \
352 --with-pammoduledir=%{_libdir}/security \
353 --with-python=%{__python} \
354 --with-pkgconfigdir=%{_pkgconfigdir} \
355 --disable-static \
356 %{debug} \
357 %{debuginfo} \
358 %{asan} \
359 %{systemd} \
360 %{pam} \
361 %{pyzfs}
362 make %{?_smp_mflags}
364 %install
365 %{__rm} -rf $RPM_BUILD_ROOT
366 make install DESTDIR=%{?buildroot}
367 find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
368 %if 0%{!?__brp_mangle_shebangs:1}
369 find %{?buildroot}%{_bindir} \
370 \( -name arc_summary -or -name arcstat -or -name dbufstat \) \
371 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
372 find %{?buildroot}%{_datadir} \
373 \( -name test-runner.py -or -name zts-report.py \) \
374 -exec %{__sed} -i 's|^#!.*|#!%{__python}|' {} \;
375 %endif
377 %post
378 %if 0%{?_systemd}
379 %if 0%{?systemd_post:1}
380 %systemd_post %{systemd_svcs}
381 %else
382 if [ "$1" = "1" -o "$1" = "install" ] ; then
383 # Initial installation
384 systemctl preset %{systemd_svcs} >/dev/null || true
386 %endif
387 %else
388 if [ -x /sbin/chkconfig ]; then
389 /sbin/chkconfig --add zfs-import
390 /sbin/chkconfig --add zfs-mount
391 /sbin/chkconfig --add zfs-share
392 /sbin/chkconfig --add zfs-zed
394 %endif
395 exit 0
397 # On RHEL/CentOS 7 the static nodes aren't refreshed by default after
398 # installing a package. This is the default behavior for Fedora.
399 %posttrans
400 %if 0%{?rhel} == 7 || 0%{?centos} == 7
401 systemctl restart kmod-static-nodes
402 systemctl restart systemd-tmpfiles-setup-dev
403 udevadm trigger
404 %endif
406 %preun
407 %if 0%{?_systemd}
408 %if 0%{?systemd_preun:1}
409 %systemd_preun %{systemd_svcs}
410 %else
411 if [ "$1" = "0" -o "$1" = "remove" ] ; then
412 # Package removal, not upgrade
413 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
414 systemctl stop %{systemd_svcs} >/dev/null || true
416 %endif
417 %else
418 if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
419 /sbin/chkconfig --del zfs-import
420 /sbin/chkconfig --del zfs-mount
421 /sbin/chkconfig --del zfs-share
422 /sbin/chkconfig --del zfs-zed
424 %endif
425 exit 0
427 %postun
428 %if 0%{?_systemd}
429 %if 0%{?systemd_postun:1}
430 %systemd_postun %{systemd_svcs}
431 %else
432 systemctl --system daemon-reload >/dev/null || true
433 %endif
434 %endif
436 %files
437 # Core utilities
438 %{_sbindir}/*
439 %{_bindir}/raidz_test
440 %{_bindir}/zgenhostid
441 %{_bindir}/zvol_wait
442 %{_bindir}/zpool_influxdb
443 # Optional Python 2/3 scripts
444 %{_bindir}/arc_summary
445 %{_bindir}/arcstat
446 %{_bindir}/dbufstat
447 # Man pages
448 %{_mandir}/man1/*
449 %{_mandir}/man5/*
450 %{_mandir}/man8/*
451 # Configuration files and scripts
452 %{_libexecdir}/%{name}
453 %{_udevdir}/vdev_id
454 %{_udevdir}/zvol_id
455 %{_udevdir}/rules.d/*
456 %if ! 0%{?_systemd} || 0%{?_initramfs}
457 # Files needed for sysvinit and initramfs-tools
458 %{_sysconfdir}/%{name}/zfs-functions
459 %config(noreplace) %{_initconfdir}/zfs
460 %else
461 %exclude %{_sysconfdir}/%{name}/zfs-functions
462 %exclude %{_initconfdir}/zfs
463 %endif
464 %if 0%{?_systemd}
465 %{_unitdir}/*
466 %{_presetdir}/*
467 %{_modulesloaddir}/*
468 %{_systemdgeneratordir}/*
469 %else
470 %config(noreplace) %{_sysconfdir}/init.d/*
471 %endif
472 %config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
473 %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
474 %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
475 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
476 %if %{with pam}
477 %{_libdir}/security/*
478 %{_datadir}/pam-configs/*
479 %endif
481 %files -n libzpool2
482 %{_libdir}/libzpool.so.*
484 %files -n libnvpair1
485 %{_libdir}/libnvpair.so.*
487 %files -n libuutil1
488 %{_libdir}/libuutil.so.*
490 %files -n libzfs2
491 %{_libdir}/libzfs*.so.*
493 %files -n libzfs2-devel
494 %{_pkgconfigdir}/libzfs.pc
495 %{_pkgconfigdir}/libzfsbootenv.pc
496 %{_pkgconfigdir}/libzfs_core.pc
497 %{_libdir}/*.so
498 %{_includedir}/*
499 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
501 %files test
502 %{_datadir}/%{name}
504 %files dracut
505 %doc contrib/dracut/README.dracut.markdown
506 %{_dracutdir}/modules.d/*
508 %if %{with pyzfs}
509 %files -n python%{__python_pkg_version}-pyzfs
510 %doc contrib/pyzfs/README
511 %doc contrib/pyzfs/LICENSE
512 %defattr(-,root,root,-)
513 %{__python_sitelib}/libzfs_core/*
514 %{__python_sitelib}/pyzfs*
515 %endif
517 %if 0%{?_initramfs}
518 %files initramfs
519 %doc contrib/initramfs/README.initramfs.markdown
520 /usr/share/initramfs-tools/*
521 %else
522 # Since we're not building the initramfs package,
523 # ignore those files.
524 %exclude /usr/share/initramfs-tools
525 %endif