[Openvpn-devel] Configurable installation directories

Message ID CAOrkh=Vw_5rLO=Ny4RKMUfjVAhoAD36SyeZj0EjZfwnqHaL2QQ@mail.gmail.com
State New
Delegated to: David Sommerseth
Headers show
Series [Openvpn-devel] Configurable installation directories | expand

Commit Message

Petr Portnov Sept. 24, 2024, 1:26 p.m. UTC
Hi there!
Continuing the packaging of the latest OpenVPN-linux for NixOS, I would
like to propose the following addition to the build system.

What it does is it allows you to customize the installation paths for DBus
and systemd services and adds the option to disable the generation of
`openvpn3_statedir / 'configs'` directory (which is not always desired,
e.g. when the OS takes this responsibility).

~ Petr Portnov

Comments

David Sommerseth Sept. 30, 2024, 10:35 a.m. UTC | #1
On 24/09/2024 15:26, Petr Portnov wrote:
> Hi there!
> Continuing the packaging of the latest OpenVPN-linux for NixOS, I would 
> like to propose the following addition to the build system.
> 
> What it does is it allows you to customize the installation paths for 
> DBus and systemd services and adds the option to disable the generation 
> of `openvpn3_statedir / 'configs'` directory (which is not always 
> desired, e.g. when the OS takes this responsibility).

That's again, Petr!

I'm going to pull this into the coming v24 release.  I'll keep you 
posted on the progress here.

Your changes makes sense, so I don't expect any issues here.  Going to 
test it a bit first, though.
Petr Portnov Sept. 30, 2024, 2:16 p.m. UTC | #2
Glad to hear it, thanks for your response!
As for the release: is there any planned date for v24? Or, as an
alternative, could the previous asio-related patch
(75abb7dc9366ba85fb1a144d88f02a1e8a62f538) and this one be cherry-picked on
top of v23 tag and be release as something like v23.1 so that there is no
need to wait for v24 to have this specific changes?

PS: accidentally sent it to personal mail only without sending it to the
mailing list, thus resending it.

пн, 30 сент. 2024 г. в 13:35, David Sommerseth <dazo+openvpn@eurephia.org>:

> On 24/09/2024 15:26, Petr Portnov wrote:
> > Hi there!
> > Continuing the packaging of the latest OpenVPN-linux for NixOS, I would
> > like to propose the following addition to the build system.
> >
> > What it does is it allows you to customize the installation paths for
> > DBus and systemd services and adds the option to disable the generation
> > of `openvpn3_statedir / 'configs'` directory (which is not always
> > desired, e.g. when the OS takes this responsibility).
>
> That's again, Petr!
>
> I'm going to pull this into the coming v24 release.  I'll keep you
> posted on the progress here.
>
> Your changes makes sense, so I don't expect any issues here.  Going to
> test it a bit first, though.
>
>
> --
> kind regards,
>
> David Sommerseth
> OpenVPN Inc
>
>
>

Patch

From 848cc46d05c203de393d75434a3f571d78687f50 Mon Sep 17 00:00:00 2001
From: Petr Portnov <mrjarviscraft@gmail.com>
Date: Sun, 22 Sep 2024 13:16:02 +0300
Subject: [PATCH] build: allow installation directories' customization

This allows to configure the installation directories
for systemd and D-Bus files.

Signed-off-by: Petr Portnov <mrjarviscraft@gmail.com>
---
 distro/systemd/meson.build |  9 +++++++--
 meson.build                | 12 ++++++++++--
 meson_options.txt          | 12 ++++++++++++
 src/configmgr/meson.build  | 10 ++++++----
 4 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/distro/systemd/meson.build b/distro/systemd/meson.build
index 36d556c..9c636b6 100644
--- a/distro/systemd/meson.build
+++ b/distro/systemd/meson.build
@@ -15,12 +15,17 @@  systemd_cfg = configuration_data({
 
 systemd_service_cfg = dependency('systemd')
 
+systemd_system_unit_dir = get_option('systemd_system_unit_dir')
+if systemd_system_unit_dir == ''
+  systemd_system_unit_dir = systemd_service_cfg.get_variable('systemdsystemunitdir')
+endif
+
 configure_file(
     input: 'openvpn3-autoload.service.in',
     output: 'openvpn3-autoload.service',
     configuration: systemd_cfg,
     install: true,
-    install_dir: systemd_service_cfg.get_variable('systemdsystemunitdir'),
+    install_dir: systemd_system_unit_dir,
 )
 
 configure_file(
@@ -28,7 +33,7 @@  configure_file(
     output: 'openvpn3-session@.service',
     configuration: systemd_cfg,
     install: true,
-    install_dir: systemd_service_cfg.get_variable('systemdsystemunitdir'),
+    install_dir: systemd_system_unit_dir,
 )
 
 custom_target('openvpn3-systemd',
diff --git a/meson.build b/meson.build
index 586c72a..ba41440 100644
--- a/meson.build
+++ b/meson.build
@@ -203,8 +203,16 @@  message('OpenVPN 3 Linux service binary directory: ' + get_option('prefix') / li
 
 #
 #  D-Bus configuration
-dbus_policy_dir = dep_dbus.get_variable('datadir') / 'dbus-1' / 'system.d'
-dbus_service_dir = dep_dbus.get_variable('system_bus_services_dir')
+dbus_policy_dir = get_option('dbus_policy_dir')
+if dbus_policy_dir == ''
+    dbus_policy_dir = dep_dbus.get_variable('datadir') / 'dbus-1' / 'system.d'
+endif
+
+dbus_service_dir = get_option('dbus_system_service_dir')
+if dbus_service_dir == ''
+    dbus_service_dir = dep_dbus.get_variable('system_bus_services_dir')
+endif
+
 dbus_config = {
     'OPENVPN_USERNAME': get_option('openvpn_username'),
     'LIBEXEC_PATH': get_option('prefix') / libexec_dir,
diff --git a/meson_options.txt b/meson_options.txt
index 43e301e..04809df 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -93,6 +93,18 @@  option('use-legacy-polkit-pkla', type: 'feature', value: 'disabled',
 option('polkit_pkla_rulesdir', type: 'string', value: '',
        description: 'Override PolicyKit PKLA rules directory')
 
+#
+# Installation
+#
+option('dbus_policy_dir', type: 'string',
+       description: 'D-Bus policy directory')
+option('dbus_system_service_dir', type: 'string',
+       description: 'D-Bus system service directory')
+option('systemd_system_unit_dir', type: 'string',
+       description: 'Path to systemd system unit directory')
+option('create_statedir', type: 'feature', value: 'enabled',
+       description: 'Create directory for OpenVPN 3 state during install phase')
+
 #
 #  Testing tools
 #
diff --git a/src/configmgr/meson.build b/src/configmgr/meson.build
index 5d0a649..6f788b7 100644
--- a/src/configmgr/meson.build
+++ b/src/configmgr/meson.build
@@ -52,7 +52,9 @@  configure_file(
     install_dir: dbus_service_dir,
 )
 
-# Create the configs directory for persistent configuration profiles
-# NOTE: Can be replaced with install_emptydir() when Meson 0.60 or newer
-#       is available on all supported distros
-meson.add_install_script('sh','-c', 'mkdir -p $DESTDIR@0@'.format(openvpn3_statedir / 'configs'))
+if get_option('create_statedir').enabled()
+    # Create the configs directory for persistent configuration profiles
+    # NOTE: Can be replaced with install_emptydir() when Meson 0.60 or newer
+    #       is available on all supported distros
+    meson.add_install_script('sh','-c', 'mkdir -p $DESTDIR@0@'.format(openvpn3_statedir / 'configs'))
+endif
-- 
2.45.2