summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2021-11-05 14:29:53 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2021-11-08 12:06:48 +0000
commita6d1760024d0884efb343e1c739f303619f7c8b9 (patch)
treec8dbba36a1918327990537b23aefe1b54941fd12
parentbf47f71c1cd36c2b0eb5aeac4d8bdf58c67f2b33 (diff)
downloadsystemd-a6d1760024d0884efb343e1c739f303619f7c8b9.tar.gz
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>
-rw-r--r--docs/sysvinit/meson.build3
-rw-r--r--man/meson.build3
-rw-r--r--rules.d/meson.build3
-rw-r--r--shell-completion/bash/meson.build3
-rw-r--r--shell-completion/zsh/meson.build3
-rw-r--r--src/core/meson.build6
-rw-r--r--src/journal-remote/meson.build3
-rw-r--r--src/libsystemd/meson.build3
-rw-r--r--src/libudev/meson.build3
-rw-r--r--src/login/meson.build3
-rw-r--r--src/resolve/meson.build3
-rw-r--r--src/rpm/meson.build3
-rw-r--r--src/timesync/meson.build3
-rw-r--r--src/udev/meson.build3
-rw-r--r--src/vconsole/meson.build3
-rw-r--r--sysctl.d/meson.build3
-rw-r--r--sysusers.d/meson.build3
-rw-r--r--tmpfiles.d/meson.build3
-rwxr-xr-xtools/meson-render-jinja2.py7
-rw-r--r--units/meson.build3
20 files changed, 26 insertions, 41 deletions
diff --git a/docs/sysvinit/meson.build b/docs/sysvinit/meson.build
index 0a1935388a..cd3015ca4b 100644
--- a/docs/sysvinit/meson.build
+++ b/docs/sysvinit/meson.build
@@ -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)
diff --git a/man/meson.build b/man/meson.build
index f259ab8eb4..a06a601767 100644
--- a/man/meson.build
+++ b/man/meson.build
@@ -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 = []
diff --git a/rules.d/meson.build b/rules.d/meson.build
index 05c55a6b41..5cecddb34f 100644
--- a/rules.d/meson.build
+++ b/rules.d/meson.build
@@ -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
diff --git a/shell-completion/bash/meson.build b/shell-completion/bash/meson.build
index 1196795814..c6668e5ea3 100644
--- a/shell-completion/bash/meson.build
+++ b/shell-completion/bash/meson.build
@@ -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)
diff --git a/shell-completion/zsh/meson.build b/shell-completion/zsh/meson.build
index 31d9a39ccf..a0615c4df9 100644
--- a/shell-completion/zsh/meson.build
+++ b/shell-completion/zsh/meson.build
@@ -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)
diff --git a/src/core/meson.build b/src/core/meson.build
index de7c2ae798..c02543bd06 100644
--- a/src/core/meson.build
+++ b/src/core/meson.build
@@ -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
diff --git a/src/journal-remote/meson.build b/src/journal-remote/meson.build
index 5670d55ec5..54b314552b 100644
--- a/src/journal-remote/meson.build
+++ b/src/journal-remote/meson.build
@@ -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
diff --git a/src/libsystemd/meson.build b/src/libsystemd/meson.build
index 02b2cd64b2..6ee78fd195 100644
--- a/src/libsystemd/meson.build
+++ b/src/libsystemd/meson.build
@@ -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)
diff --git a/src/libudev/meson.build b/src/libudev/meson.build
index 130374d14f..488ae62480 100644
--- a/src/libudev/meson.build
+++ b/src/libudev/meson.build
@@ -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)
diff --git a/src/login/meson.build b/src/login/meson.build
index da704d238f..a583025a1b 100644
--- a/src/login/meson.build
+++ b/src/login/meson.build
@@ -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
diff --git a/src/resolve/meson.build b/src/resolve/meson.build
index 1f9b8af4f3..c7cb88ac04 100644
--- a/src/resolve/meson.build
+++ b/src/resolve/meson.build
@@ -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)
diff --git a/src/rpm/meson.build b/src/rpm/meson.build
index 2ad3308cc1..8decb11f3b 100644
--- a/src/rpm/meson.build
+++ b/src/rpm/meson.build
@@ -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,
diff --git a/src/timesync/meson.build b/src/timesync/meson.build
index ec80b16e82..6d6ddeb285 100644
--- a/src/timesync/meson.build
+++ b/src/timesync/meson.build
@@ -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)
diff --git a/src/udev/meson.build b/src/udev/meson.build
index 3423d6de94..0b692df3d8 100644
--- a/src/udev/meson.build
+++ b/src/udev/meson.build
@@ -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)
diff --git a/src/vconsole/meson.build b/src/vconsole/meson.build
index dea4121f1a..eb22358c20 100644
--- a/src/vconsole/meson.build
+++ b/src/vconsole/meson.build
@@ -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)
diff --git a/sysctl.d/meson.build b/sysctl.d/meson.build
index b058f9364b..1745a13bfb 100644
--- a/sysctl.d/meson.build
+++ b/sysctl.d/meson.build
@@ -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)
diff --git a/sysusers.d/meson.build b/sysusers.d/meson.build
index 132d8a187a..73d507f1f1 100644
--- a/sysusers.d/meson.build
+++ b/sysusers.d/meson.build
@@ -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
diff --git a/tmpfiles.d/meson.build b/tmpfiles.d/meson.build
index de36f5743d..6ae9e3e0b8 100644
--- a/tmpfiles.d/meson.build
+++ b/tmpfiles.d/meson.build
@@ -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
diff --git a/tools/meson-render-jinja2.py b/tools/meson-render-jinja2.py
index 9a6fc7c31c..0f9fc43124 100755
--- a/tools/meson-render-jinja2.py
+++ b/tools/meson-render-jinja2.py
@@ -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)
diff --git a/units/meson.build b/units/meson.build
index c106284e0f..903443a85d 100644
--- a/units/meson.build
+++ b/units/meson.build
@@ -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)