File multipath-tools.spec of Package multipath-tools.17099

# spec file for package multipath-tools
# 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

# Workaround for Leap 42.1 bug, bsc#940315
%if 0%{?suse_version} == 1315
%if 0%{?is_opensuse} == 1
%if 0%{?sle_version} == 0
%define sle_version 120100

# Whether to build libdmmp
# Default YES on openSUSE factory, SLE15, and leap
# Default NO on SLES 12
# Always NO on other distros
%if 0%{?suse_version} == 1315
%if 0%{?is_opensuse} == 1
%bcond_without libdmmp
%else  # 0%{?is_opensuse} == 1
%bcond_with libdmmp
%endif # 0%{?is_opensuse} == 1
%else  # 0%{?is_opensuse} == 1
%if 0%{?suse_version} >= 1330
%bcond_without libdmmp
%endif # 0%{?suse_version} >= 1330
%endif # 0%{?suse_version} == 1315

# This should match the version in libdmmp/Makefile
%define _libdmmp_version 0.2.0
%define libdmmp_version %(echo %{_libdmmp_version} | tr . _)

# path prefix for systemd unit files and udev rules
%define _sysdir usr/lib

Name:           multipath-tools
Version:        0.7.9+195+suse.16740c5
Release:        0
Summary:        Tools to Manage Multipathed Devices with the device-mapper
License:        GPL-2.0-only AND LGPL-2.0-or-later
Group:          System/Base
Source:         multipath-tools-%{version}.tar.xz
Source1:        multipath.conf
# SUSE policy: disable partition deletion by default
Source2:        dont-del-part-nodes.rules
# Dracut conf file to make sure 11-dm-parts.rules is included in initrd
Source3:        dm-parts.conf
Source4:        libmpathpersist-example.c
Patch01:	libmultipath-set-enable_foreign-to-NONE-by-default.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  device-mapper-devel
BuildRequires:  libaio-devel
%if 0%{?with_libdmmp} == 1
BuildRequires:  libjson-c-devel
BuildRequires:  libudev-devel
BuildRequires:  liburcu-devel
BuildRequires:  readline-devel
BuildRequires:  udev
BuildRequires:  pkgconfig(libsystemd)
BuildRequires:  pkgconfig(systemd)
# For regenerate_initrd_posttrans macro
BuildRequires:	suse-module-tools
# For regenerate-initrd-posttrans
Requires(post):	suse-module-tools
Requires:       device-mapper >= 1.2.78
Requires:       kpartx
Requires:       sg3_utils
# Generate  kmod(xyz)-style dependencies for modules that we put
# in modules-load.d. Use the modules.d file (Source1) as input to avoid
# maintaining these dependencies in several places.
# This feature is to be enabled for SLE15-SP1, and some time in the
# near future, for Factory.
## DISABLED, see bsc#1119414
## if 0%{?sle_version} >= 150100
## (sed 's/^\s*//;s/\s*$//;/^#/d;/^$/d;s/^/Requires: kmod(/;s/$/)/;' %{S:1})
## endif
Obsoletes:      multipath-tools-rbd <= %{version}
PreReq:         coreutils grep

This package provides the multipath tool and the multipathd daemon
to manage dm-multipath devices. multipath can detect and set up
multipath maps. multipathd sets up multipath maps automatically,
monitors path devices for failure, removal, or addition, and applies
the necessary changes to the multipath maps to ensure continuous
availability of the map devices.

%package -n kpartx
Summary:        Manages partition tables on device-mapper devices
License:        GPL-2.0-only
Group:          System/Base
Requires:       device-mapper

%description -n kpartx
The kpartx program maps linear devmaps to device partitions, which
makes multipath maps partionable.

%package devel
Summary:        Development libraries for multipath-tools
License:        GPL-2.0-only AND LGPL-2.0-or-later
Group:          Development/Libraries/C and C++
Requires:       device-mapper
Requires:       multipath-tools = %{version}

%description devel
This package contains the development libraries for multipath-tools
and libmpathpersist.

%if 0%{?with_libdmmp} == 1
%package -n libdmmp%{libdmmp_version}
Summary:        C API for multipath-tools
License:        GPL-3.0-or-later
Group:          System/Libraries
Requires:       multipath-tools

%description -n libdmmp%{libdmmp_version}
This library enables the use of libmultipath commands from C code.

%package -n libdmmp-devel
Summary:        Header files for multipath-tools C API
License:        GPL-3.0-or-later
Group:          Development/Libraries/C and C++
Requires:       libdmmp%{libdmmp_version} = %{version}

%description -n libdmmp-devel
This package provides development files and documentation for libdmmp.


%define makeflags %{!?with_libdmmp:ENABLE_LIBDMMP=0}
%define dirflags LIB=%{_lib} usr_prefix=%{_prefix} SYSTEMDPATH=%{_sysdir}

%setup -q -n multipath-tools-%{version}
cp %{SOURCE4} .
%autopatch -p1

make CC="%__cc" OPTFLAGS="%{optflags}" %{dirflags} %{makeflags}

%make_install %{dirflags} %{makeflags}
mkdir -p %{buildroot}%{_defaultlicensedir}
mkdir -p %{buildroot}/usr/sbin
mkdir -p %{buildroot}/usr/%{_lib}
for x in multipath mpathpersist mpathcmd; do
    rm -f %{buildroot}/%{_lib}/lib$
    ln -sf /%{_lib}/lib$  %{buildroot}/usr/%{_lib}/lib$
ln -sf /usr/sbin/service %{buildroot}/usr/sbin/rcmultipathd
mkdir -p %{buildroot}/usr/lib/modules-load.d
install -m 644 -D %{SOURCE1} "%{buildroot}/usr/lib/modules-load.d/multipath.conf"
install -m 644 %{SOURCE2} %{buildroot}%{_udevrulesdir}/00-dont-del-part-nodes.rules
install -m 644 -D %{SOURCE3} %{buildroot}/usr/lib/dracut/dracut.conf.d/dm-parts.conf

[ -f /.buildenv ] && exit 0
%service_add_pre multipathd.socket multipathd.service

[ -f /.buildenv ] && exit 0
%service_add_post multipathd.socket multipathd.service
exit 0

%service_del_preun multipathd.service multipathd.socket

%service_del_postun multipathd.service
%service_del_postun -n multipathd.socket


%dir %{_defaultlicensedir}
%license LICENSES/LGPL-2.0
%license LICENSES/LGPL-2.1
%license LICENSES/GPL-2.0
%license README.licenses
%dir /%{_sysdir}/systemd/system
%dir /usr/lib/modules-load.d
%dir /usr/lib/dracut
%dir /usr/lib/dracut/dracut.conf.d


%files devel
%doc libmpathpersist-example.c

%files -n kpartx
%license LICENSES/GPL-2.0
# SLE12-SP1 and earlier: dracut does not own /usr/lib/dracut/dracut.conf.d
%if 0%{?sle_version}
%if 0%{?sle_version} <= 120100
%dir /%{_sysdir}/dracut/dracut.conf.d
%endif # 0%{?sle_version} <= 120100
%endif # 0%{?sle_version}

%posttrans -n kpartx
# The kpartx package contains udev rules that may need to be in initrd.

%if 0%{?with_libdmmp} == 1

%post -n libdmmp%{libdmmp_version} -p %{run_ldconfig}
%postun -n libdmmp%{libdmmp_version} -p %{run_ldconfig}

%files -n libdmmp%{libdmmp_version}
%license LICENSES/GPL-3.0

%files -n libdmmp-devel

%endif # with_libdmmp

openSUSE Build Service is sponsored by