File macros.obs-server of Package obs-server-macros
# -*- Mode: makefile; indent-tabs-mode: t -*- */
# RPM macros for packages installing open-build-service in Fedora/RHEL
#
%_restart_on_update_force() /usr/bin/systemctl try-restart %{*} || : %{nil}
%_restart_on_update_never() : # Restart of %{*} skipped %{nil}
%_restart_on_update_reload() /usr/bin/systemctl try-reload-or-restart %{*} || : %{nil}
%_restart_on_update() \
test -z "$DISABLE_RESTART_ON_UPDATE" -a -f /etc/sysconfig/services &&\\\
. /etc/sysconfig/services \
test "$DISABLE_RESTART_ON_UPDATE" != yes -a "$DISABLE_RESTART_ON_UPDATE" != 1 &&\\\
/usr/bin/systemctl try-restart %{*} || : \
%{nil}
%_stop_on_removal_force() /usr/bin/systemctl stop %{*} || : %{nil}
%_stop_on_removal_never() : # Stop of %{*} skipped} %{nil}
%_stop_on_removal() \
test -z "$DISABLE_STOP_ON_REMOVAL" -a -f /etc/sysconfig/services &&\\\
. /etc/sysconfig/services \
test "$DISABLE_STOP_ON_REMOVAL" != yes -a "$DISABLE_STOP_ON_REMOVAL" != 1 &&\\\
/usr/bin/systemctl stop %{*} || : \
%{nil}
%service_add_pre() \
# disable migration if initial install under systemd \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
if [ $1 -eq 1 ]; then \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
touch "/var/lib/systemd/migrated/$sysv_service" || : \
done \
else \
for service in %{?*} ; do \
# The tag file might have been left by a preceding \
# update (see 1059627) \
rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \
\
if [ ! -e "/usr/lib/systemd/system/$service" ]; then \
touch "/run/rpm-%{name}-update-$service-new-in-upgrade" \
fi \
done \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
continue \
fi \
/usr/lib/systemd/systemd-sysv-convert --save $sysv_service || : \
done \
fi \
%{nil}
# On install, tell systemd to reload its unit files
%service_add_post() \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
\
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
\
if [ $1 -eq 1 ]; then \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl preset %{?*} || : \
fi \
elif [ $1 -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 \
for service in %{?*} ; do \
sysv_service=${service%%.*} \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
continue \
fi \
/usr/lib/systemd/systemd-sysv-convert --apply $sysv_service || : \
touch /var/lib/systemd/migrated/$sysv_service || : \
done \
fi \
%{nil}
# On uninstall, disable and stop services
#
# Options used if not in an installation systems
# -f that is fore service stop in removal
# -n that do not touch active service
# the default is to check for DISABLE_STOP_ON_REMOVAL environment
# variable if not found use the value read from /etc/sysconfig/services
#
%service_del_preun(fn) \
if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} || : \
%{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files.
# On update, tell systemd to reload its unit files but don't restart service.
#
%service_del_postun_without_restart() \
if [ $1 -eq 0 ]; then \
# Package removal \
for service in %{?*} ; do \
sysv_service="${service%.*}" \
rm -f "/var/lib/systemd/migrated/$sysv_service" || : \
done \
fi \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files
#
# Options used if not in an installation systems
# -f that is force service restart in removal (deprecated)
# -n that do not touch active service (depredacted)
# the default is to check for DISABLE_RESTART_ON_UPDATE environment
# variable if not found use the value read from /etc/sysconfig/services
#
%service_del_postun(fnr) \
%service_del_postun_without_restart %{?*} \
if [ $1 -ge 1 ]; then \
# Package upgrade, not uninstall \
if [ -x /usr/bin/systemctl ]; then \
%{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}}%{!-f:%{!-n:%{-r:_reload}}} %{?*}} \
fi \
fi \
%{nil}