2015-11-15 01:14:34 +01:00
|
|
|
# -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
|
2020-11-09 05:23:58 +01:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2012-06-21 22:14:17 +02:00
|
|
|
#
|
|
|
|
# This file is part of systemd.
|
|
|
|
|
|
|
|
# RPM macros for packages installing systemd unit files
|
|
|
|
|
|
|
|
%_unitdir @systemunitdir@
|
2013-06-17 18:37:07 +02:00
|
|
|
%_userunitdir @userunitdir@
|
2012-09-13 22:17:46 +02:00
|
|
|
%_presetdir @systempresetdir@
|
2017-08-09 09:45:02 +02:00
|
|
|
%_userpresetdir @userpresetdir@
|
2012-11-16 19:54:19 +01:00
|
|
|
%_udevhwdbdir @udevhwdbdir@
|
|
|
|
%_udevrulesdir @udevrulesdir@
|
|
|
|
%_journalcatalogdir @catalogdir@
|
2014-06-13 19:18:55 +02:00
|
|
|
%_binfmtdir @binfmtdir@
|
2018-05-19 17:02:37 +02:00
|
|
|
%_sysctldir @sysctldir@
|
|
|
|
%_sysusersdir @sysusersdir@
|
|
|
|
%_tmpfilesdir @tmpfilesdir@
|
2018-06-25 18:56:50 +02:00
|
|
|
%_environmentdir @environmentdir@
|
2018-05-19 17:02:37 +02:00
|
|
|
%_modulesloaddir @modulesloaddir@
|
|
|
|
%_modprobedir @modprobedir@
|
2016-07-15 09:35:49 +02:00
|
|
|
%_systemdgeneratordir @systemgeneratordir@
|
|
|
|
%_systemdusergeneratordir @usergeneratordir@
|
manager: run environment generators
Environment file generators are a lot like unit file generators, but not
exactly:
1. environment file generators are run for each manager instance, and their
output is (or at least can be) individualized.
The generators themselves are system-wide, the same for all users.
2. environment file generators are run sequentially, in priority order.
Thus, the lifetime of those files is tied to lifecycle of the manager
instance. Because generators are run sequentially, later generators can use or
modify the output of earlier generators.
Each generator is run with no arguments, and the whole state is stored in the
environment variables. The generator can echo a set of variable assignments to
standard output:
VAR_A=something
VAR_B=something else
This output is parsed, and the next and subsequent generators run with those
updated variables in the environment. After the last generator is done, the
environment that the manager itself exports is updated.
Each generator must return 0, otherwise the output is ignored.
The generators in */user-env-generator are for the user session managers,
including root, and the ones in */system-env-generator are for pid1.
2017-01-22 07:13:47 +01:00
|
|
|
%_systemd_system_env_generator_dir @systemenvgeneratordir@
|
|
|
|
%_systemd_user_env_generator_dir @userenvgeneratordir@
|
2012-06-21 22:14:17 +02:00
|
|
|
|
2018-06-26 13:42:29 +02:00
|
|
|
# Because we had one release with a typo...
|
|
|
|
# This is temporary (Remove after systemd 240 is released)
|
2018-07-03 15:40:53 +02:00
|
|
|
%_environmnentdir %{warn:Use %%_environmentdir instead}%_environmentdir
|
2018-06-26 13:42:29 +02:00
|
|
|
|
2012-06-21 22:14:17 +02:00
|
|
|
%systemd_requires \
|
|
|
|
Requires(post): systemd \
|
|
|
|
Requires(preun): systemd \
|
|
|
|
Requires(postun): systemd \
|
|
|
|
%{nil}
|
|
|
|
|
2016-07-22 15:33:13 +02:00
|
|
|
%systemd_ordering \
|
|
|
|
OrderWithRequires(post): systemd \
|
|
|
|
OrderWithRequires(preun): systemd \
|
|
|
|
OrderWithRequires(postun): systemd \
|
|
|
|
%{nil}
|
|
|
|
|
2020-07-14 16:25:32 +02:00
|
|
|
%__systemd_someargs_0(:) %{error:The %%%1 macro requires some arguments}
|
rpm: check argument counts for systemd macros
Invoking %systemd_tmpfiles (in %post) without any arguments, while
possible, will cause systemd-tmpfiles to process the entire system
configuration, rather than just the newly installed configuration
files. In https://github.com/systemd/systemd/pull/12048, it was
established that processing everything constitutes unusual practice,
and should be flagged as a mistake at build time.
Furthermore, invoking %systemd_post without any arguments will cause
the underlying `systemctl preset` to outright return an error ("Too
few arguments") when run. This can be flagged during build time in
the same manner.
As I have found no ways to successfully nest %if clauses inside a
macro[1], I am helping myself by reusing the recursive variable
expansion technique pioneered in [2].
Now, when %systemd_post or %systemd_tmpfiles is incorrectly used,
rpm gives accurate line number reporting, too:
error: This macro requires some arguments
error: line 11: %{systemd_post}
error: This macro requires two arguments
error: line 13: %{tmpfiles_create_package meh more more}
[1] what has been tried: %{expand:%%if "%#" == 0 \\\
%%{error:you have given me %# args} \\\
%%endif}
[2] http://git.savannah.gnu.org/cgit/automake.git/commit/?id=e0bd4af16da88e4c2c61bde42675660eff7dff51
2019-03-20 14:48:47 +01:00
|
|
|
%__systemd_twoargs_2() %{nil}
|
|
|
|
|
2012-06-21 22:14:17 +02:00
|
|
|
%systemd_post() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_post}} \
|
|
|
|
if [ $1 -eq 1 ] && [ -x @bindir@/systemctl ]; then \
|
2012-06-21 22:14:17 +02:00
|
|
|
# Initial installation \
|
2019-03-20 10:58:41 +01:00
|
|
|
@bindir@/systemctl --no-reload preset %{?*} || : \
|
2012-06-21 22:14:17 +02:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2018-05-19 13:01:55 +02:00
|
|
|
%systemd_user_post() %{expand:%systemd_post \\--global %%{?*}}
|
2014-10-28 03:34:09 +01:00
|
|
|
|
2012-06-21 22:14:17 +02:00
|
|
|
%systemd_preun() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_preun}} \
|
|
|
|
if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ]; then \
|
2012-06-21 22:14:17 +02:00
|
|
|
# Package removal, not upgrade \
|
2019-03-20 10:58:41 +01:00
|
|
|
@bindir@/systemctl --no-reload disable --now %{?*} || : \
|
2012-06-21 22:14:17 +02:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2014-10-28 03:34:09 +01:00
|
|
|
%systemd_user_preun() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_preun}} \
|
|
|
|
if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ]; then \
|
2014-10-28 03:34:09 +01:00
|
|
|
# Package removal, not upgrade \
|
2019-03-20 10:58:41 +01:00
|
|
|
@bindir@/systemctl --global disable %{?*} || : \
|
2014-10-28 03:34:09 +01:00
|
|
|
fi \
|
|
|
|
%{nil}
|
|
|
|
|
2020-07-14 16:25:32 +02:00
|
|
|
%systemd_postun() \
|
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun}} \
|
|
|
|
%{nil}
|
2012-06-21 22:14:17 +02:00
|
|
|
|
2020-07-14 16:25:32 +02:00
|
|
|
%systemd_user_postun() \
|
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_postun}} \
|
|
|
|
%{nil}
|
2014-10-28 03:34:09 +01:00
|
|
|
|
2012-06-21 22:14:17 +02:00
|
|
|
%systemd_postun_with_restart() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \
|
|
|
|
if [ $1 -ge 1 ] && [ -x @bindir@/systemctl ]; then \
|
2012-06-21 22:14:17 +02:00
|
|
|
# Package upgrade, not uninstall \
|
2019-03-20 10:58:41 +01:00
|
|
|
@bindir@/systemctl try-restart %{?*} || : \
|
2012-06-21 22:14:17 +02:00
|
|
|
fi \
|
|
|
|
%{nil}
|
2012-11-16 19:54:19 +01:00
|
|
|
|
2020-07-14 16:25:32 +02:00
|
|
|
%systemd_user_postun_with_restart() \
|
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \
|
|
|
|
%{nil}
|
2014-10-28 03:34:09 +01:00
|
|
|
|
Add more file triggers to handle more aspects of systemd (#8090)
For quite a while now, there have been file triggers to handle
automatically setting up service units in upstream systemd. However,
most of the actions being done by these macros upon files can be set up
as RPM file triggers.
In fact, in Mageia, we had been doing this for most of these. In particular,
we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal.
This change adds Lua versions of the original file triggers used in Mageia,
based on the existing Lua-based file triggers for service units.
In addition, we can also have useful file triggers for udev rules, sysctl
directives, and binfmt directives. These are based on the other existing
file triggers.
2018-02-06 10:11:36 +01:00
|
|
|
%udev_hwdb_update() %{nil}
|
2012-11-16 19:54:19 +01:00
|
|
|
|
Add more file triggers to handle more aspects of systemd (#8090)
For quite a while now, there have been file triggers to handle
automatically setting up service units in upstream systemd. However,
most of the actions being done by these macros upon files can be set up
as RPM file triggers.
In fact, in Mageia, we had been doing this for most of these. In particular,
we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal.
This change adds Lua versions of the original file triggers used in Mageia,
based on the existing Lua-based file triggers for service units.
In addition, we can also have useful file triggers for udev rules, sysctl
directives, and binfmt directives. These are based on the other existing
file triggers.
2018-02-06 10:11:36 +01:00
|
|
|
%udev_rules_update() %{nil}
|
2012-11-16 19:54:19 +01:00
|
|
|
|
Add more file triggers to handle more aspects of systemd (#8090)
For quite a while now, there have been file triggers to handle
automatically setting up service units in upstream systemd. However,
most of the actions being done by these macros upon files can be set up
as RPM file triggers.
In fact, in Mageia, we had been doing this for most of these. In particular,
we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal.
This change adds Lua versions of the original file triggers used in Mageia,
based on the existing Lua-based file triggers for service units.
In addition, we can also have useful file triggers for udev rules, sysctl
directives, and binfmt directives. These are based on the other existing
file triggers.
2018-02-06 10:11:36 +01:00
|
|
|
%journal_catalog_update() %{nil}
|
2013-07-16 18:15:48 +02:00
|
|
|
|
2018-02-05 15:02:07 +01:00
|
|
|
# Deprecated. Use %tmpfiles_create_package instead
|
2013-07-16 18:15:48 +02:00
|
|
|
%tmpfiles_create() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# tmpfiles_create}} \
|
2019-03-20 10:58:41 +01:00
|
|
|
[ -x @bindir@/systemd-tmpfiles ] && @bindir@/systemd-tmpfiles --create %{?*} || : \
|
2013-07-16 18:15:48 +02:00
|
|
|
%{nil}
|
2014-06-13 19:18:55 +02:00
|
|
|
|
2018-01-31 16:07:59 +01:00
|
|
|
# Deprecated. Use %sysusers_create_package instead
|
2014-06-13 19:18:55 +02:00
|
|
|
%sysusers_create() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysusers_create}} \
|
2019-03-20 10:58:41 +01:00
|
|
|
[ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers %{?*} || : \
|
2014-06-13 19:18:55 +02:00
|
|
|
%{nil}
|
|
|
|
|
2014-08-19 02:16:27 +02:00
|
|
|
%sysusers_create_inline() \
|
2019-03-20 10:58:41 +01:00
|
|
|
[ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers - <<SYSTEMD_INLINE_EOF || : \
|
2018-03-19 18:05:49 +01:00
|
|
|
%{?*} \
|
2020-07-11 16:08:00 +02:00
|
|
|
SYSTEMD_INLINE_EOF\
|
2014-08-19 02:16:27 +02:00
|
|
|
%{nil}
|
|
|
|
|
2018-02-05 15:02:07 +01:00
|
|
|
# This should be used by package installation scripts which require users or
|
|
|
|
# groups to be present before the files installed by the package are present on
|
|
|
|
# disk (for example because some files are owned by those users or groups).
|
2018-01-31 16:07:59 +01:00
|
|
|
#
|
|
|
|
# Example:
|
2018-02-05 15:02:07 +01:00
|
|
|
# Source1: %{name}-sysusers.conf
|
2018-01-31 16:07:59 +01:00
|
|
|
# ...
|
|
|
|
# %install
|
2018-02-05 15:02:07 +01:00
|
|
|
# install -D %SOURCE1 %{buildroot}%{_sysusersdir}/%{name}.conf
|
2018-01-31 16:07:59 +01:00
|
|
|
# %pre
|
|
|
|
# %sysusers_create_package %{name} %SOURCE1
|
|
|
|
# %files
|
2018-02-05 15:02:07 +01:00
|
|
|
# %{_sysusersdir}/%{name}.conf
|
2018-01-31 16:07:59 +01:00
|
|
|
%sysusers_create_package() \
|
2020-07-14 16:30:46 +02:00
|
|
|
%{expand:%%{?!__systemd_twoargs_%#:%%{error:The %%%%sysusers_create_package macro requires two arguments}}} \
|
2020-07-11 16:13:54 +02:00
|
|
|
systemd-sysusers --replace=%_sysusersdir/%1.conf - <<SYSTEMD_INLINE_EOF || : \
|
2018-03-19 09:07:44 +01:00
|
|
|
%(cat %2) \
|
2020-07-11 16:08:00 +02:00
|
|
|
SYSTEMD_INLINE_EOF\
|
2018-01-31 16:07:59 +01:00
|
|
|
%{nil}
|
|
|
|
|
2018-02-05 15:02:07 +01:00
|
|
|
# This may be used by package installation scripts to create files according to
|
|
|
|
# their tmpfiles configuration from a package installation script, even before
|
|
|
|
# the files of that package are installed on disk.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# Source1: %{name}-tmpfiles.conf
|
|
|
|
# ...
|
|
|
|
# %install
|
|
|
|
# install -D %SOURCE1 %{buildroot}%{_tmpfilesdir}/%{name}.conf
|
|
|
|
# %pre
|
|
|
|
# %tmpfiles_create_package %{name} %SOURCE1
|
|
|
|
# %files
|
|
|
|
# %{_tmpfilesdir}/%{name}.conf
|
|
|
|
%tmpfiles_create_package() \
|
2020-07-14 16:30:46 +02:00
|
|
|
%{expand:%%{?!__systemd_twoargs_%#:%%{error:The %%%%tmpfiles_create_package macro requires two arguments}}} \
|
2020-07-11 16:13:54 +02:00
|
|
|
systemd-tmpfiles --replace=%_tmpfilesdir/%1.conf --create - <<SYSTEMD_INLINE_EOF || : \
|
2018-03-19 09:07:44 +01:00
|
|
|
%(cat %2) \
|
2020-07-11 16:08:00 +02:00
|
|
|
SYSTEMD_INLINE_EOF\
|
2018-02-05 15:02:07 +01:00
|
|
|
%{nil}
|
|
|
|
|
2014-06-13 19:18:55 +02:00
|
|
|
%sysctl_apply() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysctl_apply}} \
|
2019-03-20 10:58:41 +01:00
|
|
|
[ -x @rootlibexecdir@/systemd-sysctl ] && @rootlibexecdir@/systemd-sysctl %{?*} || : \
|
2014-06-13 19:18:55 +02:00
|
|
|
%{nil}
|
|
|
|
|
|
|
|
%binfmt_apply() \
|
2020-07-14 16:25:32 +02:00
|
|
|
%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# binfmt_apply}} \
|
2019-03-20 10:58:41 +01:00
|
|
|
[ -x @rootlibexecdir@/systemd-binfmt ] && @rootlibexecdir@/systemd-binfmt %{?*} || : \
|
2014-06-13 19:18:55 +02:00
|
|
|
%{nil}
|