forked from pool/systemd
Frederic Crozat
4e462d819d
- Handle disable_capslock, compose table and kbd_rate - Add rpm macros.systemd file. - Do not disable klogd, it has its own service now. - Handle kexec correctly (bnc#671673). - Disable preload services, they are conflicting with systemd. >>>>>>> .new OBS-URL: https://build.opensuse.org/request/show/79603 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=181
100 lines
3.0 KiB
Plaintext
100 lines
3.0 KiB
Plaintext
# 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
|
|
#
|
|
# %post
|
|
# %service_add demo.service demo1.service
|
|
#
|
|
# %preun
|
|
# %service_del_preun demo.service
|
|
#
|
|
# %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 \
|
|
|
|
%_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
|
|
|
|
# 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
|
|
|
|
# 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
|
|
|
|
%service_migrate_to_systemd_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" \
|
|
done \
|
|
else \
|
|
for service in %{?*} ; do \
|
|
if [ ! -e "/var/lib/systemd/migrated/$service" ]; then \
|
|
services_to_migrate="$services_to_migrate $service" \
|
|
fi \
|
|
done \
|
|
if [ -n "$services_to_migrate" ]; then \
|
|
/usr/sbin/systemd-sysv-convert --save $services_to_migrate >/dev/null 2>&1 || : \
|
|
fi \
|
|
fi
|
|
|
|
%service_migrate_to_systemd_post() \
|
|
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" \
|
|
fi \
|
|
done \
|
|
if [ -n "$services_to_migrate" ]; then \
|
|
/usr/sbin/systemd-sysv-convert --apply $services_to_migrate >/dev/null 2>&1 || : \
|
|
/bin/systemctl daemon-reload >/dev/null 2>&1 || : \
|
|
fi \
|
|
|
|
%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
|
|
|