File zfs.spec of Package zfs

#
# spec file for package zfs
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%global _sbindir /sbin

%define _dracutdir %{_libexecdir}/dracut
%define _udevdir   %{_libexecdir}/udev

%bcond_with     debug

Name:           zfs
Version:        2.0.6
Release:        0
Summary:        The ZFS filesystem and utilities
License:        CDDL-1.0
Group:          System/Filesystems
URL:            https://zfsonlinux.org/
Source0:        https://github.com/zfsonlinux/zfs/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
Source1:        %{name}-rpmlintrc
# EDV-Lotse     Begin
Source11:       70-zfs-grub-fix.rules
#Patch11:        zfs-import-scan.patch
# EDV-Lotse     End
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  dracut
BuildRequires:  kernel-syms
BuildRequires:  kernel-source
BuildRequires:  libattr-devel
BuildRequires:  libblkid-devel
BuildRequires:  libtirpc-devel
BuildRequires:  libtool
BuildRequires:  libuuid-devel
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libcrypto)
BuildRequires:  sudo
BuildRequires:  systemd
BuildRequires:  zlib-devel

Requires:       sudo
Recommends:     %{name}-kmp = %{version}
Conflicts:      zfs-fuse
%{?systemd_requires}

%description
ZFS is a combined file system and logical volume manager designed by
Sun Microsystems. The features of ZFS include protection against data
corruption, support for high storage capacities, integration of the
concepts of filesystem and volume management, snapshots and
copy-on-write clones, continuous integrity checking and automatic
repair, RAID-Z and native NFSv4 ACLs.

ZFS on Linux, which is also known as ZoL, includes fully functional
and stable SPA, DMU, ZVOL, and ZPL layers.

%package -n libnvpair3
Summary:        A tools library for manipulating <name, value> pairs
Group:          System/Libraries

%description -n libnvpair3
ZFS is an advanced file system and volume manager which was
originally developed by Sun Microsystems.

The nvpair library provides routines packing an unpacking nv pairs
for transporting data across process boundaries, transporting between
kernel and userland, and possibly saving onto disk files.

%package -n libuutil3
Summary:        ZFS utility library
Group:          System/Libraries

%description -n libuutil3
ZFS is an advanced file system and volume manager which was
originally developed by Sun Microsystems.

The uutil library contains various utility and wrapper functions used
by the ZFS userland.

%package -n libzfs4
Summary:        ZFS filesystem access library
Group:          System/Libraries

%description -n libzfs4
ZFS is an advanced file system and volume manager which was
originally developed by Sun Microsystems.

%package -n libzfs-devel
Summary:        Development headers
Group:          Development/Libraries/C and C++
Requires:       libnvpair3 = %{version}
Requires:       libuutil3 = %{version}
Requires:       libzfs4 = %{version}
Requires:       libzpool4 = %{version}
Provides:       libnvpair3-devel
Provides:       libuutil3-devel
Provides:       libzpool4-devel
Obsoletes:      %{name}-devel

%description -n libzfs-devel
This package contains the header files needed for building additional
applications against the ZFS libraries.

%package -n libzpool4
Summary:        Zpool interface
Group:          System/Libraries

%description -n libzpool4
ZFS is an advanced file system and volume manager which was
originally developed by Sun Microsystems.

The zpool library contains
- Emulation of kernel services in userland
- Routines needed by more than one client of libzpool

%package test
Summary:        Test infrastructure
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
Requires:       acl
Requires:       bc
Requires:       fio
Requires:       ksh
Requires:       lsscsi
Requires:       mdadm
Requires:       parted
Requires:       sysstat

%description test
This package contains test infrastructure and support scripts for
validating the file system.

%package dracut
Summary:        Dracut module
Group:          System/Base
Requires:       %{name} = %{version}
Requires:       dracut

%description dracut
This package contains a dracut module used to construct an initramfs
image which is ZFS aware.

%kernel_module_package -n %{name} -p %{_sourcedir}/preamble

%package kmod
Summary:        The ZFS filesystem kernel modules

%description kmod
This module is the kernel-dependent driver for ZFS filesystem.
This is split out so that multiple kernel driver versions can be installed,
one for each installed kernel.

%prep
%setup -q
%if 0%{?sle_version} >= 120300 && 0%{?is_opensuse}
#%patch11 -p0
%endif

%build
%if 0%{?suse_version} > 1500
export CFLAGS="%{optflags} -I/usr/include/rpc"
sed -e "s|#include <tirpc/rpc/xdr\.h>|#include_next <rpc/xdr.h>|" \
    -i lib/libspl/include/rpc/xdr.h
%endif
./autogen.sh
%configure \
    --with-config=user \
    --with-udevdir=%{_udevdir} \
    --with-udevruledir=%{_udevdir}/rules.d \
    --with-dracutdir=%{_dracutdir} \
    --disable-static \
%if %{with debug}
    --enable-debug \
%else
    --disable-debug \
%endif
    --enable-systemd \
    --with-systemdunitdir=%{_unitdir} \
    --with-systemdpresetdir=%{_presetdir} \
    --disable-sysvinit

make %{?_smp_mflags} V=1

mkdir -p ../obj
for flavor in %{flavors_to_build}; do
    krel=$(make -s -C %{_usrsrc}/linux-obj/%{_target_cpu}/$flavor kernelrelease)
    rm -rf ../obj/$flavor
    cp -r ../%{name}-%{version} ../obj/$flavor
    pushd ../obj/$flavor
    %configure \
    --with-config=kernel \
    --with-linux=%{_usrsrc}/linux \
    --with-linux-obj=%{_usrsrc}/linux-obj/%{_target_cpu}/$flavor \
%if %{with debug}
    --enable-debug \
%else
    --disable-debug \
%endif
%if %{with debug_dmu_tx}
    --enable-debug-dmu-tx
%else
    --disable-debug-dmu-tx
%endif

    make %{?_smp_mflags}
    popd
done

%install
%make_install

find %{buildroot} -type f -name "*.la" -delete -print

ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-import-cache
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-import-scan
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-mount
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-share
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-zed

install -D -m 0644 contrib/bash_completion.d/%{name} %{buildroot}%{_sysconfdir}/bash_completion.d/%{name}
sed -e "s|PARTED:-/sbin/parted|PARTED:-%{_prefix}%{_sbindir}/parted|" -i %{buildroot}%{_datadir}/zfs/common.sh

install -D -m 0644 %{SOURCE11} %{buildroot}%{_sysconfdir}/udev/rules.d/70-zfs-grub-fix.rules

for flavor in %{flavors_to_build}; do
    pushd ../obj/$flavor
    %make_install
    popd
done

rm -rf %{buildroot}%{_usrsrc}

%pre
%service_add_pre %{name}.target
%service_add_pre %{name}-import-cache.service %{name}-import-scan.service
%service_add_pre %{name}-mount.service %{name}-share.service %{name}-zed.service
#/sbin/modprobe zfs

%post
%service_add_post %{name}.target
%service_add_post %{name}-import-cache.service %{name}-import-scan.service
%service_add_post %{name}-mount.service %{name}-share.service %{name}-zed.service

%preun
%service_del_preun %{name}.target
%service_del_preun %{name}-import-cache.service %{name}-import-scan.service
%service_del_preun %{name}-mount.service %{name}-share.service %{name}-zed.service

%postun
%service_del_postun %{name}.target
%service_del_postun %{name}-import-cache.service %{name}-import-scan.service
%service_del_postun %{name}-mount.service %{name}-share.service %{name}-zed.service

%post -n libnvpair3 -p /sbin/ldconfig

%postun -n libnvpair3 -p /sbin/ldconfig

%post -n libuutil3 -p /sbin/ldconfig

%postun -n libuutil3 -p /sbin/ldconfig

%post -n libzfs4 -p /sbin/ldconfig

%postun -n libzfs4 -p /sbin/ldconfig

%post -n libzpool4 -p /sbin/ldconfig

%postun -n libzpool4 -p /sbin/ldconfig

%files
%config %{_sysconfdir}/default/zfs
%config %{_sysconfdir}/udev/rules.d/*
%{_bindir}/*
%{_sbindir}/*
%{_mandir}/man?/*
%{_libexecdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}
%config %{_sysconfdir}/bash_completion.d/*
%{_udevdir}
%{_libexecdir}/modules-load.d/*
%{_unitdir}/*
%{_presetdir}/*
%{_systemdgeneratordir}/*
%attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*

%files -n libnvpair3
%{_libdir}/libnvpair.so.3*

%files -n libuutil3
%{_libdir}/libuutil.so.3*

%files -n libzfs4
%{_libdir}/libzfs.so.4*
%{_libdir}/libzfs_core.so.3*

%files -n libzfs-devel
%license COPYRIGHT LICENSE
%doc AUTHORS NOTICE README.md
#%{_datadir}/pkgconfig/libzfs*
%{_libdir}/pkgconfig/*.pc
%{_libdir}/*.so
%{_includedir}/*

%files -n libzpool4
%{_libdir}/libzpool.so.4*

%files test
%{_datadir}/%{name}

%files dracut
%doc contrib/dracut/README.dracut.markdown
%{_dracutdir}/modules.d/*
%exclude %{_datadir}/initramfs-tools

%changelog
openSUSE Build Service is sponsored by