[lvm2] Convert form SysV init to systemd. Add systemd units and sysvinit subpackage.

Peter Rajnoha prajnoha at fedoraproject.org
Mon Jul 18 12:13:40 UTC 2011


commit 4f75fb47b96af41d871d8e735e60eece1bf92d7f
Author: Peter Rajnoha <prajnoha at redhat.com>
Date:   Mon Jul 18 14:12:30 2011 +0200

    Convert form SysV init to systemd. Add systemd units and sysvinit subpackage.

 lvm2-add-systemd-units.patch         |   63 +++++++++++++++++++++
 lvm2-autoreconf.patch                |   35 ++++++++++++
 lvm2-systemd-conf-make-support.patch |   71 +++++++++++++++++++++++
 lvm2.spec                            |  102 ++++++++++++++++++++++++++++++++--
 4 files changed, 266 insertions(+), 5 deletions(-)
---
diff --git a/lvm2-add-systemd-units.patch b/lvm2-add-systemd-units.patch
new file mode 100644
index 0000000..e2755c7
--- /dev/null
+++ b/lvm2-add-systemd-units.patch
@@ -0,0 +1,63 @@
+ scripts/dm_event_systemd_red_hat.service.in        |   13 +++++++++++++
+ scripts/dm_event_systemd_red_hat.socket            |   10 ++++++++++
+ scripts/lvm2_monitoring_systemd_red_hat.service.in |   17 +++++++++++++++++
+ 3 files changed, 40 insertions(+), 0 deletions(-)
+
+diff --git a/scripts/dm_event_systemd_red_hat.service.in b/scripts/dm_event_systemd_red_hat.service.in
+new file mode 100644
+index 0000000..3e18c69
+--- /dev/null
++++ b/scripts/dm_event_systemd_red_hat.service.in
+@@ -0,0 +1,13 @@
++[Unit]
++Description=Device-mapper event daemon
++After=fedora-storage-init.service fedora-storage-init-late.service
++Before=local-fs.target
++DefaultDependencies=no
++
++[Service]
++Type=forking
++ExecStart=@sbindir@/dmeventd
++PIDFile=@DMEVENTD_PIDFILE@
++
++[Install]
++WantedBy=sysinit.target
+diff --git a/scripts/dm_event_systemd_red_hat.socket b/scripts/dm_event_systemd_red_hat.socket
+new file mode 100644
+index 0000000..45c02dd
+--- /dev/null
++++ b/scripts/dm_event_systemd_red_hat.socket
+@@ -0,0 +1,10 @@
++[Unit]
++Description=Device-mapper event daemon FIFOs
++DefaultDependencies=no
++
++[Socket]
++ListenFIFO=/var/run/dmeventd-server
++ListenFIFO=/var/run/dmeventd-client
++
++[Install]
++WantedBy=sockets.target
+diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
+new file mode 100644
+index 0000000..c284bbb
+--- /dev/null
++++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
+@@ -0,0 +1,17 @@
++[Unit]
++Description=Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling
++Requires=dm-event.socket
++After=fedora-storage-init.service fedora-storage-init-late.service
++Before=local-fs.target
++DefaultDependencies=no
++Conflicts=shutdown.target
++
++[Service]
++Type=oneshot
++ExecStart=@sbindir@/lvm vgchange --monitor y
++ExecStop=@sbindir@/lvm vgchange --monitor n
++RemainAfterExit=yes
++
++[Install]
++WantedBy=sysinit.target
++Also=dm-event.socket
diff --git a/lvm2-autoreconf.patch b/lvm2-autoreconf.patch
new file mode 100644
index 0000000..de460e4
--- /dev/null
+++ b/lvm2-autoreconf.patch
@@ -0,0 +1,35 @@
+ configure |    6 +++++-
+ 1 files changed, 5 insertions(+), 1 deletions(-)
+
+diff --git a/configure b/configure
+index 8e3b243..aac4f26 100755
+--- a/configure
++++ b/configure
+@@ -603,6 +603,7 @@ kernelvsn
+ missingkernel
+ kerneldir
+ interface
++DMEVENTD_PIDFILE
+ WRITE_INSTALL
+ UDEV_SYNC
+ UDEV_RULES
+@@ -10380,8 +10381,9 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
+ 
+ 
+ 
++
+ ################################################################################
+-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
++ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makef
 ile unit-tests/mm/Makefile"
+ 
+ cat >confcache <<\_ACEOF
+ # This file is a shell script that caches the results of configure
+@@ -11102,6 +11104,8 @@ do
+     "scripts/clvmd_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/clvmd_init_red_hat" ;;
+     "scripts/cmirrord_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/cmirrord_init_red_hat" ;;
+     "scripts/lvm2_monitoring_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_init_red_hat" ;;
++    "scripts/dm_event_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.service" ;;
++    "scripts/lvm2_monitoring_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_systemd_red_hat.service" ;;
+     "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
+     "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
+     "test/api/Makefile") CONFIG_FILES="$CONFIG_FILES test/api/Makefile" ;;
diff --git a/lvm2-systemd-conf-make-support.patch b/lvm2-systemd-conf-make-support.patch
new file mode 100644
index 0000000..7ed1fbf
--- /dev/null
+++ b/lvm2-systemd-conf-make-support.patch
@@ -0,0 +1,71 @@
+ Makefile.in         |    3 +++
+ WHATS_NEW           |    1 +
+ configure.in        |    3 +++
+ make.tmpl.in        |    1 +
+ scripts/Makefile.in |    9 ++++++++-
+ 5 files changed, 16 insertions(+), 1 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index f7e34f4..38c41a3 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -92,6 +92,9 @@ install_system_dirs:
+ install_initscripts: 
+ 	$(MAKE) -C scripts install_initscripts
+ 
++install_systemd_units:
++	$(MAKE) -C scripts install_systemd_units
++
+ LCOV_TRACES = libdm.info lib.info tools.info \
+ 	daemons/dmeventd.info daemons/clvmd.info
+ CLEAN_TARGETS += $(LCOV_TRACES)
+diff --git a/configure.in b/configure.in
+index 60796ad..d54d7d8 100644
+--- a/configure.in
++++ b/configure.in
+@@ -1371,6 +1371,7 @@ AC_SUBST(UDEV_PC)
+ AC_SUBST(UDEV_RULES)
+ AC_SUBST(UDEV_SYNC)
+ AC_SUBST(WRITE_INSTALL)
++AC_SUBST(DMEVENTD_PIDFILE)
+ AC_SUBST(interface)
+ AC_SUBST(kerneldir)
+ AC_SUBST(missingkernel)
+@@ -1417,6 +1418,8 @@ po/Makefile
+ scripts/clvmd_init_red_hat
+ scripts/cmirrord_init_red_hat
+ scripts/lvm2_monitoring_init_red_hat
++scripts/dm_event_systemd_red_hat.service
++scripts/lvm2_monitoring_systemd_red_hat.service
+ scripts/Makefile
+ test/Makefile
+ test/api/Makefile
+diff --git a/make.tmpl.in b/make.tmpl.in
+index cd8ae35..f003149 100644
+--- a/make.tmpl.in
++++ b/make.tmpl.in
+@@ -65,6 +65,7 @@ staticdir = $(DESTDIR)@STATICDIR@
+ udevdir = $(DESTDIR)@udevdir@
+ pkgconfigdir = $(usrlibdir)/pkgconfig
+ initdir = $(DESTDIR)@sysconfdir@/rc.d/init.d
++systemd_dir = $(DESTDIR)/lib/systemd/system
+ ocf_scriptdir = $(DESTDIR)@OCFDIR@
+ 
+ USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \
+diff --git a/scripts/Makefile.in b/scripts/Makefile.in
+index 5293cc3..7262fbb 100644
+--- a/scripts/Makefile.in
++++ b/scripts/Makefile.in
+@@ -53,4 +53,11 @@ ifeq ("@BUILD_CMIRRORD@", "yes")
+ 	$(INSTALL_SCRIPT) cmirrord_init_red_hat $(initdir)/cmirrord
+ endif
+ 
+-DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat lvm2_monitoring_init_red_hat
++install_systemd_units:
++	$(INSTALL_DIR) $(systemd_dir)
++	$(INSTALL_DATA) dm_event_systemd_red_hat.socket $(systemd_dir)/dm-event.socket
++	$(INSTALL_DATA) dm_event_systemd_red_hat.service $(systemd_dir)/dm-event.service
++	$(INSTALL_DATA) lvm2_monitoring_systemd_red_hat.service $(systemd_dir)/lvm2-monitor.service
++
++DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat lvm2_monitoring_init_red_hat \
++		     dm_event_systemd_red_hat.service lvm2_monitoring_systemd_red_hat.service
diff --git a/lvm2.spec b/lvm2.spec
index f47dd20..c2cdcef 100644
--- a/lvm2.spec
+++ b/lvm2.spec
@@ -39,7 +39,7 @@
 Summary: Userland logical volume management tools 
 Name: lvm2
 Version: 2.02.86
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv2
 Group: System Environment/Base
 URL: http://sources.redhat.com/lvm2
@@ -48,6 +48,9 @@ Source0: ftp://sources.redhat.com/pub/lvm2/LVM2.%{version}.tgz
 Source1: %{name}-tmpfiles.conf
 %endif
 Patch0: lvm2-set-default-preferred_names.patch
+Patch1: lvm2-add-systemd-units.patch
+Patch2: lvm2-systemd-conf-make-support.patch
+Patch3: lvm2-autoreconf.patch
 
 BuildRequires: libselinux-devel >= 1.30.19-4, libsepol-devel
 BuildRequires: ncurses-devel
@@ -62,13 +65,19 @@ BuildRequires: pkgconfig
 %if %{enable_udev}
 BuildRequires: libudev-devel
 %endif
-Requires: %{name}-libs = %{version}-%{release}
 %if %{enable_systemd}
-Requires: initscripts
+BuildRequires: systemd-units
 %endif
-Requires: module-init-tools
+Requires: %{name}-libs = %{version}-%{release}
+%if %{enable_systemd}
+Requires(post): systemd-units systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else
 Requires(post): chkconfig
 Requires(preun): chkconfig
+%endif
+Requires: module-init-tools
 
 %description
 LVM2 includes all of the support for handling read/write operations on
@@ -81,6 +90,9 @@ or more physical volumes and creating one or more logical volumes
 %prep
 %setup -q -n LVM2.%{version}
 %patch0 -p1 -b preferred_names
+%patch1 -p1 -b .systemd_units
+%patch2 -p1 -b .systemd_conf_make
+%patch3 -p1 -b .autoreconf
 
 %build
 %define _exec_prefix ""
@@ -103,6 +115,7 @@ make install DESTDIR=$RPM_BUILD_ROOT
 make install_system_dirs DESTDIR=$RPM_BUILD_ROOT
 make install_initscripts DESTDIR=$RPM_BUILD_ROOT
 %if %{enable_systemd}
+make install_systemd_units DESTDIR=$RPM_BUILD_ROOT
 mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
 install -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
 %endif
@@ -112,12 +125,38 @@ rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/ldconfig
+%if %{enable_systemd}
+/bin/systemctl daemon-reload > /dev/null 2>&1 || :
+/bin/systemctl enable lvm2-monitor.service > /dev/null 2>&1 || :
+%else
 /sbin/chkconfig --add lvm2-monitor
+%endif
 
 %preun
+%if %{enable_systemd}
+if [ "$1" = 0 ]; then
+	/bin/systemctl --no-reload disable lvm2-monitor.service > /dev/null 2>&1 || :
+	/bin/systemctl stop lvm2-monitor.service > /dev/null 2>&1 || :
+fi
+%else
 if [ "$1" = 0 ]; then
 	/sbin/chkconfig --del lvm2-monitor
 fi
+%endif
+
+%postun
+%if %{enable_systemd}
+/bin/systemctl daemon-reload > /dev/null 2>&1 || :
+if [ $1 -ge 1 ]; then
+	/bin/systemctl try-restart lvm2-monitor.service > /dev/null 2>&1 || :
+fi
+%endif
+
+%triggerun -- %{name} < 2.02.86-2
+%{_bindir}/systemd-sysv-convert --save lvm2-monitor >/dev/null 2>&1 || :
+/bin/systemctl --no-reload enable lvm2-monitor.service > /dev/null 2>&1 || :
+/sbin/chkconfig --del lvm2-monitor > /dev/null 2>&1 || :
+/bin/systemctl try-restart lvm2-monitor.service > /dev/null 2>&1 || :
 
 %files
 %defattr(-,root,root,-)
@@ -229,9 +268,11 @@ fi
 %dir %{_sysconfdir}/lvm/archive
 %dir %{_localstatedir}/lock/lvm
 %dir %{_localstatedir}/run/lvm
-%{_sysconfdir}/rc.d/init.d/lvm2-monitor
 %if %{enable_systemd}
 %config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
+%{_unitdir}/lvm2-monitor.service
+%else
+%{_sysconfdir}/rc.d/init.d/lvm2-monitor
 %endif
 
 ##############################################################################
@@ -440,15 +481,46 @@ Version: %{device_mapper_version}
 Release: %{release}
 Requires: device-mapper = %{device_mapper_version}-%{release}
 Requires: device-mapper-event-libs = %{device_mapper_version}-%{release}
+%if %{enable_systemd}
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%endif
 
 %description -n device-mapper-event
 This package contains the dmeventd daemon for monitoring the state
 of device-mapper devices.
 
+%post -n device-mapper-event
+%if %{enable_systemd}
+/bin/systemctl daemon-reload > /dev/null 2>&1 || :
+/bin/systemctl enable dm-event.socket > /dev/null 2>&1 || :
+%endif
+
+%preun -n device-mapper-event
+%if %{enable_systemd}
+if [ "$1" = 0 ]; then
+	/bin/systemctl --no-reload disable dm-event.service dm-event.socket > /dev/null 2>&1 || :
+	/bin/systemctl stop dm-event.service dm-event.socket> /dev/null 2>&1 || :
+fi
+%endif
+
+%postun -n device-mapper-event
+%if %{enable_systemd}
+/bin/systemctl daemon-reload > /dev/null 2>&1 || :
+if [ $1 -ge 1 ]; then
+	/bin/systemctl try-restart dm-event.service > /dev/null 2>&1 || :
+fi
+%endif
+
 %files -n device-mapper-event
 %defattr(-,root,root,-)
 %{_sbindir}/dmeventd
 %{_mandir}/man8/dmeventd.8.gz
+%if %{enable_systemd}
+%{_unitdir}/dm-event.socket
+%{_unitdir}/dm-event.service
+%endif
 #%ghost %{_localstatedir}/run/dmeventd.pid
 
 %package -n device-mapper-event-libs
@@ -491,7 +563,27 @@ the device-mapper event library.
 /usr%{_libdir}/pkgconfig/devmapper-event.pc
 
 
+%if %{enable_systemd}
+# Legacy SysV init script
+%package sysvinit
+Summary: SysV style init script for LVM2.
+Group: System Environment/Base
+Requires: %{name} = %{version-release}
+Requires: initscripts
+
+%description sysvinit
+SysV style init script for LVM2. It needs to be installed only if systemd
+is not used as the system init process.
+
+%files sysvinit
+%{_sysconfdir}/rc.d/init.d/lvm2-monitor
+%endif
+
 %changelog
+* Mon Jul 18 2011 Peter Rajnoha <prajnoha at redhat.com> - 2.02.86-2
+- Add dm-event and lvm2-monitor unit files for use with systemd.
+- Add sysvinit subpackage for legacy SysV init script support.
+
 * Wed Jul 8 2011 Alasdair Kergon <agk at redhat.com> - 2.02.86-1
 - Fix activation sequences to avoid trapped I/O with multiple LVs.
 - Fix activation sequences to avoid allocating tables while devs suspended.


More information about the scm-commits mailing list