summaryrefslogtreecommitdiff
path: root/sysusers.d
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-16 11:55:36 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-05-19 10:24:43 +0900
commit6b1aac3ccf3a554011a1a6030672fa5b5c4b4f77 (patch)
treed35120a1c59911b103e5a07b21469fae7c76fe53 /sysusers.d
parente0698c66f4569c91e3fdd54ca77449698ae38704 (diff)
downloadsystemd-6b1aac3ccf3a554011a1a6030672fa5b5c4b4f77.tar.gz
meson: replace some m4 templates with jinja2
m4 was nice in '85, but the syntax feels a bit dated. Since we use python for meson, let's use a popular python templating engine to replace some m4 usage. A little nicety is that typos are caught: FAILED: sysusers.d/systemd-remote.conf /usr/bin/meson --internal exe --capture sysusers.d/systemd-remote.conf -- /home/zbyszek/src/systemd/tools/meson-render-jinja2.py config.h ../sysusers.d/systemd-remote.conf.j2 Traceback (most recent call last): File "/home/zbyszek/src/systemd/tools/meson-render-jinja2.py", line 28, in <module> print(render(sys.argv[2], defines)) File "/home/zbyszek/src/systemd/tools/meson-render-jinja2.py", line 24, in render return template.render(defines) File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render self.environment.handle_exception() File "/usr/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception reraise(*rewrite_traceback_stack(source=source)) File "/usr/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise raise value.with_traceback(tb) File "<template>", line 8, in top-level template code jinja2.exceptions.UndefinedError: 'HAVE_MICROHTTP' is undefined This checking mirrors what 349cc4a507c4d84fcadf61f42159ea6412717896 did for C defines.
Diffstat (limited to 'sysusers.d')
-rw-r--r--sysusers.d/basic.conf.in6
-rw-r--r--sysusers.d/meson.build33
-rw-r--r--sysusers.d/systemd-remote.conf.in (renamed from sysusers.d/systemd-remote.conf.m4)4
-rw-r--r--sysusers.d/systemd.conf.in (renamed from sysusers.d/systemd.conf.m4)20
4 files changed, 25 insertions, 38 deletions
diff --git a/sysusers.d/basic.conf.in b/sysusers.d/basic.conf.in
index 4be0bd869e..9da0251421 100644
--- a/sysusers.d/basic.conf.in
+++ b/sysusers.d/basic.conf.in
@@ -9,7 +9,7 @@
u root 0 "Super User" /root
# The nobody user for NFS file systems
-u @NOBODY_USER_NAME@ 65534 "Nobody" -
+u {{NOBODY_USER_NAME}} 65534 "Nobody" -
# Administrator group: can *see* more than normal users
g adm - - -
@@ -19,7 +19,7 @@ g wheel - - -
# Access to certain kernel and userspace facilities
g kmem - - -
-g tty @TTY_GID@ - -
+g tty {{TTY_GID}} - -
g utmp - - -
# Hardware access groups
@@ -36,4 +36,4 @@ g tape - - -
g video - - -
# Default group for normal users
-g users @USERS_GID@ - -
+g users {{USERS_GID}} - -
diff --git a/sysusers.d/meson.build b/sysusers.d/meson.build
index ef809a4f44..894d1840bc 100644
--- a/sysusers.d/meson.build
+++ b/sysusers.d/meson.build
@@ -4,32 +4,19 @@ if enable_sysusers
install_data('README', install_dir : sysusersdir)
endif
-in_files = ['basic.conf']
+in_files = [['basic.conf', enable_sysusers],
+ ['systemd.conf', enable_sysusers],
+ ['systemd-remote.conf', enable_sysusers and
+ conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1]]
-foreach file : in_files
- gen = configure_file(
- input : file + '.in',
- output : file,
- configuration : substs)
- if enable_sysusers
- install_data(gen,
- install_dir : sysusersdir)
- endif
-endforeach
-
-m4_files = ['systemd.conf']
-
-if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
- m4_files += ['systemd-remote.conf']
-endif
-
-foreach file : m4_files
+foreach tuple : in_files
+ file = tuple[0]
custom_target(
- 'sysusers.d_' + file,
- input : file + '.m4',
+ file,
+ input : file + '.in',
output: file,
- command : [meson_apply_m4, config_h, '@INPUT@'],
+ command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
- install : enable_sysusers,
+ install : tuple[1],
install_dir : sysusersdir)
endforeach
diff --git a/sysusers.d/systemd-remote.conf.m4 b/sysusers.d/systemd-remote.conf.in
index 988917672b..dae1077225 100644
--- a/sysusers.d/systemd-remote.conf.m4
+++ b/sysusers.d/systemd-remote.conf.in
@@ -5,6 +5,6 @@
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
-m4_ifdef(`HAVE_MICROHTTPD',
+{% if HAVE_MICROHTTPD %}
u systemd-journal-remote - "systemd Journal Remote"
-)m4_dnl
+{% endif %}
diff --git a/sysusers.d/systemd.conf.m4 b/sysusers.d/systemd.conf.in
index fdfdcf553c..9905eb596c 100644
--- a/sysusers.d/systemd.conf.m4
+++ b/sysusers.d/systemd.conf.in
@@ -6,18 +6,18 @@
# (at your option) any later version.
g systemd-journal - -
-m4_ifdef(`ENABLE_NETWORKD',
+{% if ENABLE_NETWORKD %}
u systemd-network - "systemd Network Management"
-)m4_dnl
-m4_ifdef(`ENABLE_OOMD',
+{% endif %}
+{% if ENABLE_OOMD %}
u systemd-oom - "systemd Userspace OOM Killer"
-)m4_dnl
-m4_ifdef(`ENABLE_RESOLVE',
+{% endif %}
+{% if ENABLE_RESOLVE %}
u systemd-resolve - "systemd Resolver"
-)m4_dnl
-m4_ifdef(`ENABLE_TIMESYNCD',
+{% endif %}
+{% if ENABLE_TIMESYNCD %}
u systemd-timesync - "systemd Time Synchronization"
-)m4_dnl
-m4_ifdef(`ENABLE_COREDUMP',
+{% endif %}
+{% if ENABLE_COREDUMP %}
u systemd-coredump - "systemd Core Dumper"
-)m4_dnl
+{% endif %}