From: Zbigniew Jędrzejewski-Szmek Date: Sun, 16 May 2021 16:34:23 +0000 (+0200) Subject: meson: use jinja2 in shell-completion/ X-Git-Tag: v249-rc1~210^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5908656c5737bf900b9c6826b45b4e0d43fc9577;p=thirdparty%2Fsystemd.git meson: use jinja2 in shell-completion/ --- diff --git a/shell-completion/bash/meson.build b/shell-completion/bash/meson.build index 1afa7977e66..c26b413d926 100644 --- a/shell-completion/bash/meson.build +++ b/shell-completion/bash/meson.build @@ -10,45 +10,45 @@ if bashcompletiondir == '' endif endif -if bashcompletiondir != 'no' - bash_systemctl = configure_file( - input : 'systemctl.in', - output : 'systemctl', - configuration : substs) +custom_target( + 'systemctl', + input : 'systemctl.in', + output : 'systemctl', + command : [meson_render_jinja2, config_h, '@INPUT@'], + capture : true, + install : bashcompletiondir != 'no', + install_dir : bashcompletiondir) - items = [['busctl', ''], - ['journalctl', ''], - ['systemd-analyze', ''], - ['systemd-cat', ''], - ['systemd-cgls', ''], - ['systemd-cgtop', ''], - ['systemd-delta', ''], - ['systemd-detect-virt', ''], - ['systemd-id128', ''], - ['systemd-nspawn', ''], - ['systemd-path', ''], - ['systemd-run', ''], - ['udevadm', ''], - ['kernel-install', ''], - [bash_systemctl, ''], - ['bootctl', 'ENABLE_EFI'], - ['coredumpctl', 'ENABLE_COREDUMP'], - ['homectl', 'ENABLE_HOMED'], - ['hostnamectl', 'ENABLE_HOSTNAMED'], - ['localectl', 'ENABLE_LOCALED'], - ['loginctl', 'ENABLE_LOGIND'], - ['machinectl', 'ENABLE_MACHINED'], - ['networkctl', 'ENABLE_NETWORKD'], - ['portablectl', 'ENABLE_PORTABLED'], - ['resolvectl', 'ENABLE_RESOLVE'], - ['systemd-resolve', 'ENABLE_RESOLVE'], - ['timedatectl', 'ENABLE_TIMEDATED'], - ] +items = [['busctl', ''], + ['journalctl', ''], + ['systemd-analyze', ''], + ['systemd-cat', ''], + ['systemd-cgls', ''], + ['systemd-cgtop', ''], + ['systemd-delta', ''], + ['systemd-detect-virt', ''], + ['systemd-id128', ''], + ['systemd-nspawn', ''], + ['systemd-path', ''], + ['systemd-run', ''], + ['udevadm', ''], + ['kernel-install', ''], + ['bootctl', 'ENABLE_EFI'], + ['coredumpctl', 'ENABLE_COREDUMP'], + ['homectl', 'ENABLE_HOMED'], + ['hostnamectl', 'ENABLE_HOSTNAMED'], + ['localectl', 'ENABLE_LOCALED'], + ['loginctl', 'ENABLE_LOGIND'], + ['machinectl', 'ENABLE_MACHINED'], + ['networkctl', 'ENABLE_NETWORKD'], + ['portablectl', 'ENABLE_PORTABLED'], + ['resolvectl', 'ENABLE_RESOLVE'], + ['systemd-resolve', 'ENABLE_RESOLVE'], + ['timedatectl', 'ENABLE_TIMEDATED']] - foreach item : items - if item[1] == '' or conf.get(item[1]) == 1 - install_data(item[0], - install_dir : bashcompletiondir) - endif - endforeach -endif +foreach item : items + if bashcompletiondir != 'no' and (item[1] == '' or conf.get(item[1]) == 1) + install_data(item[0], + install_dir : bashcompletiondir) + endif +endforeach diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index c25a8d94c25..e6e6ca0d7e0 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -11,7 +11,7 @@ __systemctl() { } __systemd_properties() { - @rootlibexecdir@/systemd --dump-bus-properties + {{ROOTLIBEXECDIR}}/systemd --dump-bus-properties } __contains_word () { @@ -21,6 +21,7 @@ __contains_word () { done } +{% raw -%} __filter_units_by_properties () { local mode=$1 properties=$2; shift 2 local units=("$@") @@ -50,6 +51,7 @@ __filter_units_by_properties () { echo $names fi } +{% endraw %} __get_all_units () { { __systemctl $1 list-unit-files "$2*"; __systemctl $1 list-units --all "$2*"; } \ | { while read -r a b; do echo " $a"; done; }; } diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in index 5e82ef7e1f6..9eb1ad10375 100644 --- a/shell-completion/zsh/_systemctl.in +++ b/shell-completion/zsh/_systemctl.in @@ -433,7 +433,7 @@ done if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) || ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr; then - _sys_all_properties=( ${${(M)${(f)"$(@rootlibexecdir@/systemd --dump-bus-properties)"}}} ) + _sys_all_properties=( ${${(M)${(f)"$({{ROOTLIBEXECDIR}}/systemd --dump-bus-properties)"}}} ) _store_cache SYS_ALL_PROPERTIES$_sys_service_mgr _sys_all_properties fi _values -s , "${_sys_all_properties[@]}" diff --git a/shell-completion/zsh/meson.build b/shell-completion/zsh/meson.build index 4fff13357f6..f5f9b0f993f 100644 --- a/shell-completion/zsh/meson.build +++ b/shell-completion/zsh/meson.build @@ -5,44 +5,44 @@ if zshcompletiondir == '' zshcompletiondir = join_paths(datadir, 'zsh/site-functions') endif -if zshcompletiondir != 'no' - zsh_systemctl = configure_file( - input : '_systemctl.in', - output : '_systemctl', - configuration : substs) +custom_target( + '_systemctl', + input : '_systemctl.in', + output : '_systemctl', + command : [meson_render_jinja2, config_h, '@INPUT@'], + capture : true, + install : zshcompletiondir != 'no', + install_dir : zshcompletiondir) - items = [['_busctl', ''], - ['_journalctl', ''], - ['_systemd-analyze', ''], - ['_systemd-delta', ''], - ['_systemd-nspawn', ''], - ['_systemd', ''], - ['_systemd-path', ''], - ['_systemd-run', ''], - ['_udevadm', ''], - ['_kernel-install', ''], - ['_sd_hosts_or_user_at_host', ''], - ['_sd_outputmodes', ''], - ['_sd_unit_files', ''], - ['_sd_machines', ''], - [zsh_systemctl, ''], - ['_bootctl', 'ENABLE_EFI'], - ['_coredumpctl', 'ENABLE_COREDUMP'], - ['_hostnamectl', 'ENABLE_HOSTNAMED'], - ['_localectl', 'ENABLE_LOCALED'], - ['_loginctl', 'ENABLE_LOGIND'], - ['_machinectl', 'ENABLE_MACHINED'], - ['_networkctl', 'ENABLE_NETWORKD'], - ['_systemd-inhibit', 'ENABLE_LOGIND'], - ['_resolvectl', 'ENABLE_RESOLVE'], - ['_systemd-tmpfiles', 'ENABLE_TMPFILES'], - ['_timedatectl', 'ENABLE_TIMEDATED'], - ] +items = [['_busctl', ''], + ['_journalctl', ''], + ['_systemd-analyze', ''], + ['_systemd-delta', ''], + ['_systemd-nspawn', ''], + ['_systemd', ''], + ['_systemd-path', ''], + ['_systemd-run', ''], + ['_udevadm', ''], + ['_kernel-install', ''], + ['_sd_hosts_or_user_at_host', ''], + ['_sd_outputmodes', ''], + ['_sd_unit_files', ''], + ['_sd_machines', ''], + ['_bootctl', 'ENABLE_EFI'], + ['_coredumpctl', 'ENABLE_COREDUMP'], + ['_hostnamectl', 'ENABLE_HOSTNAMED'], + ['_localectl', 'ENABLE_LOCALED'], + ['_loginctl', 'ENABLE_LOGIND'], + ['_machinectl', 'ENABLE_MACHINED'], + ['_networkctl', 'ENABLE_NETWORKD'], + ['_systemd-inhibit', 'ENABLE_LOGIND'], + ['_resolvectl', 'ENABLE_RESOLVE'], + ['_systemd-tmpfiles', 'ENABLE_TMPFILES'], + ['_timedatectl', 'ENABLE_TIMEDATED']] - foreach item : items - if item[1] == '' or conf.get(item[1]) == 1 - install_data(item[0], - install_dir : zshcompletiondir) - endif - endforeach -endif +foreach item : items + if zshcompletiondir != 'no' and (item[1] == '' or conf.get(item[1]) == 1) + install_data(item[0], + install_dir : zshcompletiondir) + endif +endforeach