File lvm2.spec of Package lvm2.14089

#
# spec file for package lvm2
#
# Copyright (c) 2020 SUSE LLC
#
# 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/
#


%define _unpackaged_files_terminate_build 0
%define _udevdir %(pkg-config --variable=udevdir udev)
%define enable_testsuite 1

%define lvm2_version              2.02.180
%define device_mapper_version     1.02.149
%define thin_provisioning_version 0.7.6

Name:           lvm2
Version:        %{lvm2_version}
Release:        0
Summary:        Logical Volume Manager Tools
License:        GPL-2.0-or-later AND LGPL-2.1-or-later AND GPL-3.0-or-later
Group:          System/Base
URL:            http://www.sourceware.org/lvm2/
Source:         ftp://sources.redhat.com/pub/%{name}/LVM2.%{version}.tgz
Source42:       ftp://sources.redhat.com/pub/%{name}/LVM2.%{version}.tgz.asc
Source1:        lvm.conf
Source8:        clvmd.ocf
Source10:       cmirrord.ocf
Source14:       baselibs.conf
Source50:       thin-provisioning-tools-v%{thin_provisioning_version}.tar.gz

BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gcc-c++
BuildRequires:  libaio-devel
BuildRequires:  libcorosync-devel
BuildRequires:  libselinux-devel
# To detect modprobe during build
BuildRequires:  kmod-compat
BuildRequires:  readline-devel
Requires(pre):  systemd-presets-branding
Requires(post): systemd-presets-branding
BuildRequires:  libblkid-devel
BuildRequires:  suse-module-tools
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(udev)
Requires:       device-mapper >= %{device_mapper_version}
Provides:       lvm = %version-%release
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if %{defined systemd_requires}
%{systemd_requires}
%endif

# Upstream patches
Patch0004:      bug-1114113_metadata-prevent-writing-beyond-metadata-area.patch
Patch0008:      bug-1122666_devices-drop-open-error-message.patch
Patch0009:      bug-1137296_pvremove-vgextend-fix-using-device-aliases-with-lvmetad.patch
Patch0010:      bug-1135984_cache-support-no_discard_passdown.patch
Patch0012:      bug-1155668_systemd-add-missing-Before-shutdown.target-to-LVM2.patch
Patch0013:      bug-1150021_01-fix-dev_unset_last_byte-after-write-error.patch

# SUSE patches: 1000+ for LVM
# Never upstream
Patch1001:      cmirrord_remove_date_time_from_compilation.patch
Patch1002:      fate-309425_display-dm-name-for-lv-name.patch
Patch1003:      fate-31841_fsadm-add-support-for-btrfs.patch
Patch1004:      bug-935623_dmeventd-fix-dso-name-wrong-compare.patch
Patch1005:      bsc1080299-detect-clvm-properly.patch
Patch1006:      bug-978055_clvmd-try-to-refresh-device-cache-on-the-first-failu.patch
Patch1007:      bug-998893_make_pvscan_service_after_multipathd.patch
Patch1008:      bug-1123327_pvscan.service.in-Move-StartLimitIn.patch
Patch1009:      bug-1150021_02-suse-special-bcache-bug-fix.patch

#SUSE patches 2000+ for device mapper, udev rules
Patch2001:      bug-1012973_simplify-special-case-for-md-in-69-dm-lvm-metadata.patch

# 3000+ for test code
Patch3001:      bug-950089_test-fix-lvm2-testsuite-build-error.patch
Patch3002:      bug-1043040_test-fix-read-ahead-issues-in-test-scripts.patch
Patch3003:      bug-1072624_test-lvmetad_dump-always-timed-out-when-using-nc.patch
Patch3004:      tests-specify-python3-as-the-script-interpreter.patch

# patches specif for lvm2.spec
Patch4001:      bug-1037309_Makefile-skip-compliling-daemons-lvmlockd-directory.patch

%description
Programs and man pages for configuring and using the LVM2 Logical
Volume Manager.

%prep
%setup -q -n LVM2.%{version} -a 50

%patch0004 -p1
%patch0008 -p1
%patch0009 -p1
%patch0010 -p1
%patch0012 -p1
%patch0013 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
%patch1006 -p1
%patch1007 -p1
%patch1008 -p1
%patch1009 -p1

%patch2001 -p1

%patch3001 -p1
%patch3002 -p1
%patch3003 -p1
%patch3004 -p1
%patch4001 -p1

%build
#set path so that thin_check can be found
#export before configure due to bnc#779965
export MODPROBE_CMD=/sbin/modprobe 
export CFLAGS="$RPM_OPT_FLAGS"
export PATH=$PATH:/sbin:/usr/sbin
sed -ie "s/%{device_mapper_version}/1.03.01/g" VERSION_DM
%configure \
	--prefix=/ \
	--libdir=/%_lib \
	--with-usrlibdir=%_libdir \
	--with-usrsbindir=%_sbindir \
	--sbindir=/sbin \
	--enable-dmeventd \
	--enable-udev_sync \
	--enable-udev_rules \
	--enable-cmdlib \
	--enable-applib \
	--enable-dmeventd \
	--enable-realtime \
	--enable-pkgconfig \
	--enable-selinux \
	--with-clvmd=corosync \
	--with-cluster=internal \
	--datarootdir="%_datadir" \
	--with-default-locking-dir=/run/lock/lvm \
	--enable-cmirrord \
	--enable-lvmetad \
	--with-default-pid-dir=/run \
	--with-default-dm-run-dir=/run \
	--with-default-run-dir=/run/lvm \
	--with-tmpfilesdir=%{_tmpfilesdir} \
	--with-thin=internal \
	--with-device-gid=6 \
	--with-device-mode=0640 \
	--with-device-uid=0 \
	--with-dmeventd-path=/sbin/dmeventd \
	--with-thin-check=%{_sbindir}/thin_check \
	--with-thin-dump=%{_sbindir}/thin_dump \
	--with-thin-repair=%{_sbindir}/thin_repair \
	--with-udev-prefix="%_prefix/" \
	--enable-blkid-wiping \
	--enable-lvmpolld

export SUSE_ASNEEDED=0

make %{?_smp_mflags}

pushd thin-provisioning-tools-%{thin_provisioning_version}
autoreconf -fiv
%configure --sbindir=/sbin --prefix="%_prefix"
make %{?_smp_mflags}
popd

%install
%make_install
make install_system_dirs DESTDIR="%buildroot"
make install_systemd_units DESTDIR="%buildroot"
make install_systemd_generators DESTDIR="%buildroot"
make install_tmpfiles_configuration DESTDIR="%buildroot"
# Install configuration file
install -m 644 %{SOURCE1} "%buildroot/%_sysconfdir/lvm/"
# Install testsuite
%if %{enable_testsuite}
make -C test install DESTDIR="%buildroot"
%endif
# Is this directory used anymore?
install -d -m 755 "%buildroot/%_sysconfdir/lvm/metadata"
mkdir -p "%buildroot/%_initddir"
mkdir -p "%buildroot/%_sbindir"
install -m755 -D %{S:8} "%buildroot/%_prefix/lib/ocf/resource.d/lvm2/clvmd"
install -m755 -D %{S:10} "%buildroot/%_prefix/lib/ocf/resource.d/lvm2/cmirrord"

# Make sure libdevmapper.so.1.02 libdevmapper-event.so.1.02 still available
# on Tumbleweed, as virtualbox.org didn't update their RPMs yet.
rm -f libdm/ioctl/libdevmapper.so daemons/dmeventd/libdevmapper-event.so
sed -i "s/1.03.01/%{device_mapper_version}/" VERSION_DM
make device-mapper
make install_device-mapper DESTDIR=%{buildroot}

pushd "%buildroot/%_lib"
ln -sf liblvm2cmd.so.2.02 liblvm2cmd.so
ln -sf liblvm2app.so.2.2 liblvm2app.so
for i in libdevmapper-event-lvm2{mirror,raid,snapshot,thin}; do
	ln -sf "device-mapper/$i.so" "$i.so"
	ln -sf "device-mapper/$i.so" "$i.so.2.02"
done
popd

pushd "%buildroot/%_sbindir"
ln -sf ../../sbin/lvm lvm
ln -sf ../../sbin/lvmconf lvmconf
popd

pushd "%buildroot/sbin"
ln -sf ../usr/sbin/clvmd clvmd
ln -sf ../usr/sbin/cmirrord cmirrord
popd

pushd thin-provisioning-tools-%{thin_provisioning_version}
%make_install
popd

# Remove some files which will not be packed
rm %{buildroot}%{_unitdir}/lvm2-lvmlockd.service
rm %{buildroot}%{_unitdir}/lvm2-lvmlocking.service
rm %{buildroot}%{_mandir}/man8/lvmlockctl.8
rm %{buildroot}%{_mandir}/man8/lvmlockd.8

%pre
%service_add_pre blk-availability.service lvm2-monitor.service lvm2-lvmetad.socket lvm2-lvmetad.service lvm2-lvmpolld.socket lvm2-lvmpolld.service

%post
/sbin/ldconfig
%{?regenerate_initrd_post}
%service_add_post blk-availability.service lvm2-monitor.service lvm2-lvmetad.socket lvm2-lvmetad.service lvm2-lvmpolld.socket lvm2-lvmpolld.service
# Use %%tmpfiles_create when 13.2 is oldest in support scope
%{_bindir}/systemd-tmpfiles --create %{_tmpfilesdir}/lvm2.conf || :

%posttrans
%{?regenerate_initrd_posttrans}

%preun
%service_del_preun blk-availability.service lvm2-monitor.service lvm2-lvmetad.service lvm2-lvmetad.socket lvm2-lvmpolld.service lvm2-lvmpolld.socket

%postun
/sbin/ldconfig
%{?regenerate_initrd_post}
%service_del_postun blk-availability.service lvm2-monitor.service lvm2-lvmetad.service lvm2-lvmetad.socket lvm2-lvmpolld.service lvm2-lvmpolld.socket

%files
%defattr(-,root,root)
%doc README VERSION WHATS_NEW
%doc doc/lvm_fault_handling.txt
%dir %{_sysconfdir}/lvm
%dir %{_sysconfdir}/lvm/backup
%dir %{_sysconfdir}/lvm/archive
%dir %{_sysconfdir}/lvm/metadata
%dir %{_sysconfdir}/lvm/profile
%dir %{_sysconfdir}/lvm/cache
%dir /usr/lib/systemd/system-generators
%dir /usr/lib/tmpfiles.d
%ghost %{_sysconfdir}/lvm/cache/.cache
%{_sysconfdir}/lvm/profile/*.profile
%{_sysconfdir}/lvm/lvmlocal.conf
%{_udevdir}/rules.d/11-dm-lvm.rules
%{_udevdir}/rules.d/69-dm-lvm-metad.rules
%{_unitdir}/blk-availability.service
%{_unitdir}/lvm2-monitor.service
%{_unitdir}/lvm2-lvmetad.socket
%{_unitdir}/lvm2-lvmetad.service
%{_unitdir}/lvm2-pvscan@.service
%{_unitdir}/lvm2-lvmpolld.socket
%{_unitdir}/lvm2-lvmpolld.service
%{_tmpfilesdir}/lvm2.conf
%config(noreplace) %{_sysconfdir}/lvm/lvm.conf
/usr/lib/systemd/system-generators/lvm2-activation-generator
/sbin/blkdeactivate
/sbin/fsadm
/sbin/lv*
/sbin/pv*
/sbin/vg*
%_sbindir/lvm
%_sbindir/lvmconf
%dir /%_lib/device-mapper
/%_lib/device-mapper/libdevmapper-event-lvm2*.so
/%_lib/libdevmapper-event-lvm2*.so
/%_lib/liblvm2cmd.so
/%_lib/liblvm2cmd.so.2.02
/%_lib/liblvm2app.so
/%_lib/liblvm2app.so.2.2
/%_libdir/liblvm2app.so
/%_libdir/liblvm2cmd.so
/%_lib/libdevmapper-event-lvm2*.so.2.02
/%_libdir/libdevmapper-event-lvm2.so
%{_mandir}/man5/lvm.conf.5%{ext_man}
%{_mandir}/man7/lvmcache.7%{ext_man}
%{_mandir}/man7/lvmraid.7%{ext_man}
%{_mandir}/man7/lvmreport.7%{ext_man}
%{_mandir}/man7/lvmthin.7%{ext_man}
%{_mandir}/man7/lvmsystemid.7%{ext_man}
%{_mandir}/man8/fsadm.8%{ext_man}
%{_mandir}/man8/lvchange.8%{ext_man}
%{_mandir}/man8/lvconvert.8%{ext_man}
%{_mandir}/man8/lvcreate.8%{ext_man}
%{_mandir}/man8/lvdisplay.8%{ext_man}
%{_mandir}/man8/lvextend.8%{ext_man}
%{_mandir}/man8/lvm.8%{ext_man}
%{_mandir}/man8/lvm2-activation-generator.8%{ext_man}
%{_mandir}/man8/lvm-config.8%{ext_man}
%{_mandir}/man8/lvmconfig.8%{ext_man}
%{_mandir}/man8/lvm-dumpconfig.8%{ext_man}
%{_mandir}/man8/lvmconf.8%{ext_man}
%{_mandir}/man8/lvmdiskscan.8%{ext_man}
%{_mandir}/man8/lvmdump.8%{ext_man}
%{_mandir}/man8/lvm-fullreport.8%{ext_man}
%{_mandir}/man8/lvmsadc.8%{ext_man}
%{_mandir}/man8/lvmsar.8%{ext_man}
%{_mandir}/man8/lvreduce.8%{ext_man}
%{_mandir}/man8/lvremove.8%{ext_man}
%{_mandir}/man8/lvrename.8%{ext_man}
%{_mandir}/man8/lvresize.8%{ext_man}
%{_mandir}/man8/lvs.8%{ext_man}
%{_mandir}/man8/lvscan.8%{ext_man}
%{_mandir}/man8/pvchange.8%{ext_man}
%{_mandir}/man8/pvck.8%{ext_man}
%{_mandir}/man8/pvcreate.8%{ext_man}
%{_mandir}/man8/pvdisplay.8%{ext_man}
%{_mandir}/man8/pvmove.8%{ext_man}
%{_mandir}/man8/pvremove.8%{ext_man}
%{_mandir}/man8/pvresize.8%{ext_man}
%{_mandir}/man8/pvs.8%{ext_man}
%{_mandir}/man8/pvscan.8%{ext_man}
%{_mandir}/man8/vgcfgbackup.8%{ext_man}
%{_mandir}/man8/vgcfgrestore.8%{ext_man}
%{_mandir}/man8/vgchange.8%{ext_man}
%{_mandir}/man8/vgck.8%{ext_man}
%{_mandir}/man8/vgconvert.8%{ext_man}
%{_mandir}/man8/vgcreate.8%{ext_man}
%{_mandir}/man8/vgdisplay.8%{ext_man}
%{_mandir}/man8/vgexport.8%{ext_man}
%{_mandir}/man8/vgextend.8%{ext_man}
%{_mandir}/man8/vgimport.8%{ext_man}
%{_mandir}/man8/vgimportclone.8%{ext_man}
%{_mandir}/man8/vgmerge.8%{ext_man}
%{_mandir}/man8/vgmknodes.8%{ext_man}
%{_mandir}/man8/vgreduce.8%{ext_man}
%{_mandir}/man8/vgremove.8%{ext_man}
%{_mandir}/man8/vgrename.8%{ext_man}
%{_mandir}/man8/vgs.8%{ext_man}
%{_mandir}/man8/vgscan.8%{ext_man}
%{_mandir}/man8/vgsplit.8%{ext_man}
%{_mandir}/man8/lvmetad.8%{ext_man}
%{_mandir}/man8/blkdeactivate.8%{ext_man}
%{_mandir}/man8/lvmpolld.8%{ext_man}
%{_mandir}/man8/lvm-lvpoll.8%{ext_man}

%package clvm
URL:            http://sources.redhat.com/cluster/clvm/
Version:        %{lvm2_version}
Release:        0
BuildRequires:  kmod-compat
BuildRequires:  libaio-devel
BuildRequires:  libcorosync-devel
BuildRequires:  libdlm-devel
Requires:       corosync
Requires:       device-mapper >= %{device_mapper_version}
Requires:       lvm2 = %{version}
Requires:       lvm2-cmirrord
Obsoletes:      cmirrord < %{version}
Provides:       cmirrord = %{version}
Summary:        Clustered LVM2
Group:          Productivity/Clustering/HA

%description clvm
A daemon for using LVM2 Logival Volumes in a clustered environment.

%files clvm
%defattr(-,root,root)
%{_sbindir}/clvmd
/sbin/clvmd
%dir /usr/lib/ocf
%dir /usr/lib/ocf/resource.d
%dir /usr/lib/ocf/resource.d/lvm2
/usr/lib/ocf/resource.d/lvm2/clvmd
%{_unitdir}/lvm2-clvmd.service
%{_unitdir}/lvm2-cluster-activation.service
/usr/lib/systemd/lvm2-cluster-activation
%{_mandir}/man8/clvmd.8.gz

%package cmirrord
URL:            http://www.sourceware.org/lvm2/
Version:        %{lvm2_version}
Release:        0
Requires:       corosync
Requires:       device-mapper >= %{device_mapper_version}
Requires:       lvm2 = %{version}
Requires:       lvm2-clvm
Summary:        Clustered RAID 1 support using device-mapper and corosync
Group:          Productivity/Clustering/HA

%description cmirrord
A daemon for using LVM2 Logival Volumes in a clustered environment.

%files cmirrord
%defattr(-,root,root)
%{_sbindir}/cmirrord
/sbin/cmirrord
/usr/lib/ocf/resource.d/lvm2/cmirrord
/usr/lib/systemd/system/lvm2-cmirrord.service
%{_mandir}/man8/cmirrord.8.gz

%package devel
Version:        %{lvm2_version}
Release:        0
Requires:       lvm2 = %{version}
Summary:        Development files for LVM2
Group:          Development/Libraries/C and C++

%description devel
This package provides development files for the LVM2 Logical Volume Manager.


%files devel
%defattr(-,root,root)
%_includedir/lvm2cmd.h
%_includedir/lvm2app.h
%_libdir/pkgconfig/lvm2app.pc

##########################################
# Subpackage: device-mapper
##########################################
%package -n device-mapper

%ifarch ppc64
Obsoletes:      device-mapper-64bit
%endif
Version:        %{device_mapper_version}
Release:        0
Summary:        Device Mapper Tools
Group:          System/Base
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  boost-devel
BuildRequires:  gcc-c++
BuildRequires:  kmod-compat
BuildRequires:  libaio-devel
BuildRequires:  libexpat-devel
BuildRequires:  libselinux-devel
BuildRequires:  libsepol-devel
BuildRequires:  libstdc++-devel
BuildRequires:  suse-module-tools
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(libudev)
Requires:       expat

%if %{defined systemd_requires}
%{systemd_requires}
%endif

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

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

%posttrans -n device-mapper
%{?regenerate_initrd_posttrans}

%pre -n device-mapper
%service_add_pre dm-event.service dm-event.socket

%preun -n device-mapper
%service_del_preun dm-event.service dm-event.socket

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

%files -n device-mapper
%defattr(-,root,root)
%doc INSTALL COPYING COPYING.LIB README
%doc udev/12-dm-permissions.rules
/%_lib/libdevmapper.so.1.03
/%_lib/libdevmapper-event.so.1.03
/%_lib/libdevmapper.so.1.02
/%_lib/libdevmapper-event.so.1.02
/sbin/dmsetup
/sbin/dmeventd
/sbin/dmstats
%_sbindir/thin_*
%_mandir/man8/dmsetup.8.gz
%_mandir/man8/dmeventd.8.gz
%_mandir/man8/dmstats.8.gz
%_mandir/man8/thin_*.8*
%_udevrulesdir/10-dm.rules
%_udevrulesdir/13-dm-disk.rules
%_udevrulesdir/95-dm-notify.rules
%_unitdir/dm-event.socket
%_unitdir/dm-event.service
%_sbindir/cache_*
%_sbindir/era_*
%_sbindir/pdata_tools
%_mandir/man8/cache_*.8*
%_mandir/man8/era_*.8*

%package -n device-mapper-devel
Summary:        Development package for the device mapper
Group:          Development/Libraries/C and C++
Version:        %{device_mapper_version}
Release:        0
Requires:       device-mapper = %{device_mapper_version}

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

%files -n device-mapper-devel
%defattr(-,root,root)
%_libdir/libdevmapper.so
%_libdir/libdevmapper-event.so
%_includedir/libdevmapper*.h
%_libdir/pkgconfig/devmapper*.pc

%if %{enable_testsuite}
%package testsuite
Version:        %{lvm2_version}
Release:        0
Summary:        LVM2 Testsuite
Group:          Development
Requires:       lvm2 = %{version}

%description testsuite
An extensive functional testsuite for the LVM2 Logical Volume Manager.

%files testsuite
%defattr(-,root,root)
%{_datarootdir}/lvm2-testsuite/
%{_libexecdir}/lvm2-testsuite/
%{_bindir}/lvm2-testsuite
%endif

%changelog
openSUSE Build Service is sponsored by