From 29f218d9dcf79bbad66d89455c8c5c7566dc1f88 Mon Sep 17 00:00:00 2001 From: Sayafdine Said Date: Tue, 12 Sep 2023 22:37:53 +0200 Subject: [PATCH] build: templatize autocomplete and pam-config --- howdy/src/autocomplete/{howdy => howdy.in} | 4 +++- howdy/src/meson.build | 27 ++++++++++++++++++++++ howdy/src/pam-config/howdy | 6 ----- howdy/src/pam-config/howdy.in | 6 +++++ meson.build | 2 +- meson.options | 3 ++- 6 files changed, 39 insertions(+), 9 deletions(-) rename howdy/src/autocomplete/{howdy => howdy.in} (86%) delete mode 100644 howdy/src/pam-config/howdy create mode 100644 howdy/src/pam-config/howdy.in diff --git a/howdy/src/autocomplete/howdy b/howdy/src/autocomplete/howdy.in similarity index 86% rename from howdy/src/autocomplete/howdy rename to howdy/src/autocomplete/howdy.in index 0ee737c3..38d4fed2 100755 --- a/howdy/src/autocomplete/howdy +++ b/howdy/src/autocomplete/howdy.in @@ -4,6 +4,8 @@ _howdy() { local cur prev opts + local config_path="@config_path@" + source _variables COMPREPLY=() # The argument typed so far cur="${COMP_WORDS[COMP_CWORD]}" @@ -20,7 +22,7 @@ _howdy() { ;; # For disable, grab the current "disabled" config option and give the reverse "disable") - local status=$(cut -d'=' -f2 <<< $(cat /etc/howdy/config.ini | grep 'disabled =') | xargs echo -n) + local status=$(cut -d'=' -f2 <<< $(cat $config_path | grep 'disabled =') | xargs echo -n) [ "$status" == "false" ] && COMPREPLY="true" || COMPREPLY="false" return 0 diff --git a/howdy/src/meson.build b/howdy/src/meson.build index 57a6e70c..65339513 100644 --- a/howdy/src/meson.build +++ b/howdy/src/meson.build @@ -53,6 +53,21 @@ pam_module_conf_data = configuration_data(paths_dict) pam_module_conf_data.set('compare_script_path', join_paths(pysourcesinstalldir, 'compare.py')) pam_module_conf_data.set('config_file_path', config_path) subdir('pam') +if get_option('install_pam_config') + # pamdir is inherited from the pam subproject + pam_config = configure_file( + input: 'pam-config/howdy.in', + output: 'pam-config', + configuration: {'pamdir': pamdir} + ) + install_data( + pam_config, + install_dir: get_option('prefix') / get_option('datadir') / 'pam-configs', + install_mode: 'rwxr-xr-x', + install_tag: 'pam', + rename: 'howdy', + ) +endif if get_option('install_in_site_packages') py.install_sources( @@ -73,6 +88,18 @@ else endif install_data('logo.png', install_tag: 'meta') +autocomplete = configure_file( + input: 'autocomplete/howdy.in', + output: 'autocomplete', + configuration: configuration_data({ 'config_path': config_path }) +) +install_data( + autocomplete, + install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'bash-completion', 'completions'), + install_mode: 'rwxr--r--', + install_tag: 'bash_completion', + rename: 'howdy', +) fs = import('fs') if not fs.exists(config_path) diff --git a/howdy/src/pam-config/howdy b/howdy/src/pam-config/howdy deleted file mode 100644 index ed190397..00000000 --- a/howdy/src/pam-config/howdy +++ /dev/null @@ -1,6 +0,0 @@ -Name: Howdy -Default: yes -Priority: 512 -Auth-Type: Primary -Auth: - [success=end default=ignore] /lib/security/howdy/pam_howdy.so diff --git a/howdy/src/pam-config/howdy.in b/howdy/src/pam-config/howdy.in new file mode 100644 index 00000000..b447b258 --- /dev/null +++ b/howdy/src/pam-config/howdy.in @@ -0,0 +1,6 @@ +Name: Howdy +Default: yes +Priority: 512 +Auth-Type: Primary +Auth: + [success=end default=ignore] @pamdir@/pam_howdy.so diff --git a/meson.build b/meson.build index d6cffff6..c2150dfc 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('howdy', 'cpp', license: 'MIT', version: 'beta', meson_version: '>= 0.64.0') +dlibdatadir = get_option('dlib_data_dir') != '' ? get_option('dlib_data_dir') : join_paths(get_option('prefix'), get_option('datadir'), 'dlib-data') confdir = get_option('config_dir') != '' ? get_option('config_dir') : join_paths(get_option('prefix'), get_option('sysconfdir'), 'howdy') -dlibdatadir = get_option('dlib_data_dir') != '' ? get_option('dlib_data_dir') : join_paths(confdir, 'dlib-data') usermodelsdir = get_option('user_models_dir') != '' ? get_option('user_models_dir') : join_paths(confdir, 'models') logpath = get_option('log_path') diff --git a/meson.options b/meson.options index bd4318a7..1a35b819 100644 --- a/meson.options +++ b/meson.options @@ -5,4 +5,5 @@ option('dlib_data_dir', type: 'string', value: '', description: 'Set the dlib da option('user_models_dir', type: 'string', value: '', description: 'Set the user models directory') option('log_path', type: 'string', value: '/var/log/howdy', description: 'Set the log file path') option('install_in_site_packages', type: 'boolean', value: false, description: 'Install howdy python files in site packages') -option('py_sources_dir', type: 'string', value: '', description: 'Set the python sources directory') \ No newline at end of file +option('py_sources_dir', type: 'string', value: '', description: 'Set the python sources directory') +option('install_pam_config', type: 'boolean', value: false, description: 'Install pam config file (for Debian/Ubuntu)') \ No newline at end of file