]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/macros.systemd.in
Merge pull request #8107 from sourcejedi/pedant
[thirdparty/systemd.git] / src / core / macros.systemd.in
1 # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
2 # SPDX-License-Identifier: LGPL-2.1+
3 #
4 # This file is part of systemd.
5 #
6 # Copyright 2012 Lennart Poettering
7 #
8 # systemd is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU Lesser General Public License as published by
10 # the Free Software Foundation; either version 2.1 of the License, or
11 # (at your option) any later version.
12 #
13 # systemd is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public License
19 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
20
21 # RPM macros for packages installing systemd unit files
22
23 %_unitdir @systemunitdir@
24 %_userunitdir @userunitdir@
25 %_presetdir @systempresetdir@
26 %_userpresetdir @userpresetdir@
27 %_udevhwdbdir @udevhwdbdir@
28 %_udevrulesdir @udevrulesdir@
29 %_journalcatalogdir @catalogdir@
30 %_tmpfilesdir @tmpfilesdir@
31 %_sysusersdir @sysusersdir@
32 %_sysctldir @sysctldir@
33 %_binfmtdir @binfmtdir@
34 %_systemdgeneratordir @systemgeneratordir@
35 %_systemdusergeneratordir @usergeneratordir@
36 %_systemd_system_env_generator_dir @systemenvgeneratordir@
37 %_systemd_user_env_generator_dir @userenvgeneratordir@
38
39 %systemd_requires \
40 Requires(post): systemd \
41 Requires(preun): systemd \
42 Requires(postun): systemd \
43 %{nil}
44
45 %systemd_ordering \
46 OrderWithRequires(post): systemd \
47 OrderWithRequires(preun): systemd \
48 OrderWithRequires(postun): systemd \
49 %{nil}
50
51 %systemd_post() \
52 if [ $1 -eq 1 ] ; then \
53 # Initial installation \
54 systemctl --no-reload preset %{?*} >/dev/null 2>&1 || : \
55 fi \
56 %{nil}
57
58 %systemd_user_post() %{expand:%systemd_post \\--user \\--global %%{?*}}
59
60 %systemd_preun() \
61 if [ $1 -eq 0 ] ; then \
62 # Package removal, not upgrade \
63 systemctl --no-reload disable --now %{?*} > /dev/null 2>&1 || : \
64 fi \
65 %{nil}
66
67 %systemd_user_preun() \
68 if [ $1 -eq 0 ] ; then \
69 # Package removal, not upgrade \
70 systemctl --no-reload --user --global disable %{?*} > /dev/null 2>&1 || : \
71 fi \
72 %{nil}
73
74 %systemd_postun() %{nil}
75
76 %systemd_user_postun() %{nil}
77
78 %systemd_postun_with_restart() \
79 if [ $1 -ge 1 ] ; then \
80 # Package upgrade, not uninstall \
81 systemctl try-restart %{?*} >/dev/null 2>&1 || : \
82 fi \
83 %{nil}
84
85 %systemd_user_postun_with_restart() %{nil}
86
87 %udev_hwdb_update() %{nil}
88
89 %udev_rules_update() %{nil}
90
91 %journal_catalog_update() %{nil}
92
93 %tmpfiles_create() \
94 systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \
95 %{nil}
96
97 # Deprecated. Use %sysusers_create_package instead
98 %sysusers_create() \
99 systemd-sysusers %{?*} >/dev/null 2>&1 || : \
100 %{nil}
101
102 %sysusers_create_inline() \
103 echo %{?*} | systemd-sysusers - >/dev/null 2>&1 || : \
104 %{nil}
105
106 # This should be used by package installation scripts which
107 # require users or groups to be present before the files installed
108 # by the package are present on disk (for example because some files
109 # are owned by those users or groups).
110 #
111 # Example:
112 # Source1: %{name}.conf
113 # ...
114 # %install
115 # install -Dt %{buildroot}%{sysusersdir} %SOURCE1
116 # %pre
117 # %sysusers_create_package %{name} %SOURCE1
118 # %files
119 # %{sysusersdir}/%{name}.conf
120 %sysusers_create_package() \
121 echo "%(cat %2)" | systemd-sysusers --replace=%_sysusersdir/%1.conf - >/dev/null 2>&1 || : \
122 %{nil}
123
124 %sysctl_apply() \
125 @rootlibexecdir@/systemd-sysctl %{?*} >/dev/null 2>&1 || : \
126 %{nil}
127
128 %binfmt_apply() \
129 @rootlibexecdir@/systemd-binfmt %{?*} >/dev/null 2>&1 || : \
130 %{nil}