Stephan Kulow 2015-07-21 11:24:38 +00:00 committed by Git OBS Bridge
commit 779e2cbd00
3 changed files with 109 additions and 81 deletions

View File

@ -41,157 +41,178 @@ Requires(postun): systemd \
%_binfmtdir /usr/lib/binfmt.d
%service_add_pre() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
# disable migration if initial install under systemd \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
if [ $FIRST_ARG -eq 1 ]; then \
for service in %{?*} ; do \
sysv_service=${service%.*} \
touch "/var/lib/systemd/migrated/$sysv_service" || : \
done \
if [ "$FIRST_ARG" -eq 1 ]; then \
for service in %{?*} ; do \
sysv_service="${service%.*}" \
touch "/var/lib/systemd/migrated/$sysv_service" || : \
done \
else \
if [ $FIRST_ARG -gt 1 ]; then \
for service in %{?*} ; do \
if [ ! -e "/usr/lib/systemd/system/$service" ]; then \
touch "/run/rpm-%{name}-update-$service-new-in-upgrade" \
fi \
done \
fi \
for service in %{?*} ; do \
sysv_service=${service%.*} \
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 \
/usr/sbin/systemd-sysv-convert --save $services_to_migrate >/dev/null 2>&1 || : \
fi \
if [ "$FIRST_ARG" -gt 1 ]; then \
for service in %{?*} ; do \
if [ ! -e "/usr/lib/systemd/system/$service" ]; then \
touch "/run/rpm-%{name}-update-$service-new-in-upgrade" \
fi \
done \
fi \
for service in %{?*} ; do \
sysv_service="${service%.*}" \
if [ ! -e "/var/lib/systemd/migrated/$sysv_service" ]; then \
services_to_migrate="$services_to_migrate $sysv_service" \
fi \
done \
if [ -n "$services_to_migrate" -a -x /usr/sbin/systemd-sysv-convert ]; then \
/usr/sbin/systemd-sysv-convert --save $services_to_migrate || : \
fi \
fi \
%{nil}
# On install, tell systemd to reload its unit files
%service_add_post() \
test -n "$FIRST_ARG" || FIRST_ARG=$1 \
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
for service in %{?*} ; do \
sysv_service=${service%.*} \
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 \
sysv_service="${service%.*}" \
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 \
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
if [ -n "$services_to_migrate" ]; then \
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate >/dev/null 2>&1 || : \
elif [ $FIRST_ARG -eq 1 ]; then \
/usr/bin/systemctl preset %{?*} >/dev/null 2>&1 || : \
elif [ $FIRST_ARG -gt 1 ]; then \
for service in %{?*} ; do \
if [ -e "/run/rpm-%{name}-update-$service-new-in-upgrade" ]; then \
rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \
/usr/bin/systemctl preset "$service" >/dev/null 2>&1 || : \
fi \
done \
if [ -x /usr/sbin/systemd-sysv-convert ]; then \
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate || : \
fi \
elif [ "$FIRST_ARG" -eq 1 ]; then \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl preset %{?*} || : \
fi \
elif [ "$FIRST_ARG" -gt 1 ]; then \
for service in %{?*} ; do \
if [ ! -e "/run/rpm-%{name}-update-$service-new-in-upgrade" ]; then \
continue \
fi \
rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \
if [ ! -x /usr/bin/systemctl ]; then \
continue \
fi \
/usr/bin/systemctl preset "$service" || : \
done \
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 \
/usr/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
/usr/bin/systemctl stop %{?*} > /dev/null 2>&1 || : \
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
if [ "$FIRST_ARG" -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} || : \
/usr/bin/systemctl stop %{?*} || : \
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 \
if test "$YAST_IS_RUNNING" != "instsys" -a "$DISABLE_RESTART_ON_UPDATE" != yes ; then \
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
/usr/bin/systemctl try-restart %{?*} >/dev/null 2>&1 || : \
fi \
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
if [ "$FIRST_ARG" -ge 1 ]; then \
# Package upgrade, not uninstall \
if test "$YAST_IS_RUNNING" != "instsys" && \
test "$DISABLE_RESTART_ON_UPDATE" != yes -a -x /usr/bin/systemctl; then \
/usr/bin/systemctl daemon-reload || : \
/usr/bin/systemctl try-restart %{?*} || : \
fi \
else # package uninstall \
for service in %{?*} ; do \
sysv_service=${service%.*} \
rm -f "/var/lib/systemd/migrated/$sysv_service" 2> /dev/null || : \
done \
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
for service in %{?*} ; do \
sysv_service="${service%.*}" \
rm -f "/var/lib/systemd/migrated/$sysv_service" || : \
done \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
fi \
%{nil}
%systemd_post() \
if [ $1 -eq 0 ] ; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
/usr/bin/systemctl stop %{?*} > /dev/null 2>&1 || : \
if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} || : \
/usr/bin/systemctl stop %{?*} || : \
fi \
%{nil}
%systemd_user_post() %systemd_post --user --global %{?*}
%systemd_preun() \
if [ $1 -eq 0 ] ; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : \
/usr/bin/systemctl stop %{?*} > /dev/null 2>&1 || : \
if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} || : \
/usr/bin/systemctl stop %{?*} || : \
fi \
%{nil}
%systemd_user_preun() \
if [ $1 -eq 0 ] ; then \
if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
systemctl --no-reload --user --global disable %{?*} > /dev/null 2>&1 || : \
/usr/bin/systemctl --no-reload --user --global disable %{?*} || : \
fi \
%{nil}
%systemd_postun() \
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
%{nil}
%systemd_user_postun() %{nil}
%systemd_user_postun_with_restart() %{nil}
%systemd_postun_with_restart() \
@rootbindir@/systemctl daemon-reload >/dev/null 2>&1 || : \
if [ $1 -ge 1 ] ; then \
# Package upgrade, not uninstall \
/usr/bin/systemctl try-restart %{?*} >/dev/null 2>&1 || : \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
if [ "$1" -ge 1 -a -x /usr/bin/systemctl ]; then \
# Package upgrade, not uninstall \
/usr/bin/systemctl try-restart %{?*} || : \
fi \
%{nil}
%udev_hwdb_update() \
/usr/bin/udevadm hwdb --update >/dev/null 2>&1 || : \
[ -x /usr/bin/udevadm ] && /usr/bin/udevadm hwdb --update || : \
%{nil}
%udev_rules_update() \
/usr/bin/udevadm control --reload >/dev/null 2>&1 || : \
[ -x /usr/bin/udevadm ] && /usr/bin/udevadm control --reload || : \
%{nil}
%journal_catalog_update() \
/usr/bin/journalctl --update-catalog >/dev/null 2>&1 || : \
[ -x /usr/bin/journalctl ] && /usr/bin/journalctl --update-catalog || : \
%{nil}
%tmpfiles_create() \
/usr/bin/systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \
[ -x /usr/bin/systemd-tmpfiles ] && \
/usr/bin/systemd-tmpfiles --create %{?*} || : \
%{nil}
%sysusers_create() \
systemd-sysusers %{?*} >/dev/null 2>&1 || : \
[ -x /usr/bin/systemd-sysusers ] && /usr/bin/systemd-sysusers %{?*} || : \
%{nil}
%sysusers_create_inline() \
echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \
if [ -x /usr/bin/systemd-sysusers ]; then \
echo %{?*} | systemd-sysusers - || : \
fi \
%{nil}
%sysctl_apply() \
/usr/lib/systemd/systemd-sysctl %{?*} >/dev/null 2>&1 || : \
[ -x /usr/lib/systemd/systemd-sysctl ] && \
/usr/lib/systemd/systemd-sysctl %{?*} || : \
%{nil}
%binfmt_apply() \
/usr/lib/systemd/systemd-binfmt %{?*} >/dev/null 2>&1 || : \
[ -x /usr/lib/systemd/systemd-binfmt ] && \
/usr/lib/systemd/systemd-binfmt %{?*} || : \
%{nil}

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jun 15 11:33:28 UTC 2015 - jengelh@inai.de
- Check for presence/executability of systemd programs before
executing them, and do not suppress warnings/errors resulting
from them.
-------------------------------------------------------------------
Fri Jan 9 13:38:16 UTC 2015 - jengelh@inai.de

View File

@ -1,7 +1,7 @@
#
# spec file for package systemd-rpm-macros
#
# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2015 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