teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/triggers.systemd

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