From 87017faf86e6fcc51ddfcb51022ce2bfa91bdd0c Mon Sep 17 00:00:00 2001 From: Sayafdine Said Date: Sun, 25 Jun 2023 11:21:01 +0200 Subject: [PATCH] fix: use build options to configure paths --- howdy/src/meson.build | 55 ++++++++++++++++++++++++++------------- howdy/src/meson.options | 10 +++++-- howdy/src/pam/meson.build | 5 +++- 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/howdy/src/meson.build b/howdy/src/meson.build index bb127a5..f99137a 100644 --- a/howdy/src/meson.build +++ b/howdy/src/meson.build @@ -1,15 +1,15 @@ -project('howdy', 'cpp', license: 'MIT', license_files: '../LICENSE', version: 'beta', meson_version: '>= 1.1.0') +project('howdy', 'cpp', license: 'MIT', license_files: '../../LICENSE', version: 'beta', meson_version: '>= 1.1.0') py = import('python').find_installation() py.dependency() -confdir = join_paths(get_option('sysconfdir'), 'howdy') -dlibdatadir = join_paths(confdir, 'dlib-data') -usermodelsdir = join_paths(confdir, 'models') -logpath = '/var/log/howdy' +confdir = get_option('config_dir') != '' ? get_option('config_dir') : join_paths(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') py_conf = configuration_data({ - 'config_dir': confdir, + 'config_dir': confdir, 'dlib_data_dir': dlibdatadir, 'user_models_dir': usermodelsdir, 'log_path': logpath, @@ -48,18 +48,40 @@ py_sources = [ ] # Include PAM module -compare_script_path = join_paths(py.get_install_dir(), 'howdy', 'compare.py') +if get_option('install_in_site_packages') + pysourcesinstalldir = join_paths(py.get_install_dir(), 'howdy') +else + pysourcesinstalldir = get_option('py_sources_dir') != '' ? get_option('py_sources_dir') : join_paths(get_option('prefix'), get_option('libdir'), 'howdy') +endif + +compare_script_path = join_paths(pysourcesinstalldir, 'compare.py') subdir('pam') -py.install_sources( - py_sources, - subdir: 'howdy', - preserve_path: true, -) +if get_option('install_in_site_packages') + py.install_sources( + py_sources, + subdir: 'howdy', + preserve_path: true, + install_mode: 'r--r--r--', + install_tag: 'py_sources', + ) +else + install_data( + py_sources, + preserve_path: true, + install_dir: pysourcesinstalldir, + install_mode: 'r--r--r--', + install_tag: 'py_sources', + ) +endif install_data('logo.png', install_tag: 'meta') -install_data('config.ini', install_dir: confdir, install_mode: 'rwxr--r--', install_tag: 'config') +fs = import('fs') +config_path = join_paths(confdir, 'config.ini') +if not fs.exists(config_path) + install_data('config.ini', install_dir: confdir, install_mode: 'rwxr--r--', install_tag: 'config') +endif install_data('dlib-data/install.sh', install_dir: dlibdatadir, install_mode: 'rwxr--r--') @@ -109,21 +131,18 @@ install_man('../howdy.1') # endif -py_path = py.get_install_dir() -cli_path = join_paths(py_path, 'howdy', 'cli.py') - +cli_path = join_paths(pysourcesinstalldir, 'cli.py') conf_data = configuration_data({ 'script_path': cli_path }) bin_name = 'howdy' - bin = configure_file( input: 'bin/howdy.in', output: bin_name, configuration: conf_data ) - install_data( bin, install_mode: 'rwxr-xr-x', install_dir: get_option('bindir'), + install_tag: 'bin', ) \ No newline at end of file diff --git a/howdy/src/meson.options b/howdy/src/meson.options index 0586054..bd4318a 100644 --- a/howdy/src/meson.options +++ b/howdy/src/meson.options @@ -1,2 +1,8 @@ -option('pam_dir', type: 'string', value: '/lib/security', description: 'Set the pam_howdy destination directory') -#option('fetch_dlib_data', type: 'boolean', value: false, description: 'Download dlib data files') \ No newline at end of file +option('pam_dir', type: 'string', value: '', description: 'Set the pam_howdy destination directory') +#option('fetch_dlib_data', type: 'boolean', value: false, description: 'Download dlib data files') +option('config_dir', type: 'string', value: '', description: 'Set the howdy config directory') +option('dlib_data_dir', type: 'string', value: '', description: 'Set the dlib data directory') +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 diff --git a/howdy/src/pam/meson.build b/howdy/src/pam/meson.build index 3cb0161..39959dc 100644 --- a/howdy/src/pam/meson.build +++ b/howdy/src/pam/meson.build @@ -16,6 +16,8 @@ paths_h = configure_file( install_dir: get_option('pam_dir') ) +pamdir = get_option('pam_dir') != '' ? get_option('pam_dir') : join_paths(get_option('libdir'), 'security') + shared_library( 'pam_howdy', 'main.cc', @@ -30,6 +32,7 @@ shared_library( paths_h, ], install: true, - install_dir: get_option('pam_dir'), + install_dir: pamdir, + install_tag: 'pam_module', name_prefix: '' )