2013-06-20 13:51:16 +00:00
|
|
|
# -*- Mode: makefile; indent-tabs-mode: t -*- */
|
|
|
|
# RPM macros for packages installing systemd unit files
|
|
|
|
#
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# When a package install systemd unit files, it should use the following macros:
|
|
|
|
#
|
|
|
|
# add %systemd_requires in the specfile
|
|
|
|
#
|
|
|
|
# %pre
|
|
|
|
# %service_add_pre demo.service demo1.service
|
|
|
|
#
|
|
|
|
# %post
|
|
|
|
# %service_add_post demo.service demo1.service
|
|
|
|
#
|
|
|
|
# %preun
|
|
|
|
# %service_del_preun demo.service
|
|
|
|
#
|
|
|
|
# %postun
|
|
|
|
# %service_del_postun demo.service
|
2019-02-25 09:47:37 +00:00
|
|
|
# %service_del_postun_without_restart demo.service
|
2015-08-05 15:23:06 +00:00
|
|
|
#
|
2013-06-20 13:51:16 +00:00
|
|
|
|
|
|
|
%_unitdir /usr/lib/systemd/system
|
2014-11-18 13:57:10 +00:00
|
|
|
%_userunitdir /usr/lib/systemd/user
|
2013-06-20 13:51:16 +00:00
|
|
|
%_presetdir /usr/lib/systemd/system-preset
|
2018-02-12 16:58:33 +00:00
|
|
|
%_userpresetdir /usr/lib/systemd/user-preset
|
2013-06-20 13:51:16 +00:00
|
|
|
%_udevhwdbdir /usr/lib/udev/hwdb.d
|
|
|
|
%_udevrulesdir /usr/lib/udev/rules.d
|
|
|
|
%_journalcatalogdir /usr/lib/systemd/catalog
|
|
|
|
%_tmpfilesdir /usr/lib/tmpfiles.d
|
2015-01-12 09:12:57 +00:00
|
|
|
%_sysusersdir /usr/lib/sysusers.d
|
2013-06-20 13:51:16 +00:00
|
|
|
%_sysctldir /usr/lib/sysctl.d
|
2014-03-27 14:45:24 +00:00
|
|
|
%_ntpunitsdir /usr/lib/systemd/ntp-units.d
|
2014-11-18 13:57:10 +00:00
|
|
|
%_binfmtdir /usr/lib/binfmt.d
|
2018-02-12 16:58:33 +00:00
|
|
|
%_systemdgeneratordir /usr/lib/systemd/system-generators
|
|
|
|
%_systemdusergeneratordir /usr/lib/systemd/user-generators
|
|
|
|
%_systemd_system_env_generator_dir /usr/lib/systemd/system-environment-generators
|
|
|
|
%_systemd_user_env_generator_dir /usr/lib/systemd/user-environment-generators
|
|
|
|
|
|
|
|
%systemd_requires \
|
|
|
|
Requires(pre): systemd \
|
|
|
|
Requires(post): systemd \
|
|
|
|
Requires(preun): systemd \
|
|
|
|
Requires(postun): systemd \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%systemd_ordering \
|
|
|
|
OrderWithRequires(post): systemd \
|
|
|
|
OrderWithRequires(preun): systemd \
|
|
|
|
OrderWithRequires(postun): systemd \
|
|
|
|
%{nil}
|
2013-06-20 13:51:16 +00:00
|
|
|
|
2016-03-03 10:09:49 +00:00
|
|
|
%_restart_on_update_force() (\
|
|
|
|
%{?*:/usr/bin/systemctl try-restart %{*}} \
|
|
|
|
) || : %{nil}
|
|
|
|
%_restart_on_update_never() %{?*:# Restart of %{*} skipped} %{nil}
|
|
|
|
%_restart_on_update() (\
|
|
|
|
test -f /etc/sysconfig/services -a \\\
|
|
|
|
-z "$DISABLE_RESTART_ON_UPDATE" && . /etc/sysconfig/services\
|
|
|
|
test "$DISABLE_RESTART_ON_UPDATE" = yes -o \\\
|
|
|
|
"$DISABLE_RESTART_ON_UPDATE" = 1 && exit 0\
|
|
|
|
%{?*:/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 -f /etc/sysconfig/services -a \\\
|
|
|
|
-z "$DISABLE_STOP_ON_REMOVAL" && . /etc/sysconfig/services\
|
|
|
|
test "$DISABLE_STOP_ON_REMOVAL" = yes -o \\\
|
|
|
|
"$DISABLE_STOP_ON_REMOVAL" = 1 && exit 0\
|
|
|
|
%{?*:/usr/bin/systemctl stop %{*}}\
|
|
|
|
) || : %{nil}
|
2015-11-20 16:54:39 +00:00
|
|
|
|
2013-06-20 13:51:16 +00:00
|
|
|
%service_add_pre() \
|
2015-07-10 08:14:04 +00:00
|
|
|
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
|
2013-06-20 13:51:16 +00:00
|
|
|
# disable migration if initial install under systemd \
|
|
|
|
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ "$FIRST_ARG" -eq 1 ]; then \
|
|
|
|
for service in %{?*} ; do \
|
2015-11-20 16:54:39 +00:00
|
|
|
sysv_service="${service%%.*}" \
|
2015-07-10 08:14:04 +00:00
|
|
|
touch "/var/lib/systemd/migrated/$sysv_service" || : \
|
|
|
|
done \
|
2013-06-20 13:51:16 +00:00
|
|
|
else \
|
2017-11-02 16:12:23 +00:00
|
|
|
for service in %{?*} ; do \
|
2017-12-01 10:51:04 +00:00
|
|
|
# The tag file might have been left by a preceding \
|
|
|
|
# update (see 1059627) \
|
|
|
|
rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \
|
|
|
|
\
|
2017-11-02 16:12:23 +00:00
|
|
|
if [ ! -e "/usr/lib/systemd/system/$service" ]; then \
|
|
|
|
touch "/run/rpm-%{name}-update-$service-new-in-upgrade" \
|
|
|
|
fi \
|
|
|
|
done \
|
2015-07-10 08:14:04 +00:00
|
|
|
for service in %{?*} ; do \
|
2015-11-20 16:54:39 +00:00
|
|
|
sysv_service="${service%%.*}" \
|
2017-12-15 09:52:31 +00:00
|
|
|
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
|
|
|
|
continue \
|
|
|
|
fi \
|
2018-11-26 13:56:33 +00:00
|
|
|
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
|
2017-12-15 09:52:31 +00:00
|
|
|
continue \
|
2015-07-10 08:14:04 +00:00
|
|
|
fi \
|
2018-11-26 13:56:33 +00:00
|
|
|
/usr/lib/systemd/systemd-sysv-convert --save $sysv_service || : \
|
2015-07-10 08:14:04 +00:00
|
|
|
done \
|
2013-06-20 13:51:16 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# On install, tell systemd to reload its unit files
|
|
|
|
%service_add_post() \
|
2015-07-10 08:14:04 +00:00
|
|
|
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
|
2013-06-20 13:51:16 +00:00
|
|
|
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
|
2017-12-15 09:52:31 +00:00
|
|
|
\
|
2019-02-27 12:21:44 +00:00
|
|
|
if [ -x /usr/bin/systemctl ]; then \
|
|
|
|
/usr/bin/systemctl daemon-reload || : \
|
|
|
|
fi \
|
|
|
|
\
|
2017-12-15 09:52:31 +00:00
|
|
|
if [ "$FIRST_ARG" -eq 1 ]; then \
|
2015-07-10 08:14:04 +00:00
|
|
|
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 \
|
2017-12-15 09:52:31 +00:00
|
|
|
for service in %{?*} ; do \
|
|
|
|
sysv_service=${service%%.*} \
|
|
|
|
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
|
|
|
|
continue \
|
|
|
|
fi \
|
2018-11-26 13:56:33 +00:00
|
|
|
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
|
2017-12-15 09:52:31 +00:00
|
|
|
continue \
|
|
|
|
fi \
|
2018-11-26 13:56:33 +00:00
|
|
|
/usr/lib/systemd/systemd-sysv-convert --apply $sysv_service || : \
|
2017-12-15 09:52:31 +00:00
|
|
|
touch /var/lib/systemd/migrated/$sysv_service || : \
|
|
|
|
done \
|
2013-06-20 13:51:16 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
# On uninstall, disable and stop services
|
2016-03-03 10:09:49 +00:00
|
|
|
#
|
|
|
|
# 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) \
|
2015-07-10 08:14:04 +00:00
|
|
|
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 %{?*} || : \
|
2016-03-03 10:09:49 +00:00
|
|
|
%{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
|
2013-06-20 13:51:16 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2019-02-25 09:47:37 +00:00
|
|
|
# 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() \
|
|
|
|
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
|
|
|
|
if [ "$FIRST_ARG" -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}
|
|
|
|
|
2013-06-20 13:51:16 +00:00
|
|
|
# On uninstall, tell systemd to reload its unit files
|
2016-03-03 10:09:49 +00:00
|
|
|
#
|
|
|
|
# Options used if not in an installation systems
|
2019-02-25 09:47:37 +00:00
|
|
|
# -f that is force service restart in removal (deprecated)
|
|
|
|
# -n that do not touch active service (depredacted)
|
2016-03-03 10:09:49 +00:00
|
|
|
# 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(fn) \
|
2015-07-10 08:14:04 +00:00
|
|
|
test -n "$FIRST_ARG" || FIRST_ARG="$1" \
|
2019-02-25 09:47:37 +00:00
|
|
|
%service_del_postun_without_restart %{?*} \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ "$FIRST_ARG" -ge 1 ]; then \
|
|
|
|
# Package upgrade, not uninstall \
|
2015-11-20 16:54:39 +00:00
|
|
|
if [ -x /usr/bin/systemctl ]; then \
|
2016-03-03 10:09:49 +00:00
|
|
|
%{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
|
2015-07-10 08:14:04 +00:00
|
|
|
fi \
|
2013-06-20 13:51:16 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2019-02-25 09:47:37 +00:00
|
|
|
#
|
|
|
|
# Upstream variants
|
|
|
|
#
|
|
|
|
|
2018-02-14 14:07:02 +00:00
|
|
|
%systemd_post() \
|
|
|
|
if [ $1 -eq 1 -a -x /usr/bin/systemctl ] ; then \
|
|
|
|
# Initial installation \
|
|
|
|
/usr/bin/systemctl --no-reload preset %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2018-05-22 12:56:47 +00:00
|
|
|
%systemd_user_post() %{expand:%systemd_post \\--global %%{?*}}
|
2014-11-18 13:57:10 +00:00
|
|
|
|
2016-03-03 10:09:49 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
%systemd_preun(fn) \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \
|
|
|
|
# Package removal, not upgrade \
|
|
|
|
/usr/bin/systemctl --no-reload disable %{?*} || : \
|
2016-03-03 10:09:49 +00:00
|
|
|
%{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
|
2014-11-18 13:57:10 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%systemd_user_preun() \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \
|
2014-11-18 13:57:10 +00:00
|
|
|
# Package removal, not upgrade \
|
2018-05-22 12:56:47 +00:00
|
|
|
/usr/bin/systemctl --global disable %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%systemd_postun() \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ -x /usr/bin/systemctl ]; then \
|
|
|
|
/usr/bin/systemctl daemon-reload || : \
|
|
|
|
fi \
|
2014-11-18 13:57:10 +00:00
|
|
|
%{nil}
|
|
|
|
|
2015-01-12 09:12:57 +00:00
|
|
|
%systemd_user_postun() %{nil}
|
|
|
|
%systemd_user_postun_with_restart() %{nil}
|
|
|
|
|
2014-11-18 13:57:10 +00:00
|
|
|
%systemd_postun_with_restart() \
|
2015-07-10 08:14:04 +00:00
|
|
|
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 %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2013-06-20 13:51:16 +00:00
|
|
|
%udev_hwdb_update() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/bin/udevadm ] && /usr/bin/udevadm hwdb --update || : \
|
2013-06-20 13:51:16 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%udev_rules_update() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/bin/udevadm ] && /usr/bin/udevadm control --reload || : \
|
2013-06-20 13:51:16 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%journal_catalog_update() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/bin/journalctl ] && /usr/bin/journalctl --update-catalog || : \
|
2013-06-20 13:51:16 +00:00
|
|
|
%{nil}
|
2014-11-18 13:57:10 +00:00
|
|
|
|
|
|
|
%tmpfiles_create() \
|
2017-11-22 14:47:28 +00:00
|
|
|
[ -z "${TRANSACTIONAL_UPDATE}" -a -x /usr/bin/systemd-tmpfiles ] && \
|
2015-07-10 08:14:04 +00:00
|
|
|
/usr/bin/systemd-tmpfiles --create %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
%{nil}
|
|
|
|
|
2015-01-12 09:12:57 +00:00
|
|
|
%sysusers_create() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/bin/systemd-sysusers ] && /usr/bin/systemd-sysusers %{?*} || : \
|
2015-01-12 09:12:57 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%sysusers_create_inline() \
|
2015-07-10 08:14:04 +00:00
|
|
|
if [ -x /usr/bin/systemd-sysusers ]; then \
|
|
|
|
echo %{?*} | systemd-sysusers - || : \
|
|
|
|
fi \
|
2015-01-12 09:12:57 +00:00
|
|
|
%{nil}
|
|
|
|
|
2014-11-18 13:57:10 +00:00
|
|
|
%sysctl_apply() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/lib/systemd/systemd-sysctl ] && \
|
|
|
|
/usr/lib/systemd/systemd-sysctl %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%binfmt_apply() \
|
2015-07-10 08:14:04 +00:00
|
|
|
[ -x /usr/lib/systemd/systemd-binfmt ] && \
|
|
|
|
/usr/lib/systemd/systemd-binfmt %{?*} || : \
|
2014-11-18 13:57:10 +00:00
|
|
|
%{nil}
|