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