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

%global _sbindir /sbin

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

%bcond_with     debug

Name:           zfs
Version:        0.8.4
Release:        0
Summary:        The ZFS filesystem and utilities
License:        CDDL-1.0
Group:          System/Filesystems
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

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 libnvpair1
Summary:        A tools library for manipulating <name, value> pairs
Group:          System/Libraries

%description -n libnvpair1
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 libuutil1
Summary:        ZFS utility library
Group:          System/Libraries

%description -n libuutil1
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 libzfs2
Summary:        ZFS filesystem access library
Group:          System/Libraries

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

%package -n libzfs2-devel
Summary:        Development headers
Group:          Development/Libraries/C and C++
Requires:       libnvpair1 = %{version}
Requires:       libuutil1 = %{version}
Requires:       libzfs2 = %{version}
Requires:       libzpool2 = %{version}
Provides:       libnvpair1-devel
Provides:       libuutil1-devel
Provides:       libzpool2-devel
Obsoletes:      %{name}-devel

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

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

%description -n libzpool2
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.

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

%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
%configure \
    --with-config=user \
    --with-udevdir=%{_udevdir} \
    --with-udevruledir=%{_udevdir}/rules.d \
    --with-dracutdir=%{_dracutdir} \
    --disable-static \
%if %{with debug}
    --enable-debug \
    --disable-debug \
    --enable-systemd \
    --with-systemdunitdir=%{_unitdir} \
    --with-systemdpresetdir=%{_presetdir} \

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 \
    --disable-debug \
%if %{with debug_dmu_tx}

    make %{?_smp_mflags}


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/

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

rm -rf %{buildroot}%{_usrsrc}

%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

%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

%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

%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 libnvpair1 -p /sbin/ldconfig

%postun -n libnvpair1 -p /sbin/ldconfig

%post -n libuutil1 -p /sbin/ldconfig

%postun -n libuutil1 -p /sbin/ldconfig

%post -n libzfs2 -p /sbin/ldconfig

%postun -n libzfs2 -p /sbin/ldconfig

%post -n libzpool2 -p /sbin/ldconfig

%postun -n libzpool2 -p /sbin/ldconfig

%config %{_sysconfdir}/default/zfs
%config %{_sysconfdir}/udev/rules.d/*
%config(noreplace) %{_sysconfdir}/%{name}
%config %{_sysconfdir}/bash_completion.d/*
%attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/*

%files -n libnvpair1

%files -n libuutil1

%files -n libzfs2

%files -n libzfs2-devel

%files -n libzpool2

%files test

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

openSUSE Build Service is sponsored by