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