SHA256
1
0
forked from pool/systemd

Accepting request 84925 from home:fcrozat:systemd

- Merge migration rpm macros into service_add/service_del macros.
- Use systemd presets in rpm macros
- Add fix-reload.patch: handle daemon-reload and start condition
  properly (bnc#719221).

OBS-URL: https://build.opensuse.org/request/show/84925
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=198
This commit is contained in:
Frederic Crozat 2011-09-26 15:37:34 +00:00 committed by Git OBS Bridge
parent 80e2def3cb
commit 7ac3b28776
5 changed files with 113 additions and 60 deletions

43
fix-reload.patch Normal file
View File

@ -0,0 +1,43 @@
From a82e5507a6e03766957d43ca8818112ae9766288 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 22 Sep 2011 21:32:18 +0200
Subject: [PATCH] unit: don't recheck conditions when a unit is already starting but unit_start() is invoked
---
src/unit.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/unit.c b/src/unit.c
index 3ce87ea..0b435cb 100644
--- a/src/unit.c
+++ b/src/unit.c
@@ -888,16 +888,20 @@ int unit_start(Unit *u) {
if (u->meta.load_state != UNIT_LOADED)
return -EINVAL;
- /* If this is already (being) started, then this will
- * succeed. Note that this will even succeed if this unit is
- * not startable by the user. This is relied on to detect when
- * we need to wait for units and when waiting is finished. */
+ /* If this is already started, then this will succeed. Note
+ * that this will even succeed if this unit is not startable
+ * by the user. This is relied on to detect when we need to
+ * wait for units and when waiting is finished. */
state = unit_active_state(u);
if (UNIT_IS_ACTIVE_OR_RELOADING(state))
return -EALREADY;
- /* If the conditions failed, don't do anything at all */
- if (!unit_condition_test(u)) {
+ /* If the conditions failed, don't do anything at all. If we
+ * already are activating this call might still be useful to
+ * speed up activation in case there is some hold-off time,
+ * but we don't want to recheck the condition in that case. */
+ if (state != UNIT_ACTIVATING &&
+ !unit_condition_test(u)) {
log_debug("Starting of %s requested but condition failed. Ignoring.", u->meta.id);
return -EALREADY;
}
--
1.7.3.4

View File

@ -7,7 +7,10 @@
# add %systemd_requires in the specfile
#
# %post
# %service_add demo.service demo1.service
# %service_add_pre demo.service demo1.service
#
# %post
# %service_add_post demo.service demo1.service
#
# %preun
# %service_del_preun demo.service
@ -15,64 +18,30 @@
# %postun
# %service_del_postun demo.service
#
#
# when migrating a package from sysvinit to systemd :
# %triggerun -- package_name < version_where_switch_occured
# %service_migrate_to_systemd [ -l run_level ] service_name.service
# foobar.socket
#
# -l <run_level> is optional
###
# This is for /bin/systemctl
%systemd_requires \
Requires(pre): systemd \
Requires(post): systemd \
Requires(preun): systemd \
Requires(postun): systemd \
%systemd_requires \
Requires(pre): systemd \
Requires(post): systemd \
Requires(preun): systemd \
Requires(postun): systemd \
%_unitdir /lib/systemd/system
# On install, tell systemd to reload its unit files
%service_add() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -eq 1 ]; then \
# Initial installation \
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
fi \
%{nil}
# On uninstall, disable and stop services
%service_del_preun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -eq 0 ]; then \
# Package removal, not upgrade \
/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
/bin/systemctl stop %{?*} > /dev/null 2>&1 || : \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files
%service_del_postun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
if [ $FIRST_ARG -ge 1 ]; then \
# Package upgrade, not uninstall \
/bin/systemctl try-restart %{?*} >/dev/null 2>&1 || : \
fi \
%{nil}
%service_migrate_to_systemd_pre() \
%service_add_pre() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
# disable migration if initial install under systemd \
if [ $FIRST_ARG -eq 1 ]; then \
for service in %{?*} ; do \
touch "/var/lib/systemd/migrated/$service" \
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
touch "/var/lib/systemd/migrated/$sysv_service" \
done \
else \
for service in %{?*} ; do \
if [ ! -e "/var/lib/systemd/migrated/$service" ]; then \
services_to_migrate="$services_to_migrate $service" \
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \
services_to_migrate="$services_to_migrate $sysv_service" \
fi \
done \
if [ -n "$services_to_migrate" ]; then \
@ -81,25 +50,45 @@ else \
fi \
%{nil}
%service_migrate_to_systemd_post() \
# On install, tell systemd to reload its unit files
%service_add_post() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
for service in %{?*} ; do \
if [ ! -e "/var/lib/systemd/migrated/$service" ]; then \
services_to_migrate="$services_to_migrate $service" \
touch "/var/lib/systemd/migrated/$service" \
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \
services_to_migrate="$services_to_migrate $sysv_service" \
touch "/var/lib/systemd/migrated/$sysv_service" \
fi \
done \
if [ -n "$services_to_migrate" ]; then \
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate >/dev/null 2>&1 || : \
fi \
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
/bin/systemctl preset %{?*} >/dev/null 2>&1 || : \
%{nil}
# On uninstall, disable and stop services
%service_del_preun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -eq 0 ]; then \
# Package removal, not upgrade \
/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
/bin/systemctl stop %{?*} > /dev/null 2>&1 || : \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files
%service_del_postun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -ge 1 ]; then \
# Package upgrade, not uninstall \
/bin/systemctl try-restart %{?*} >/dev/null 2>&1 || : \
else # package uninstall \
for service in %{?*} ; do \
sysv_service=`echo $service | sed -e 's/\\.[a-z]*//g'` \
rm -f "/var/lib/systemd/migrated/$sysv_service" 2> /dev/null \
done \
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
fi \
%{nil}
%service_migrate_to_systemd_postun() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
if [ $FIRST_ARG -eq 0 ]; then \
for service in %{?*} ; do \
rm -f "/var/lib/systemd/migrated/$service" 2> /dev/null \
done \
fi \
%{nil}

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Sep 26 14:52:46 UTC 2011 - fcrozat@suse.com
- Merge migration rpm macros into service_add/service_del macros.
- Use systemd presets in rpm macros
- Add fix-reload.patch: handle daemon-reload and start condition
properly (bnc#719221).
-------------------------------------------------------------------
Fri Sep 23 15:39:03 UTC 2011 - fcrozat@suse.com

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Sep 26 14:52:46 UTC 2011 - fcrozat@suse.com
- Merge migration rpm macros into service_add/service_del macros.
- Use systemd presets in rpm macros
- Add fix-reload.patch: handle daemon-reload and start condition
properly (bnc#719221).
-------------------------------------------------------------------
Fri Sep 23 15:39:03 UTC 2011 - fcrozat@suse.com

View File

@ -67,6 +67,8 @@ Patch10: revert_insserv_conf_parsing.patch
# in the patch. Any patches added here without a very good reason to make
# an exception will be silently removed with the next version update.
Patch9: 0001-execute-fix-bus-serialization-for-commands.patch
# PATCH-FIX-UPSTREAM fix-reload.patch fcrozat@suse.com bnc#719221 -- Fix daemon-reload and conditions when service is starting
Patch11: fix-reload.patch
%description
Systemd is a system and service manager, compatible with SysV and LSB
@ -121,6 +123,7 @@ Plymouth integration for systemd
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%build
autoreconf -fiv
@ -141,7 +144,7 @@ make %{?_smp_mflags}
mkdir -p %{buildroot}%{_sysconfdir}/rpm
install -m644 %{S:4} %{buildroot}%{_sysconfdir}/rpm
find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
mkdir -p %{buildroot}/{sbin,var/lib/systemd/sysv-convert,var/lib/systemd/migrated}
mkdir -p %{buildroot}/{sbin,var/lib/systemd/sysv-convert,var/lib/systemd/migrated} %{buildroot}/lib/systemd/{system.preset,user.preset}
install -m755 %{S:3} -D %{buildroot}%{_sbindir}/systemd-sysv-convert
install -m755 %{S:5} %{buildroot}/lib/systemd/system-generators
install -m755 %{S:7} %{buildroot}/lib/systemd/
@ -251,6 +254,8 @@ rm -rf %{buildroot}
%{_bindir}/systemd-cgls
/lib/systemd/systemd-*
%dir /lib/systemd/system-shutdown
%dir /lib/systemd/system.preset
%dir /lib/systemd/user.preset
/%{_lib}/security/pam_systemd.so
%dir %{_sysconfdir}/systemd/system
%dir %{_sysconfdir}/systemd/user