]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
build: preserve correct mode when generating files via jinja2
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 5 Nov 2021 13:29:53 +0000 (14:29 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 8 Nov 2021 12:06:48 +0000 (12:06 +0000)
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>
20 files changed:
docs/sysvinit/meson.build
man/meson.build
rules.d/meson.build
shell-completion/bash/meson.build
shell-completion/zsh/meson.build
src/core/meson.build
src/journal-remote/meson.build
src/libsystemd/meson.build
src/libudev/meson.build
src/login/meson.build
src/resolve/meson.build
src/rpm/meson.build
src/timesync/meson.build
src/udev/meson.build
src/vconsole/meson.build
sysctl.d/meson.build
sysusers.d/meson.build
tmpfiles.d/meson.build
tools/meson-render-jinja2.py
units/meson.build

index 0a1935388abae0415a5c433cbd401911ba37d603..cd3015ca4b4954c9236303c8a43246b9a9ea33b0 100644 (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)
index f259ab8eb4f66abf57f55e1508dac47161f5f001..a06a60176707def5d386ad9705fb40a25d6a43a6 100644 (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 = []
index 05c55a6b41e4d84144970003b32224dcf8de1df6..5cecddb34f668bf9e962589876fd2babd8bfec0a 100644 (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
index 1196795814e2a464079e681fdb0cbb9c6bdc9a81..c6668e5ea33e31bc07363dc9de4c7a2e06612464 100644 (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)
 
index 31d9a39ccfc70504cab8e78a1d84ccf4ca22df55..a0615c4df97f707d9f5c3d867c9e43e4c043caa0 100644 (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)
 
index de7c2ae798e7d9f18fc54bbbd2b012607dee39b3..c02543bd062f7f079efb9e98296c889b04b3df92 100644 (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
index 5670d55ec5502e88711ea7d9295a5d305cac2e38..54b314552b4d666f36ede7a1e3d134f465153369 100644 (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
index 02b2cd64b2b3e5e43f07d57da9d9ad854a5bfcb9..6ee78fd195521fd7b6b4b47ed095902c0b6f5f4a 100644 (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)
 
index 130374d14fb0f743f8abc9c4be9fab60fbbcb40a..488ae6248097256d17bc96024d3d0b0623742344 100644 (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)
 
index da704d238fe47e95afc995441d67ceffc0445f11..a583025a1bc67d2435ae0f5f93bc8e95b4c98de1 100644 (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
index 1f9b8af4f3fcbf2e93fb89db88e6fe50453788d2..c7cb88ac04bb77e885436a38b01c992b6c59a8b4 100644 (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)
 
index 2ad3308cc1c6dc0310dda990767bc44c246d4a81..8decb11f3bee1c57cbe189bbb88c24b37fb9c047 100644 (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,
index ec80b16e8291e5fa1df52dfe1b9fc6571befb860..6d6ddeb28545fad2515263dda8f763c329f37940 100644 (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)
 
index 3423d6de9469a8a1ef2be3b4b2b9bf16ba1ed244..0b692df3d8a72aa21399f699cdc07f3037f37216 100644 (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)
 
index dea4121f1a7e5c200b7d7118486daad43f94f2b4..eb22358c20530824cf223a9e32e6172c5940665f 100644 (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)
index b058f9364bee9e18ade68544d7f900d1044c1e05..1745a13bfbd2bdac81447968b726e5b29200a8e9 100644 (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)
 
index 132d8a187af83209332eb0157baee1418a7aa35f..73d507f1f15fb6e10b1d99e11c16d59e8c2999c4 100644 (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
index de36f5743d0921b11665fba1b9e29e70e871c2bd..6ae9e3e0b859fe818c4a04af3db62b88f4ed61a0 100644 (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
index 9a6fc7c31c88eccf02484138d2ab7d2e04b3c0e5..0f9fc431243006fd45ae597c35b64fa4a5334fcf 100755 (executable)
@@ -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)
index c106284e0fd2b41d2ccb73a6f65369de8a0a27be..903443a85df7f7cdbc4cfac7fd3b328083d275fc 100644 (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)