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