Blame SOURCES/triggers.systemd

a3e2b5
#  -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
a3e2b5
#  SPDX-License-Identifier: LGPL-2.1+
a3e2b5
#
a3e2b5
#  This file is part of systemd.
a3e2b5
#
a3e2b5
#  Copyright 2015 Zbigniew Jędrzejewski-Szmek
a3e2b5
#  Copyright 2018 Neal Gompa
a3e2b5
#
a3e2b5
#  systemd is free software; you can redistribute it and/or modify it
a3e2b5
#  under the terms of the GNU Lesser General Public License as published by
a3e2b5
#  the Free Software Foundation; either version 2.1 of the License, or
a3e2b5
#  (at your option) any later version.
a3e2b5
#
a3e2b5
#  systemd is distributed in the hope that it will be useful, but
a3e2b5
#  WITHOUT ANY WARRANTY; without even the implied warranty of
a3e2b5
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a3e2b5
#  Lesser General Public License for more details.
a3e2b5
#
a3e2b5
#  You should have received a copy of the GNU Lesser General Public License
a3e2b5
#  along with systemd; If not, see <http://www.gnu.org/licenses/>.
a3e2b5
a3e2b5
# The contents of this are an example to be copied into systemd.spec.
a3e2b5
#
a3e2b5
# Minimum rpm version supported: 4.13.0
a3e2b5
a3e2b5
%transfiletriggerin -P 900900 -- /usr/lib/systemd/system /etc/systemd/system
a3e2b5
# This script will run after any package is initially installed or
a3e2b5
# upgraded. We care about the case where a package is initially
a3e2b5
# installed, because other cases are covered by the *un scriptlets,
a3e2b5
# so sometimes we will reload needlessly.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/systemctl daemon-reload
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerun -- /usr/lib/systemd/system /etc/systemd/system
a3e2b5
# On removal, we need to run daemon-reload after any units have been
a3e2b5
# removed. %transfiletriggerpostun would be ideal, but it does not get
a3e2b5
# executed for some reason.
a3e2b5
# On upgrade, we need to run daemon-reload after any new unit files
a3e2b5
# have been installed, but before %postun scripts in packages get
a3e2b5
# executed. %transfiletriggerun gets the right list of files
a3e2b5
# but it is invoked too early (before changes happen).
a3e2b5
# %filetriggerpostun happens at the right time, but it fires for
a3e2b5
# every package.
a3e2b5
# To execute the reload at the right time, we create a state
a3e2b5
# file in %transfiletriggerun and execute the daemon-reload in
a3e2b5
# the first %filetriggerpostun.
a3e2b5
a3e2b5
if test -d "/run/systemd/system"; then
a3e2b5
    mkdir -p "%{_localstatedir}/lib/rpm-state/systemd"
a3e2b5
    touch "%{_localstatedir}/lib/rpm-state/systemd/needs-reload"
a3e2b5
fi
a3e2b5
a3e2b5
%filetriggerpostun -P 1000100 -- /usr/lib/systemd/system /etc/systemd/system
a3e2b5
if test -f "%{_localstatedir}/lib/rpm-state/systemd/needs-reload"; then
a3e2b5
    rm -rf "%{_localstatedir}/lib/rpm-state/systemd"
a3e2b5
    %{_bindir}/systemctl daemon-reload
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin -P 100700 -- /usr/lib/sysusers.d
a3e2b5
# This script will process files installed in /usr/lib/sysusers.d to create
a3e2b5
# specified users automatically. The priority is set such that it
a3e2b5
# will run before the tmpfiles file trigger.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/systemd-sysusers
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin -P 100500 -- /usr/lib/tmpfiles.d
a3e2b5
# This script will process files installed in /usr/lib/tmpfiles.d to create
a3e2b5
# tmpfiles automatically. The priority is set such that it will run
a3e2b5
# after the sysusers file trigger, but before any other triggers.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/systemd-tmpfiles --create
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin udev -- /usr/lib/udev/hwdb.d
a3e2b5
# This script will automatically invoke hwdb update if files have been
a3e2b5
# installed or updated in /usr/lib/udev/hwdb.d.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/systemd-hwdb update
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin -- /usr/lib/systemd/catalog
a3e2b5
# This script will automatically invoke journal catalog update if files
a3e2b5
# have been installed or updated in /usr/lib/systemd/catalog.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/journalctl --update-catalog
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin udev -- /usr/lib/udev/rules.d
a3e2b5
# This script will automatically update udev with new rules if files
a3e2b5
# have been installed or updated in /usr/lib/udev/rules.d.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  %{_bindir}/udevadm control --reload
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin -- /usr/lib/sysctl.d
a3e2b5
# This script will automatically apply sysctl rules if files have been
a3e2b5
# installed or updated in /usr/lib/sysctl.d.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  /usr/lib/systemd/systemd-sysctl
a3e2b5
fi
a3e2b5
a3e2b5
%transfiletriggerin -- /usr/lib/binfmt.d
a3e2b5
# This script will automatically apply binfmt rules if files have been
a3e2b5
# installed or updated in /usr/lib/binfmt.d.
a3e2b5
if test -d /run/systemd/system; then
a3e2b5
  /usr/lib/systemd/systemd-binfmt
a3e2b5
fi