File zfs.spec of Package zfs

#
# spec file for package zfs
#
# Copyright (c) 2017 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 http://bugs.opensuse.org/
#


%global _sbindir /sbin

%define _dracutdir %{_libexecdir}/dracut
%if 0%{?suse_version} < 1230
%define _udevdir   /lib/udev
%else
%define _udevdir   %{_libexecdir}/udev
%endif
%if 0%{?suse_version} < 1130
%define _initddir  %{_sysconfdir}/init.d
%endif
%if 0%{?suse_version} >= 1230
%define _systemd 1
%if 0%{?suse_version} <= 1230
%define _presetdir %{_libexecdir}/systemd/system-preset
%endif
%endif

%bcond_with     debug
%bcond_with     blkid


Name:           zfs
Version:        0.7.0
Release:        rc4
Summary:        Commands to control the kernel modules
License:        CDDL-1.0
Group:          System/Filesystems
Url:            http://zfsonlinux.org/
Source0:        https://github.com/zfsonlinux/zfs/archive/%{name}-%{version}.tar.bz2
Source1:        %{name}.init
Source2:        %{name}-rpmlintrc
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  dracut
BuildRequires:  libblkid-devel
BuildRequires:  libattr-devel
BuildRequires:  libtool
BuildRequires:  libuuid-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
%if 0%{?_systemd}
BuildRequires:  systemd
%{?systemd_requires}
%endif
Requires:       spl = %{version}
Requires(pre):  %fillup_prereq
Requires(pre):  %insserv_prereq
Recommends:     %{name}-kmp = %{version}
Conflicts:      zfs-fuse
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This package contains support utilities for the zfs file system.

%package -n libnvpair1
Summary:        A tools library for manipulating <name, value> pairs
License:        CDDL-1.0
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
License:        CDDL-1.0
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
License:        CDDL-1.0
Group:          System/Libraries
Obsoletes:      libzfs1

%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
License:        CDDL-1.0
Group:          System/Libraries
Obsoletes:      libzpool1

%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:       bc
Requires:       lsscsi
Requires:       mdadm
Requires:       parted

%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.

%prep
%if %{with debug}
    %define debug --enable-debug
%else
    %define debug --disable-debug
%endif
%if %{with blkid}
    %define blkid --with-blkid
%else
    %define blkid --without-blkid
%endif
%if 0%{?_systemd}
    %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --disable-sysvinit
%else
    %define systemd --enable-sysvinit --disable-systemd
%endif

%setup -q -n %{name}-%{name}-%{version}

%build
./autogen.sh
%configure \
	--with-config=user \
	--with-udevdir=%{_udevdir} \
	--with-udevruledir=%{_udevdir}/rules.d \
	--with-dracutdir=%{_dracutdir} \
	--disable-static \
	--disable-test \
	%{debug} \
	%{blkid} \
	%{systemd}

make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install
find %{buildroot} -type f -name "*.la" -delete -print

%if 0%{?_systemd}
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
%else
install -D -m 0755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
ln -s %{_initddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
%endif

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

%pre
%if 0%{?_systemd}
%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
%endif

%post
%if 0%{?_systemd}
%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
%else
%fillup_and_insserv -f -y
%endif

%preun
%if 0%{?_systemd}
%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
%else
%stop_on_removal
%endif

%postun
%if 0%{?_systemd}
%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
%else
%restart_on_update %{name}
%insserv_cleanup
%endif

%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

%files
%defattr(-,root,root)
%{_sbindir}/*
%{_bindir}/*
%{_mandir}/man?/*
%{_libexecdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}
%config %{_sysconfdir}/bash_completion.d/*
%{_udevdir}
%if 0%{?_systemd}
%{_libexecdir}/modules-load.d/*
%{_unitdir}/*
%{_presetdir}/*
%else
%{_sysconfdir}/init.d/*
%endif

%files -n libnvpair1
%defattr(-,root,root)
%{_libdir}/libnvpair.so.1*

%files -n libuutil1
%defattr(-,root,root)
%{_libdir}/libuutil.so.1*

%files -n libzfs2
%defattr(-,root,root)
%{_libdir}/libzfs.so.2*
%{_libdir}/libzfs_core.so.1*

%files -n libzfs2-devel
%defattr(-,root,root)
%{_datadir}/pkgconfig/libzfs*
%{_libdir}/*.so
%{_includedir}/*
%doc AUTHORS COPYRIGHT DISCLAIMER
%doc OPENSOLARIS.LICENSE README.markdown

%files -n libzpool2
%defattr(-,root,root)
%{_libdir}/libzpool.so.2*

%files test
%defattr(-,root,root)
%{_datadir}/%{name}

%files dracut
%defattr(-,root,root)
%doc contrib/dracut/README.dracut.markdown
%{_dracutdir}/modules.d/*
%exclude /usr/share/initramfs-tools

%changelog