Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:Update
systemd-rpm-macros
macros.systemd
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File macros.systemd of Package systemd-rpm-macros
# -*- 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 # ### # # When a package install systemd preset files, it should use the following macros: # # %pre -p /bin/bash # %systemd_preset_pre # # %posttrans -p /bin/bash # %systemd_preset_posttrans # ### # This is for systemctl %systemd_requires \ Requires(pre): systemd \ Requires(post): systemd \ Requires(preun): systemd \ Requires(postun): systemd \ %_unitdir /usr/lib/systemd/system %_presetdir /usr/lib/systemd/system-preset %_udevhwdbdir /usr/lib/udev/hwdb.d %_udevrulesdir /usr/lib/udev/rules.d %_journalcatalogdir /usr/lib/systemd/catalog %_tmpfilesdir /usr/lib/tmpfiles.d %_sysctldir /usr/lib/sysctl.d %_ntpunitsdir /usr/lib/systemd/ntp-units.d %_restart_on_update_force() (\ test "$YAST_IS_RUNNING" = instsys && exit 0 \ %{?*:/usr/bin/systemctl try-restart %{*}} \ ) || : %{nil} %_restart_on_update_never() %{?*:# Restart of %{*} skipped} %{nil} %_restart_on_update() (\ test "$YAST_IS_RUNNING" = instsys && exit 0\ 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() ( \ test "$YAST_IS_RUNNING" = instsys && exit 0\ %{?*:/usr/bin/systemctl stop %{*}}\ ) || : %{nil} %_stop_on_removal_never() %{?*:# Stop of %{*} skipped} %{nil} %_stop_on_removal() (\ test "$YAST_IS_RUNNING" = instsys && exit 0\ 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} %service_add_pre() \ 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 \ 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 \ fi \ %{nil} # On install, tell systemd to reload its unit files %service_add_post() \ 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 \ done \ /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \ 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 \ fi \ %{nil} # On uninstall, disable and stop services %service_del_preun(fn) \ 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 %{?*} > /dev/null 2>&1 || : \ %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ %{nil} # On uninstall, tell systemd to reload its unit files %service_del_postun(fn) \ test -n "$FIRST_ARG" || FIRST_ARG=$1 \ if [ $FIRST_ARG -ge 1 ]; then \ # Package upgrade, not uninstall \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \ %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ else # package uninstall \ for service in %{?*} ; do \ sysv_service=${service%.*} \ rm -f "/var/lib/systemd/migrated/$sysv_service" 2> /dev/null || : \ done \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : \ fi \ fi \ %{nil} %udev_hwdb_update() \ [ -x /usr/bin/udevadm ] && /usr/bin/udevadm hwdb --update >/dev/null 2>&1 || : \ %{nil} %udev_rules_update() \ [ -x /usr/bin/udevadm ] /usr/bin/udevadm control --reload >/dev/null 2>&1 || : \ %{nil} %journal_catalog_update() \ [ -x /usr/bin/journalctl ] && /usr/bin/journalctl --update-catalog >/dev/null 2>&1 || : \ %{nil} %tmpfiles_create() \ [ -x /usr/bin/systemd-tmpfiles ] && \ /usr/bin/systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \ %{nil} %systemd_preset_pre() \ if ! test -f /usr/lib/systemd/system-preset/99-default-disable.preset ; then \ mkdir -p /usr/lib/systemd/system-preset; \ touch /usr/lib/systemd/system-preset/systemd_preset-skip.rpm-tmp; \ else \ cd /usr/lib/systemd/system-preset; \ declare -a PRESET_FILES; \ declare -A PRESETS; \ PRESET_FILES=(*.preset); \ if ! test -f systemd_preset-old.rpm-tmp ; then \ for ((i=${#PRESET_FILES[@]}-1 ; i>= 0 ; i-- )) ; do \ FILE=${PRESET_FILES[i]}; \ exec 3<"$FILE"; \ while read -u3 ENABLE SERVICE PAD ; do \ if test -z "$SERVICE" ; then \ continue; \ fi; \ case "$ENABLE" in \ enable|disable) \ PRESETS[$SERVICE]=$ENABLE;; \ esac; \ done; \ exec 3<&-; \ done; \ exec 3>systemd_preset-old.rpm-tmp; \ for PRESET in "${!PRESETS[@]}" ; do \ echo >&3 "${PRESETS[$PRESET]} $PRESET"; \ done; \ exec 3>&-; \ fi; \ fi; \ %{nil} %systemd_preset_posttrans() \ if test -f /usr/lib/systemd/system-preset/systemd_preset-skip.rpm-tmp ; then \ rm -f /usr/lib/systemd/system-preset/systemd_preset-{old,skip}.rpm-tmp; \ fi; \ cd /usr/lib/systemd/system-preset; \ if test -f systemd_preset-old.rpm-tmp ; then \ declare -a PRESET_FILES; \ declare -A PRESETS_OLD; \ declare -A PRESETS_OLD_WILDCARD; \ declare -A PRESETS; \ declare -A PRESETS_WILDCARD; \ exec 3<systemd_preset-old.rpm-tmp; \ while read -u3 ENABLE SERVICE PAD ; do \ if test -z "$SERVICE" ; then \ continue; \ fi; \ case "$ENABLE" in \ enable|disable) \ case $SERVICE in \ *"*"*|*"?"*) PRESETS_OLD_WILDCARD[$SERVICE]=$ENABLE;; \ *) PRESETS_OLD[$SERVICE]=$ENABLE;; \ esac;; \ esac; \ done; \ exec 3<&-; \ PRESET_FILES=(*.preset); \ for ((i=${#PRESET_FILES[@]}-1 ; i>= 0 ; i-- )) ; do \ FILE=${PRESET_FILES[i]}; \ exec 3<"$FILE"; \ while read -u3 ENABLE SERVICE PAD ; do \ if test -z "$SERVICE" ; then \ continue; \ fi; \ case "$ENABLE" in \ enable|disable) \ case $SERVICE in \ *"*"*|*"?"*) PRESETS_WILDCARD[$SERVICE]=$ENABLE;; \ *) PRESETS[$SERVICE]=$ENABLE;; \ esac;; \ esac; \ done; \ exec 3<&-; \ done; \ if test -x /usr/bin/systemctl ; then \ /usr/bin/systemctl --type=service,socket list-unit-files; \ fi >systemd_preset-states.rpm-tmp; \ exec 3<systemd_preset-states.rpm-tmp; \ read -u3 PAD; \ while read -u3 SERVICE ENABLE PAD ; do \ if test -z "$SERVICE" ; then \ break; \ fi; \ ENABLE_OLD=enable; \ for PRESET in "${!PRESETS_OLD_WILDCARD[@]}" ; do \ case "$SERVICE" in \ $PRESET) ENABLE_OLD=${PRESETS_OLD_WILDCARD[$PRESET]};; \ esac; \ done; \ if test -n "${PRESETS_OLD[$SERVICE]}" ; then \ ENABLE_OLD="${PRESETS_OLD[$SERVICE]}"; \ fi; \ ENABLE_NEW=enable; \ for PRESET in "${!PRESETS_WILDCARD[@]}" ; do \ case "$SERVICE" in \ $PRESET) ENABLE_NEW=${PRESETS_WILDCARD[$PRESET]};; \ esac; \ done; \ if test -n "${PRESETS[$SERVICE]}" ; then \ ENABLE_NEW="${PRESETS[$SERVICE]}"; \ fi; \ if test "$ENABLE_OLD" != "$ENABLE_NEW" ; then \ echo "Resetting $SERVICE to the new default: $ENABLE_NEW"; \ /usr/bin/systemctl preset "$SERVICE" || :; \ fi; \ done; \ exec 3<&-; \ rm -f systemd_preset-old.rpm-tmp systemd_preset-states.rpm-tmp; \ fi; \ %{nil}
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor