1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-21 09:33:57 +03:00

build: preserve correct mode when generating files via jinja2

When using "capture : true" in custom_target()s the mode of the source
file is not preserved when the generated file is not installed and so
needs to be tweaked manually. Switch from output capture to creating the
target file and copy the permissions from the input file.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2021-11-05 14:29:53 +01:00 committed by Luca Boccassi
parent bf47f71c1c
commit a6d1760024
20 changed files with 26 additions and 41 deletions

View File

@ -4,7 +4,6 @@ custom_target(
'README',
input : 'README.in',
output : 'README',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : conf.get('HAVE_SYSV_COMPAT') == 1,
install_dir : sysvinit_path)

View File

@ -30,8 +30,7 @@ custom_entities_ent = custom_target(
'custom-entities.ent',
input : 'custom-entities.ent.in',
output : 'custom-entities.ent',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true)
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
man_pages = []
html_pages = []

View File

@ -52,8 +52,7 @@ foreach file : rules_in
file,
input : file + '.in',
output: file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : true,
install_dir : udevrulesdir)
endforeach

View File

@ -14,8 +14,7 @@ custom_target(
'systemctl',
input : 'systemctl.in',
output : 'systemctl',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : bashcompletiondir != 'no',
install_dir : bashcompletiondir)

View File

@ -9,8 +9,7 @@ custom_target(
'_systemctl',
input : '_systemctl.in',
output : '_systemctl',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : zshcompletiondir != 'no',
install_dir : zshcompletiondir)

View File

@ -149,8 +149,7 @@ load_fragment_gperf_gperf = custom_target(
'load-fragment-gperf.gperf',
input : 'load-fragment-gperf.gperf.in',
output: 'load-fragment-gperf.gperf',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true)
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
load_fragment_gperf_c = custom_target(
'load-fragment-gperf.c',
@ -202,8 +201,7 @@ foreach item : in_files
file,
input : file + '.in',
output: file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : (dir == pkgsysconfdir) ? install_sysconfdir_samples : (dir != 'no'),
install_dir : dir)
endforeach

View File

@ -54,8 +54,7 @@ foreach tuple : in_files
file,
input : file + '.in',
output: file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : tuple[1],
install_dir : pkgsysconfdir)
endforeach

View File

@ -183,8 +183,7 @@ custom_target(
'libsystemd.pc',
input : 'libsystemd.pc.in',
output : 'libsystemd.pc',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : pkgconfiglibdir != 'no',
install_dir : pkgconfiglibdir)

View File

@ -43,8 +43,7 @@ custom_target(
'libudev.pc',
input : 'libudev.pc.in',
output : 'libudev.pc',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : pkgconfiglibdir != 'no',
install_dir : pkgconfiglibdir)

View File

@ -81,8 +81,7 @@ foreach tuple : in_files
file,
input : file + '.in',
output: file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : tuple[2] and install,
install_dir : dir)
endforeach

View File

@ -166,8 +166,7 @@ custom_target(
'resolved.conf',
input : 'resolved.conf.in',
output : 'resolved.conf',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
install_dir : pkgsysconfdir)

View File

@ -18,8 +18,7 @@ foreach tuple : in_files
file,
input : file + '.in',
output : file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : tuple[1],
install_dir : tuple.length() > 2 ? tuple[2] : '',
install_mode : tuple.length() > 3 ? tuple[3] : false,

View File

@ -38,8 +38,7 @@ custom_target(
'timesyncd.conf',
input : 'timesyncd.conf.in',
output : 'timesyncd.conf',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_TIMESYNCD') == 1 and install_sysconfdir_samples,
install_dir : pkgsysconfdir)

View File

@ -162,8 +162,7 @@ custom_target(
'udev.pc',
input : 'udev.pc.in',
output : 'udev.pc',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : pkgconfigdatadir != 'no',
install_dir : pkgconfigdatadir)

View File

@ -4,7 +4,6 @@ custom_target(
'90-vconsole.rules',
input : '90-vconsole.rules.in',
output : '90-vconsole.rules',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_VCONSOLE') == 1,
install_dir : udevrulesdir)

View File

@ -16,8 +16,7 @@ custom_target(
'50-coredump.conf',
input : '50-coredump.conf.in',
output : '50-coredump.conf',
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : conf.get('ENABLE_COREDUMP') == 1,
install_dir : sysctldir)

View File

@ -33,8 +33,7 @@ foreach tuple : in_files
file,
input : file + '.in',
output: file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : tuple[1],
install_dir : sysusersdir)
endforeach

View File

@ -40,8 +40,7 @@ foreach pair : in_files
pair[0],
input : pair[0] + '.in',
output: pair[0],
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : enable_tmpfiles,
install_dir : tmpfilesdir)
else

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
import ast
import os
import re
import sys
@ -27,4 +28,8 @@ def render(filename, defines):
if __name__ == '__main__':
defines = parse_config_h(sys.argv[1])
print(render(sys.argv[2], defines))
output = render(sys.argv[2], defines)
with open(sys.argv[3], 'w') as f:
f.write(output)
info = os.stat(sys.argv[2])
os.chmod(sys.argv[3], info.st_mode)

View File

@ -272,8 +272,7 @@ foreach tuple : in_units
file,
input : file + '.in',
output : file,
command : [meson_render_jinja2, config_h, '@INPUT@'],
capture : true,
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
install : install,
install_dir : systemunitdir)