Add BuildRequires gcc, make, elfutils-libelf-devel
[zfs.git] / rpm / generic / zfs.spec.in
blob7c96caacfa170b65b10eb49d180ba7e835fc6499
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 # Set the default _initconfdir when undefined.
32 %if %{undefined _initconfdir}
33 %global _initconfdir /etc/sysconfig
34 %endif
36 %bcond_with debug
37 %bcond_with debuginfo
38 %bcond_with asan
39 %bcond_with systemd
41 # Python permits the !/usr/bin/python shebang for scripts that are cross
42 # compatible between python2 and python3, but Fedora 28 does not. Fedora
43 # wants us to choose python3 for cross-compatible scripts. Since we want
44 # to support python2 and python3 users, exclude our scripts from Fedora 28's
45 # RPM build check, so that we don't get a bunch of build warnings.
47 # Details: https://github.com/zfsonlinux/zfs/issues/7360
49 %global __brp_mangle_shebangs_exclude_from arc_summary.py|arcstat.py|dbufstat.py|test-runner.py|zts-report.py
51 # Generic enable switch for systemd
52 %if %{with systemd}
53 %define _systemd 1
54 %endif
56 # RHEL >= 7 comes with systemd
57 %if 0%{?rhel} >= 7
58 %define _systemd 1
59 %endif
61 # Fedora >= 15 comes with systemd, but only >= 18 has
62 # the proper macros
63 %if 0%{?fedora} >= 18
64 %define _systemd 1
65 %endif
67 # opensuse >= 12.1 comes with systemd, but only >= 13.1
68 # has the proper macros
69 %if 0%{?suse_version} >= 1310
70 %define _systemd 1
71 %endif
73 Name: @PACKAGE@
74 Version: @VERSION@
75 Release: @RELEASE@%{?dist}
76 Summary: Commands to control the kernel modules and libraries
78 Group: System Environment/Kernel
79 License: @ZFS_META_LICENSE@
80 URL: http://zfsonlinux.org/
81 Source0: %{name}-%{version}.tar.gz
82 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
83 Requires: libzpool2 = %{version}
84 Requires: libnvpair1 = %{version}
85 Requires: libuutil1 = %{version}
86 Requires: libzfs2 = %{version}
87 Requires: %{name}-kmod = %{version}
88 Provides: %{name}-kmod-common = %{version}
89 Obsoletes: spl
91 # zfs-fuse provides the same commands and man pages that ZoL does. Renaming
92 # those on either side would conflict with all available documentation.
93 Conflicts: zfs-fuse
95 %if 0%{?rhel}%{?fedora}%{?suse_version}
96 BuildRequires: gcc, make
97 BuildRequires: zlib-devel
98 BuildRequires: libuuid-devel
99 BuildRequires: libblkid-devel
100 BuildRequires: libudev-devel
101 BuildRequires: libattr-devel
102 BuildRequires: openssl-devel
103 %if 0%{?fedora} >= 28
104 BuildRequires: libtirpc-devel
105 %endif
106 Requires: openssl
107 %if 0%{?_systemd}
108 BuildRequires: systemd
109 %endif
110 %endif
112 %if 0%{?_systemd}
113 Requires(post): systemd
114 Requires(preun): systemd
115 Requires(postun): systemd
116 %endif
118 # The zpool iostat/status -c scripts call some utilities like lsblk and iostat
119 Requires: util-linux
120 Requires: sysstat
122 %description
123 This package contains the ZFS command line utilities.
125 %package -n libzpool2
126 Summary: Native ZFS pool library for Linux
127 Group: System Environment/Kernel
129 %description -n libzpool2
130 This package contains the zpool library, which provides support
131 for managing zpools
133 %post -n libzpool2 -p /sbin/ldconfig
134 %postun -n libzpool2 -p /sbin/ldconfig
136 %package -n libnvpair1
137 Summary: Solaris name-value library for Linux
138 Group: System Environment/Kernel
140 %description -n libnvpair1
141 This package contains routines for packing and unpacking name-value
142 pairs. This functionality is used to portably transport data across
143 process boundaries, between kernel and user space, and can be used
144 to write self describing data structures on disk.
146 %post -n libnvpair1 -p /sbin/ldconfig
147 %postun -n libnvpair1 -p /sbin/ldconfig
149 %package -n libuutil1
150 Summary: Solaris userland utility library for Linux
151 Group: System Environment/Kernel
153 %description -n libuutil1
154 This library provides a variety of compatibility functions for ZFS on Linux:
155 * libspl: The Solaris Porting Layer userland library, which provides APIs
156 that make it possible to run Solaris user code in a Linux environment
157 with relatively minimal modification.
158 * libavl: The Adelson-Velskii Landis balanced binary tree manipulation
159 library.
160 * libefi: The Extensible Firmware Interface library for GUID disk
161 partitioning.
162 * libshare: NFS, SMB, and iSCSI service integration for ZFS.
164 %post -n libuutil1 -p /sbin/ldconfig
165 %postun -n libuutil1 -p /sbin/ldconfig
167 %package -n libzfs2
168 Summary: Native ZFS filesystem library for Linux
169 Group: System Environment/Kernel
171 %description -n libzfs2
172 This package provides support for managing ZFS filesystems
174 %post -n libzfs2 -p /sbin/ldconfig
175 %postun -n libzfs2 -p /sbin/ldconfig
177 %package -n libzfs2-devel
178 Summary: Development headers
179 Group: System Environment/Kernel
180 Requires: libzfs2 = %{version}
181 Requires: libzpool2 = %{version}
182 Requires: libnvpair1 = %{version}
183 Requires: libuutil1 = %{version}
184 Provides: libzpool2-devel
185 Provides: libnvpair1-devel
186 Provides: libuutil1-devel
187 Obsoletes: zfs-devel
189 %description -n libzfs2-devel
190 This package contains the header files needed for building additional
191 applications against the ZFS libraries.
193 %package test
194 Summary: Test infrastructure
195 Group: System Environment/Kernel
196 Requires: %{name}%{?_isa} = %{version}-%{release}
197 Requires: parted
198 Requires: lsscsi
199 Requires: mdadm
200 Requires: bc
201 Requires: ksh
202 Requires: fio
203 Requires: acl
204 Requires: sudo
205 Requires: sysstat
206 Requires: libaio
207 %if 0%{?rhel}%{?fedora}%{?suse_version}
208 BuildRequires: libaio-devel
209 %endif
210 AutoReqProv: no
212 %description test
213 This package contains test infrastructure and support scripts for
214 validating the file system.
216 %package dracut
217 Summary: Dracut module
218 Group: System Environment/Kernel
219 Requires: %{name}%{?_isa} = %{version}-%{release}
220 Requires: dracut
221 Requires: /usr/bin/awk
222 Requires: grep
224 %description dracut
225 This package contains a dracut module used to construct an initramfs
226 image which is ZFS aware.
228 %if 0%{?_pyzfs}
229 %package -n pyzfs
230 Summary: Python wrapper for libzfs_core
231 Group: Development/Languages/Python
232 License: Apache-2.0
233 BuildArch: noarch
234 Requires: libzfs2 = %{version}
235 Requires: libnvpair1 = %{version}
236 Requires: libffi
237 Requires: python >= 2.7
238 Requires: python-cffi
239 %if 0%{?rhel}%{?fedora}%{?suse_version}
240 BuildRequires: python-devel
241 BuildRequires: libffi-devel
242 %endif
244 %description -n pyzfs
245 This package provides a python wrapper for the libzfs_core C library.
246 %endif
248 %if 0%{?_initramfs}
249 %package initramfs
250 Summary: Initramfs module
251 Group: System Environment/Kernel
252 Requires: %{name}%{?_isa} = %{version}-%{release}
253 Requires: %{name} = %{version}-%{release}
254 Requires: initramfs-tools
256 %description initramfs
257 This package contains a initramfs module used to construct an initramfs
258 image which is ZFS aware.
259 %endif
261 %prep
262 %if %{with debug}
263 %define debug --enable-debug
264 %else
265 %define debug --disable-debug
266 %endif
268 %if %{with debuginfo}
269 %define debuginfo --enable-debuginfo
270 %else
271 %define debuginfo --disable-debuginfo
272 %endif
274 %if %{with asan}
275 %define asan --enable-asan
276 %else
277 %define asan --disable-asan
278 %endif
280 %if 0%{?_systemd}
281 %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --disable-sysvinit
282 %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
283 %else
284 %define systemd --enable-sysvinit --disable-systemd
285 %endif
287 %setup -q
289 %build
290 %configure \
291 --with-config=user \
292 --with-udevdir=%{_udevdir} \
293 --with-udevruledir=%{_udevruledir} \
294 --with-dracutdir=%{_dracutdir} \
295 --disable-static \
296 %{debug} \
297 %{debuginfo} \
298 %{asan} \
299 %{systemd}
300 make %{?_smp_mflags}
302 %install
303 %{__rm} -rf $RPM_BUILD_ROOT
304 make install DESTDIR=%{?buildroot}
305 find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
307 %post
308 %if 0%{?_systemd}
309 %if 0%{?systemd_post:1}
310 %systemd_post %{systemd_svcs}
311 %else
312 if [ "$1" = "1" -o "$1" = "install" ] ; then
313 # Initial installation
314 systemctl preset %{systemd_svcs} >/dev/null || true
316 %endif
317 %else
318 if [ -x /sbin/chkconfig ]; then
319 /sbin/chkconfig --add zfs-import
320 /sbin/chkconfig --add zfs-mount
321 /sbin/chkconfig --add zfs-share
322 /sbin/chkconfig --add zfs-zed
324 %endif
325 exit 0
327 # On RHEL/CentOS 7 the static nodes aren't refreshed by default after
328 # installing a package. This is the default behavior for Fedora.
329 %posttrans
330 %if 0%{?rhel} == 7 || 0%{?centos} == 7
331 systemctl restart kmod-static-nodes
332 systemctl restart systemd-tmpfiles-setup-dev
333 udevadm trigger
334 %endif
336 %preun
337 %if 0%{?_systemd}
338 %if 0%{?systemd_preun:1}
339 %systemd_preun %{systemd_svcs}
340 %else
341 if [ "$1" = "0" -o "$1" = "remove" ] ; then
342 # Package removal, not upgrade
343 systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
344 systemctl stop %{systemd_svcs} >/dev/null || true
346 %endif
347 %else
348 if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
349 /sbin/chkconfig --del zfs-import
350 /sbin/chkconfig --del zfs-mount
351 /sbin/chkconfig --del zfs-share
352 /sbin/chkconfig --del zfs-zed
354 %endif
355 exit 0
357 %postun
358 %if 0%{?_systemd}
359 %if 0%{?systemd_postun:1}
360 %systemd_postun %{systemd_svcs}
361 %else
362 systemctl --system daemon-reload >/dev/null || true
363 %endif
364 %endif
366 %files
367 %{_sbindir}/*
368 %{_bindir}/*
369 %{_libexecdir}/%{name}
370 %{_mandir}/man1/*
371 %{_mandir}/man5/*
372 %{_mandir}/man8/*
373 %{_udevdir}/vdev_id
374 %{_udevdir}/zvol_id
375 %{_udevdir}/rules.d/*
376 %if 0%{?_systemd}
377 /usr/lib/modules-load.d/*
378 %{_unitdir}/*
379 %{_presetdir}/*
380 %{_generatordir}/*
381 %else
382 %config(noreplace) %{_sysconfdir}/init.d/*
383 %config(noreplace) %{_initconfdir}/zfs
384 %endif
385 %config(noreplace) %{_sysconfdir}/%{name}
386 %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*
388 %files -n libzpool2
389 %{_libdir}/libzpool.so.*
391 %files -n libnvpair1
392 %{_libdir}/libnvpair.so.*
394 %files -n libuutil1
395 %{_libdir}/libuutil.so.*
397 %files -n libzfs2
398 %{_libdir}/libzfs*.so.*
400 %files -n libzfs2-devel
401 %{_datadir}/pkgconfig/libzfs.pc
402 %{_datadir}/pkgconfig/libzfs_core.pc
403 %{_libdir}/*.so
404 %{_includedir}/*
405 %doc AUTHORS COPYRIGHT LICENSE NOTICE README.md
407 %files test
408 %{_datadir}/%{name}
410 %files dracut
411 %doc contrib/dracut/README.dracut.markdown
412 %{_dracutdir}/modules.d/*
414 %if 0%{?_pyzfs}
415 %files -n pyzfs
416 %doc contrib/pyzfs/README
417 %doc contrib/pyzfs/LICENSE
418 %defattr(-,root,root,-)
419 %{python_sitelib}/libzfs_core/*
420 %{python_sitelib}/pyzfs*
421 %endif
423 %if 0%{?_initramfs}
424 %files initramfs
425 %doc contrib/initramfs/README.initramfs.markdown
426 /usr/share/initramfs-tools/*
427 %else
428 # Since we're not building the initramfs package,
429 # ignore those files.
430 %exclude /usr/share/initramfs-tools
431 %endif