]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - rpm/generic/zfs.spec.in
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.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-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}
363
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
376
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
385 fi
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
393 fi
394 %endif
395 exit 0
396
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
405
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
415 fi
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
423 fi
424 %endif
425 exit 0
426
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
435
436 %files
437 # Core utilities
438 %{_sbindir}/*
439 %{_bindir}/raidz_test
440 %{_bindir}/zgenhostid
441 %{_bindir}/zvol_wait
442 # Optional Python 2/3 scripts
443 %{_bindir}/arc_summary
444 %{_bindir}/arcstat
445 %{_bindir}/dbufstat
446 # Man pages
447 %{_mandir}/man1/*
448 %{_mandir}/man5/*
449 %{_mandir}/man8/*
450 # Configuration files and scripts
451 %{_libexecdir}/%{name}
452 %{_udevdir}/vdev_id
453 %{_udevdir}/zvol_id
454 %{_udevdir}/rules.d/*
455 %if ! 0%{?_systemd} || 0%{?_initramfs}
456 # Files needed for sysvinit and initramfs-tools
457 %{_sysconfdir}/%{name}/zfs-functions
458 %config(noreplace) %{_initconfdir}/zfs
459 %else
460 %exclude %{_sysconfdir}/%{name}/zfs-functions
461 %exclude %{_initconfdir}/zfs
462 %endif
463 %if 0%{?_systemd}
464 %{_unitdir}/*
465 %{_presetdir}/*
466 %{_modulesloaddir}/*
467 %{_systemdgeneratordir}/*
468 %else
469 %config(noreplace) %{_sysconfdir}/init.d/*
470 %endif
471 %config(noreplace) %{_sysconfdir}/%{name}/zed.d/*
472 %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/*
473 %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example
474 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
475 %if %{with pam}
476 %{_libdir}/security/*
477 %{_datadir}/pam-configs/*
478 %endif
479
480 %files -n libzpool2
481 %{_libdir}/libzpool.so.*
482
483 %files -n libnvpair1
484 %{_libdir}/libnvpair.so.*
485
486 %files -n libuutil1
487 %{_libdir}/libuutil.so.*
488
489 %files -n libzfs2
490 %{_libdir}/libzfs*.so.*
491
492 %files -n libzfs2-devel
493 %{_pkgconfigdir}/libzfs.pc
494 %{_pkgconfigdir}/libzfs_core.pc
495 %{_libdir}/*.so
496 %{_includedir}/*
497 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
498
499 %files test
500 %{_datadir}/%{name}
501
502 %files dracut
503 %doc contrib/dracut/README.dracut.markdown
504 %{_dracutdir}/modules.d/*
505
506 %if %{with pyzfs}
507 %files -n python%{__python_pkg_version}-pyzfs
508 %doc contrib/pyzfs/README
509 %doc contrib/pyzfs/LICENSE
510 %defattr(-,root,root,-)
511 %{__python_sitelib}/libzfs_core/*
512 %{__python_sitelib}/pyzfs*
513 %endif
514
515 %if 0%{?_initramfs}
516 %files initramfs
517 %doc contrib/initramfs/README.initramfs.markdown
518 /usr/share/initramfs-tools/*
519 %else
520 # Since we're not building the initramfs package,
521 # ignore those files.
522 %exclude /usr/share/initramfs-tools
523 %endif