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