File device-mapper.spec of Package device-mapper

#
# spec file for package device-mapper
#
# Copyright (c) 2014 SUSE LINUX Products 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/
#


Name:           device-mapper
# bug437293
%ifarch ppc64
Obsoletes:      device-mapper-64bit
%endif
#
Version:        1.02.78
Release:        0
Summary:        Device Mapper Tools
License:        GPL-2.0+ and LGPL-2.1+
Group:          System/Base
Source:         ftp://sources.redhat.com/pub/lvm2/LVM2.2.02.98.tgz
Source42:       ftp://sources.redhat.com/pub/lvm2/LVM2.2.02.98.tgz.asc
Source50:       thin-provisioning-tools-v0.2.4.tar.gz
Source99:       baselibs.conf
Patch1:         %{name}-dmsetup-export.patch
Patch2:         %{name}-gcc-warnings.patch
Patch3:         %{name}-static.patch
Patch6:         bug-479104_device-mapper-dmsetup-deps-export.patch
Patch10:        device-mapper-link
Patch11:        increase-minor-version.diff
#bnc730837, fixed in upstream
Patch12:        segault_for_truncated_string_token.patch

#sr#140943
#bnc#78902,bnc#789019,bnc#789020
Patch13:        udev-rules_update.diff

#bnc#788882
Patch14:        udev_sync-cookie_set-1-on-each-dm_task_set_cookie-ca.patch

#bnc#862817,upstraem
Patch15:        s390-sectorsize4096.patch

Patch16:        add_integrate_flush_flag.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  boost-devel
BuildRequires:  gcc-c++
BuildRequires:  libexpat-devel
BuildRequires:  libselinux-devel
BuildRequires:  libstdc++-devel
BuildRequires:  suse-module-tools
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(libudev)
Requires:       expat

PreReq:         %insserv_prereq %fillup_prereq

%{systemd_requires}

%description
Programs, libraries, and man pages for configuring and using the device
mapper.



Authors:
--------
    Joe Thornber <thornber@sistina.com>

%package devel
Summary:        Development package for the device mapper
Group:          System/Base
Requires:       %name = %version

%description devel
Files needed for software development using the device mapper



Authors:
--------
    Joe Thornber <thornber@sistina.com>

%prep
%setup -q -n LVM2.2.02.98 -a50
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch6 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1

%build
export CFLAGS="$RPM_OPT_FLAGS"
%configure --bindir=/bin --libdir=/%_lib --sbindir=/sbin --enable-dmeventd \
           --enable-selinux --enable-cmdlib \
           --with-dmeventd-path=/sbin/dmeventd \
           --with-device-uid=0 --with-device-gid=6 --with-device-mode=0640 \
		   --enable-udev_sync --enable-udev_rules --with-udev-prefix=/usr/ \
		   --enable-pkgconfig --enable-realtime --with-thin=internal \
    		--with-thin-check=/sbin/thin_check --with-default-pid-dir=/run \
            --with-default-dm-run-dir=/run --with-default-run-dir=/run/lvm \
            --with-default-locking-dir=/run/lock/lvm

export SUSE_ASNEEDED=0
make -j1 device-mapper # symlinks are generated in parallel! %{?_smp_mflags}
sed s/1.03.01/%{version}/g < VERSION_DM > VERSION_DM.new
mv VERSION_DM.new VERSION_DM
rm -f libdm/ioctl/libdevmapper.so daemons/dmeventd/libdevmapper-event.so
make -j1 device-mapper
pushd thin-provisioning-tools-0.2.4
%configure --sbindir=/sbin --prefix=/usr
make
popd

%install
make install_device-mapper DESTDIR=$RPM_BUILD_ROOT
sed s/%{version}/1.03.01/g < VERSION_DM > VERSION_DM.new
mv VERSION_DM.new VERSION_DM
rm -f libdm/ioctl/libdevmapper.so daemons/dmeventd/libdevmapper-event.so
make -j1 device-mapper
make install_device-mapper DESTDIR=$RPM_BUILD_ROOT
#make libdir=$RPM_BUILD_ROOT/%_libdir install_static_lib
mkdir -p $RPM_BUILD_ROOT/%_libdir
mkdir -p $RPM_BUILD_ROOT/%_libdir/pkgconfig
mkdir -p $RPM_BUILD_ROOT/etc/init.d
#install -m 744 %{SOURCE1} $RPM_BUILD_ROOT/etc/init.d
install -d  $RPM_BUILD_ROOT%{_unitdir}
install -m 0644 scripts/dm_event_systemd_red_hat.socket $RPM_BUILD_ROOT%{_unitdir}/dm-event.socket
install -m 0644 scripts/dm_event_systemd_red_hat.service $RPM_BUILD_ROOT%{_unitdir}/dm-event.service
[ %_libdir != "/usr/lib" ] && mv $RPM_BUILD_ROOT/usr/lib/libdevmapper.so $RPM_BUILD_ROOT/%_libdir/libdevmapper.so
[ %_libdir != "/usr/lib" ] && mv $RPM_BUILD_ROOT/usr/lib/libdevmapper-event.so $RPM_BUILD_ROOT/%_libdir/libdevmapper-event.so
[ %_libdir != "/usr/lib" ] && mv $RPM_BUILD_ROOT/usr/lib/libdevmapper.a $RPM_BUILD_ROOT/%_libdir/libdevmapper.a
[ %_libdir != "/usr/lib" ] && mv $RPM_BUILD_ROOT/usr/lib/pkgconfig/devmapper.pc $RPM_BUILD_ROOT/%_libdir/pkgconfig/devmapper.pc
[ %_libdir != "/usr/lib" ] && mv $RPM_BUILD_ROOT/usr/lib/pkgconfig/devmapper-event.pc $RPM_BUILD_ROOT/%_libdir/pkgconfig/devmapper-event.pc
pushd thin-provisioning-tools-0.2.4
make install DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir}
popd

%post
%service_add_post dm-event.service dm-event.socket
/sbin/ldconfig
%{?regenerate_initrd_post}

%posttrans
%{?regenerate_initrd_posttrans}

%pre
%service_add_pre dm-event.service dm-event.socket

%preun
%service_del_preun dm-event.service dm-event.socket

%postun
%service_del_postun dm-event.service dm-event.socket
/sbin/ldconfig

%files
%defattr(-,root,root)
%doc INSTALL COPYING COPYING.LIB README
%doc udev/12-dm-permissions.rules
/%_lib/libdevmapper.so.1.02
/%_lib/libdevmapper.so.1.03
/%_lib/libdevmapper-event.so.1.02
/%_lib/libdevmapper-event.so.1.03
/sbin/dmsetup
/sbin/dmeventd
/usr/sbin/thin_check
/usr/sbin/thin_dump
/usr/sbin/thin_restore
/usr/sbin/thin_metadata_size
/usr/sbin/thin_repair
/usr/sbin/thin_rmap
%{_mandir}/man8/dmsetup.8.gz
%{_mandir}/man8/dmeventd.8.gz
%{_mandir}/man8/thin_check.8.gz
%{_mandir}/man8/thin_dump.8.gz
%{_mandir}/man8/thin_restore.8.gz
%{_mandir}/man8/thin_metadata_size.8.gz
%{_mandir}/man8/thin_repair.8.gz
%{_mandir}/man8/thin_rmap.8.gz
%{_udevrulesdir}/10-dm.rules
%{_udevrulesdir}/13-dm-disk.rules
%{_udevrulesdir}/95-dm-notify.rules
%{_unitdir}/dm-event.socket
%{_unitdir}/dm-event.service

%files devel
%defattr(-,root,root)
/%_libdir/libdevmapper.so
/%_libdir/libdevmapper-event.so
%attr(644, root, root) %_libdir/libdevmapper.a
/usr/include/libdevmapper.h
/usr/include/libdevmapper-event.h
/%_libdir/pkgconfig/devmapper-event.pc
/%_libdir/pkgconfig/devmapper.pc

%changelog