meson: use jinja2 in shell-completion/

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-05-16 18:34:23 +02:00 committed by Yu Watanabe
parent 8f127e161e
commit 5908656c57
4 changed files with 83 additions and 81 deletions

View file

@ -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

View file

@ -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; }; }

View file

@ -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[@]}"

View file

@ -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