X Tutup
Skip to content

Commit 059cc61

Browse files
keszybzyuwata
authored andcommitted
meson: use jinja2 for unit templates
We don't need two (and half) templating systems anymore, yay! I'm keeping the changes minimal, to make the diff manageable. Some enhancements due to a better templating system might be possible in the future. For handling of '## ' — see the next commit.
1 parent 6b1aac3 commit 059cc61

File tree

65 files changed

+133
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+133
-160
lines changed

meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ conf.set_quoted('SYSTEMD_SHUTDOWN_BINARY_PATH', join_paths(rootlib
242242
conf.set_quoted('SYSTEMCTL_BINARY_PATH', join_paths(rootbindir, 'systemctl'))
243243
conf.set_quoted('SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH', join_paths(rootbindir, 'systemd-tty-ask-password-agent'))
244244
conf.set_quoted('SYSTEMD_STDIO_BRIDGE_BINARY_PATH', join_paths(bindir, 'systemd-stdio-bridge'))
245+
conf.set_quoted('ROOTBINDIR', rootbindir)
245246
conf.set_quoted('ROOTPREFIX', rootprefixdir)
246247
conf.set_quoted('ROOTPREFIX_NOSLASH', rootprefixdir_noslash)
247248
conf.set_quoted('RANDOM_SEED_DIR', randomseeddir)
@@ -842,6 +843,7 @@ substs.set('TTY_GID', tty_gid)
842843

843844
# Ensure provided GID argument is numeric, otherwise fall back to default assignment
844845
users_gid = get_option('users-gid')
846+
conf.set('USERS_GID', users_gid < 0 ? '-' : users_gid)
845847
substs.set('USERS_GID', users_gid < 0 ? '-' : users_gid)
846848

847849
conf.set10('ENABLE_ADM_GROUP', get_option('adm-group'))
@@ -887,14 +889,17 @@ if localegen_path != ''
887889
writable = ' /usr/lib/locale'
888890
endif
889891
substs.set('SERVICE_LOCALEGEN_WRITABLE', writable)
892+
conf.set_quoted('SERVICE_LOCALEGEN_WRITABLE', writable)
890893
conf.set10('HAVE_LOCALEGEN', have)
891894

892895
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
893896

894897
service_watchdog = get_option('service-watchdog')
895898
watchdog_value = service_watchdog == '' ? '' : 'WatchdogSec=' + service_watchdog
896899
substs.set('SERVICE_WATCHDOG', watchdog_value)
900+
conf.set_quoted('SERVICE_WATCHDOG', watchdog_value)
897901

902+
conf.set_quoted('SUSHELL', get_option('debug-shell'))
898903
substs.set('SUSHELL', get_option('debug-shell'))
899904
substs.set('DEBUGTTY', get_option('debug-tty'))
900905
conf.set_quoted('DEBUGTTY', get_option('debug-tty'))
@@ -3741,7 +3746,7 @@ status = [
37413746
'debug shell: @0@ @ @1@'.format(get_option('debug-shell'),
37423747
get_option('debug-tty')),
37433748
'TTY GID: @0@'.format(tty_gid),
3744-
'users GID: @0@'.format(substs.get('USERS_GID')),
3749+
'users GID: @0@'.format(conf.get('USERS_GID')),
37453750
'system UIDs: <=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
37463751
conf.get('SYSTEM_ALLOC_UID_MIN')),
37473752
'system GIDs: <=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
Description=Console Getty
1212
Documentation=man:agetty(8) man:systemd-getty-generator(8)
1313
After=systemd-user-sessions.service plymouth-quit-wait.service
14-
m4_ifdef(`HAVE_SYSV_COMPAT',
14+
{% if HAVE_SYSV_COMPAT %}
1515
After=rc-local.service getty-pre.target
16-
)m4_dnl
16+
{% endif %}
1717
Before=getty.target
1818

1919
# OCI containers may be run without a console
@@ -30,9 +30,9 @@ UtmpIdentifier=cons
3030
TTYPath=/dev/console
3131
TTYReset=yes
3232
TTYVHangup=yes
33-
m4_ifdef(`ENABLE_LOGIND',,
33+
{% if not ENABLE_LOGIND %}
3434
KillMode=process
35-
)m4_dnl
35+
{% endif %}
3636
IgnoreSIGPIPE=no
3737
SendSIGHUP=yes
3838

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Description=Container Getty on /dev/pts/%I
1212
Documentation=man:agetty(8) man:systemd-getty-generator(8)
1313
Documentation=man:machinectl(1)
1414
After=systemd-user-sessions.service plymouth-quit-wait.service
15-
m4_ifdef(`HAVE_SYSV_COMPAT',
15+
{% if HAVE_SYSV_COMPAT %}
1616
After=rc-local.service getty-pre.target
17-
)m4_dnl
17+
{% endif %}
1818
Before=getty.target
1919
IgnoreOnIsolate=yes
2020
ConditionPathExists=/dev/pts/%I
@@ -36,8 +36,8 @@ UtmpIdentifier=pts/%I
3636
TTYPath=/dev/pts/%I
3737
TTYReset=yes
3838
TTYVHangup=yes
39-
m4_ifdef(`ENABLE_LOGIND',,
39+
{% if not ENABLE_LOGIND %}
4040
KillMode=process
41-
)m4_dnl
41+
{% endif %}
4242
IgnoreSIGPIPE=no
4343
SendSIGHUP=yes

units/debug-shell.service.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
# (at your option) any later version.
99

1010
[Unit]
11-
Description=Early root shell on @DEBUGTTY@ FOR DEBUGGING ONLY
11+
Description=Early root shell on {{DEBUGTTY}} FOR DEBUGGING ONLY
1212
Documentation=man:systemd-debug-generator(8)
1313
DefaultDependencies=no
1414
IgnoreOnIsolate=yes
15-
ConditionPathExists=@DEBUGTTY@
15+
ConditionPathExists={{DEBUGTTY}}
1616

1717
[Service]
1818
Environment=TERM=linux
19-
ExecStart=@SUSHELL@
19+
ExecStart={{SUSHELL}}
2020
Restart=always
2121
RestartSec=0
2222
StandardInput=tty
23-
TTYPath=@DEBUGTTY@
23+
TTYPath={{DEBUGTTY}}
2424
TTYReset=yes
2525
TTYVHangup=yes
2626
KillMode=process

units/emergency.service.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Before=rescue.service
1919
[Service]
2020
Environment=HOME=/root
2121
WorkingDirectory=-/root
22-
ExecStartPre=-@rootbindir@/plymouth --wait quit
23-
ExecStart=-@rootlibexecdir@/systemd-sulogin-shell emergency
22+
ExecStartPre=-{{ROOTBINDIR}}/plymouth --wait quit
23+
ExecStart=-{{ROOTLIBEXECDIR}}/systemd-sulogin-shell emergency
2424
Type=idle
2525
StandardInput=tty-force
2626
StandardOutput=inherit
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Description=Getty on %I
1212
Documentation=man:agetty(8) man:systemd-getty-generator(8)
1313
Documentation=http://0pointer.de/blog/projects/serial-console.html
1414
After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target
15-
m4_ifdef(`HAVE_SYSV_COMPAT',
15+
{% if HAVE_SYSV_COMPAT %}
1616
After=rc-local.service
17-
)m4_dnl
17+
{% endif %}
1818

1919
# If additional gettys are spawned during boot then we should make
2020
# sure that this is synchronized before getty.target, even though
@@ -47,9 +47,9 @@ TTYPath=/dev/%I
4747
TTYReset=yes
4848
TTYVHangup=yes
4949
TTYVTDisallocate=yes
50-
m4_ifdef(`ENABLE_LOGIND',,
50+
{% if not ENABLE_LOGIND %}
5151
KillMode=process
52-
)m4_dnl
52+
{% endif %}
5353
IgnoreSIGPIPE=no
5454
SendSIGHUP=yes
5555

units/kmod-static-nodes.service.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ ConditionFileNotEmpty=/lib/modules/%v/modules.devname
1717
[Service]
1818
Type=oneshot
1919
RemainAfterExit=yes
20-
ExecStart=@KMOD@ static-nodes --format=tmpfiles --output=/run/tmpfiles.d/static-nodes.conf
20+
ExecStart={{KMOD}} static-nodes --format=tmpfiles --output=/run/tmpfiles.d/static-nodes.conf

units/meson.build

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,18 @@ units = [
165165
]
166166

167167
in_units = [
168+
['console-getty.service', ''],
169+
['container-getty@.service', ''],
168170
['debug-shell.service', ''],
169171
['emergency.service', ''],
172+
['getty@.service', '',
173+
'autovt@.service'],
170174
['kmod-static-nodes.service', 'HAVE_KMOD ENABLE_TMPFILES',
171175
'sysinit.target.wants/'],
172176
['quotaon.service', 'ENABLE_QUOTACHECK'],
173177
['rc-local.service', 'HAVE_SYSV_COMPAT'],
174178
['rescue.service', ''],
179+
['serial-getty@.service', ''],
175180
['systemd-backlight@.service', 'ENABLE_BACKLIGHT'],
176181
['systemd-binfmt.service', 'ENABLE_BINFMT',
177182
'sysinit.target.wants/'],
@@ -247,14 +252,6 @@ in_units = [
247252
['user@.service', ''],
248253
]
249254

250-
m4_units = [
251-
['console-getty.service', ''],
252-
['container-getty@.service', ''],
253-
['getty@.service', '',
254-
'autovt@.service '],
255-
['serial-getty@.service', ''],
256-
]
257-
258255
add_wants = []
259256

260257
foreach tuple : in_units
@@ -265,15 +262,11 @@ foreach tuple : in_units
265262
install = ((conds.get(0, '') == '' or conf.get(conds[0]) == 1) and
266263
(conds.get(1, '') == '' or conf.get(conds[1]) == 1))
267264

268-
gen1 = configure_file(
269-
input : file + '.in',
270-
output : file + '.tmp',
271-
configuration : substs)
272-
gen2 = custom_target(
265+
custom_target(
273266
file,
274-
input : gen1,
267+
input : file + '.in',
275268
output : file,
276-
command : [sed, '/^## /d', '@INPUT@'],
269+
command : [meson_render_jinja2, config_h, '@INPUT@'],
277270
capture : true,
278271
install : install,
279272
install_dir : systemunitdir)
@@ -285,31 +278,6 @@ foreach tuple : in_units
285278
endif
286279
endforeach
287280

288-
foreach tuple : m4_units
289-
file = tuple[0]
290-
input = tuple.get(3, file + '.m4')
291-
292-
# we do this here because install_data does not accept custom_target output
293-
conds = tuple[1].split(' ')
294-
install = ((conds.get(0, '') == '' or conf.get(conds[0]) == 1) and
295-
(conds.get(1, '') == '' or conf.get(conds[1]) == 1))
296-
297-
custom_target(
298-
file,
299-
input : input,
300-
output: file,
301-
command : [meson_apply_m4, config_h, '@INPUT@'],
302-
capture : true,
303-
install : install,
304-
install_dir : systemunitdir)
305-
306-
if tuple.length() > 2 and install
307-
foreach target : tuple[2].split()
308-
add_wants += [systemunitdir, target, file]
309-
endforeach
310-
endif
311-
endforeach
312-
313281
foreach tuple : units
314282
file = tuple[0]
315283
input = tuple.get(3, file)

units/quotaon.service.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Documentation=man:quotaon(8)
1313
DefaultDependencies=no
1414
After=systemd-quotacheck.service
1515
Before=remote-fs.target shutdown.target
16-
ConditionPathExists=@QUOTAON@
16+
ConditionPathExists={{QUOTAON}}
1717

1818
[Service]
1919
Type=oneshot
2020
RemainAfterExit=yes
21-
ExecStart=@QUOTAON@ -aug
21+
ExecStart={{QUOTAON}} -aug

units/rc-local.service.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
# (at your option) any later version.
99

1010
# This unit gets pulled automatically into multi-user.target by
11-
# systemd-rc-local-generator if @RC_LOCAL_PATH@ is executable.
11+
# systemd-rc-local-generator if {{RC_LOCAL_PATH}} is executable.
1212
[Unit]
13-
Description=@RC_LOCAL_PATH@ Compatibility
13+
Description={{RC_LOCAL_PATH}} Compatibility
1414
Documentation=man:systemd-rc-local-generator(8)
15-
ConditionFileIsExecutable=@RC_LOCAL_PATH@
15+
ConditionFileIsExecutable={{RC_LOCAL_PATH}}
1616
After=network.target
1717

1818
[Service]
1919
Type=forking
20-
ExecStart=@RC_LOCAL_PATH@ start
20+
ExecStart={{RC_LOCAL_PATH}} start
2121
TimeoutSec=0
2222
RemainAfterExit=yes
2323
GuessMainPID=no

0 commit comments

Comments
 (0)
X Tutup