Skip to content

Commit

Permalink
build: templatize autocomplete and pam-config
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsay-so committed Sep 12, 2023
1 parent 5133d05 commit 29f218d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions howdy/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions howdy/src/pam-config/howdy

This file was deleted.

6 changes: 6 additions & 0 deletions howdy/src/pam-config/howdy.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Name: Howdy
Default: yes
Priority: 512
Auth-Type: Primary
Auth:
[success=end default=ignore] @pamdir@/pam_howdy.so
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
3 changes: 2 additions & 1 deletion meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -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')
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)')

0 comments on commit 29f218d

Please sign in to comment.