This commit is contained in:
Gerben Jan Dijkman 2024-08-04 13:51:13 +02:00
parent a22eb04f90
commit d374795d2e
3 changed files with 103 additions and 89 deletions

View File

@ -0,0 +1,27 @@
diff --git a/meson.build b/meson.build
index ff4fcb515489758ffea10a3e8c6bf3b0a16b2575..a1e8e6a44c6cf0a1b5589e5a438ca9aeeb674617 100644
--- a/meson.build
+++ b/meson.build
@@ -111,16 +111,13 @@ x11_dep = dependency('x11')
xfixes_dep = dependency('xfixes', version: '>= 6.0')
enable_systemd = get_option('systemd')
-if enable_systemd
- systemd_dep = dependency('systemd', version: '>= 243', required: false)
- assert(systemd_dep.found(), 'Systemd support explicitly required, but systemd not found')
-
- libsystemd_dep = dependency('libsystemd', version: '>= 243', required: false)
- assert(libsystemd_dep.found(), 'Systemd support explicitly required, but libsystemd not found')
-
- systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir',
- define_variable: ['prefix', gsd_prefix])
+systemd_dep = dependency('systemd', version: '>= 243', required: enable_systemd)
+if systemd_dep.found()
+ systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir',
+ define_variable: ['prefix', gsd_prefix])
endif
+libsystemd_dep = dependency('libsystemd', version: '>= 243', required: enable_systemd)
+
m_dep = cc.find_library('m')

View File

@ -1,97 +1,83 @@
From 1a4d50f4ee611bdede6072c0bfd2a1b2e327c5fc Mon Sep 17 00:00:00 2001 diff --git a/meson.build b/meson.build
From: Dudemanguy <random342@airmail.cc> index deecd3f1e68b615d7a699ad8f0a29d60daffd1de..e07fa841b750cf6551ff510d03e87322d7f4cb26 100644
Date: Mon, 25 Mar 2024 10:39:30 -0500 --- a/meson.build
Subject: [PATCH] sharing: fix building without systemd +++ b/meson.build
@@ -111,13 +111,20 @@ x11_dep = dependency('x11')
xfixes_dep = dependency('xfixes', version: '>= 6.0')
0bfc60813befb45e3dd4840795839806f5310e39 introduced a bunch of enable_systemd = get_option('systemd')
systemd-specific stuff that broke building without systemd. Guard all of -systemd_dep = dependency('systemd', version: '>= 243', required: enable_systemd)
the relevant things. -if systemd_dep.found()
--- - systemd_userunitdir = systemd_dep.get_variable(pkgconfig: 'systemduserunitdir',
plugins/sharing/gsd-sharing-manager.c | 12 +++++++++++- - pkgconfig_define: ['prefix', gsd_prefix])
1 file changed, 11 insertions(+), 1 deletion(-) +enable_elogind = get_option('elogind')
+
+if enable_systemd and enable_elogind
+ error('Only systemd or elogind support should be activated')
+elif enable_systemd
+ systemd_dep = dependency('systemd', version: '>= 243', required: true)
+ libsystemd_dep = dependency('libsystemd', version: '>= 243', required: true)
+ systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir',
+ define_variable: ['prefix', gsd_prefix])
+elif enable_elogind
+ elogind_dep = dependency('libelogind', version: '>= 209', required: true)
endif
-libsystemd_dep = dependency('libsystemd', version: '>= 243', required: enable_systemd)
+config_h.set10('HAVE_SYSTEMD_LIB', enable_systemd or enable_elogind)
m_dep = cc.find_library('m')
diff --git a/meson_options.txt b/meson_options.txt
index 1d913b4d29d7e4af54b3381c4dbed71366175ec3..5e2cccab651ee873fd34dcdd0a7b826d7316291d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,6 @@
option('udev_dir', type: 'string', value: '', description: 'Absolute path of the udev base directory')
option('systemd', type: 'boolean', value: true, description: 'Enable systemd integration')
-
+option('elogind', type: 'boolean', value: false, description: 'Use elogind')
option('alsa', type: 'boolean', value: true, description: 'build with ALSA support (not optional on Linux platforms)')
option('gudev', type: 'boolean', value: true, description: 'build with gudev device support (not optional on Linux platforms)')
option('cups', type: 'boolean', value: true, description: 'build with CUPS support')
diff --git a/plugins/sharing/gsd-sharing-manager.c b/plugins/sharing/gsd-sharing-manager.c diff --git a/plugins/sharing/gsd-sharing-manager.c b/plugins/sharing/gsd-sharing-manager.c
index c669e7bde..8b818c4e4 100644 index 2ab2cb054f8dbbaa2d2198b0c90e62c0f1e975c2..c669e7bdebb651ed3ffa2cb78a2eb84907c2ae7c 100644
--- a/plugins/sharing/gsd-sharing-manager.c --- a/plugins/sharing/gsd-sharing-manager.c
+++ b/plugins/sharing/gsd-sharing-manager.c +++ b/plugins/sharing/gsd-sharing-manager.c
@@ -266,6 +266,7 @@ gsd_sharing_manager_sync_configurable_services (GsdSharingManager *manager) @@ -20,12 +20,15 @@
} #include "config.h"
#include <locale.h>
-#include <systemd/sd-login.h>
#include <glib.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <glib/gstdio.h>
+#if HAVE_SYSTEMD_LIB +#if HAVE_SYSTEMD_LIB
static void +#include <systemd/sd-login.h>
on_assigned_service_finished (GPid pid,
int exit_status,
@@ -406,10 +407,12 @@ stop_assigned_service_after_timeout (GsdSharingManager *manager,
timeout_source,
G_SOURCE_FUNC (on_timeout_reached));
}
+#endif +#endif
+
#if HAVE_NETWORK_MANAGER
#include <NetworkManager.h>
#endif /* HAVE_NETWORK_MANAGER */
diff --git a/plugins/sharing/meson.build b/plugins/sharing/meson.build
index bda21608a589385e3436e60b999f55e778065d53..c65c4f9a5c41d5c6eb3168d4624083d8ab2c4bc1 100644
--- a/plugins/sharing/meson.build
+++ b/plugins/sharing/meson.build
@@ -6,9 +6,14 @@ sources = files(
deps = plugins_deps + [
gio_unix_dep,
libnotify_dep,
- libsystemd_dep
]
static void +if enable_systemd
gsd_sharing_manager_sync_assigned_services (GsdSharingManager *manager) + deps += libsystemd_dep
{ +elif enable_elogind
+#if HAVE_SYSTEMD_LIB + deps += elogind_dep
GList *services, *l; +endif
+
services = g_hash_table_get_values (manager->assigned_services); if enable_network_manager
@@ -423,6 +426,7 @@ gsd_sharing_manager_sync_assigned_services (GsdSharingManager *manager) deps += libnm_dep
start_assigned_service (manager, info); endif
}
g_list_free (services);
+#endif
}
static void
@@ -1004,6 +1008,7 @@ assigned_service_free (gpointer pointer)
g_free (info);
}
+#if HAVE_SYSTEMD_LIB
static void
on_system_bus_name_appeared (GDBusConnection *connection,
const char *system_bus_name,
@@ -1046,6 +1051,7 @@ on_system_bus_name_vanished (GDBusConnection *connection,
stop_assigned_service_after_timeout (manager, info);
}
+#endif
static void
manage_configurable_services (GsdSharingManager *manager)
@@ -1069,6 +1075,7 @@ manage_configurable_services (GsdSharingManager *manager)
static void
manage_assigned_services (GsdSharingManager *manager)
{
+#if HAVE_SYSTEMD_LIB
size_t i;
int ret;
g_autofree char *session_id = NULL;
@@ -1129,12 +1136,13 @@ manage_assigned_services (GsdSharingManager *manager)
g_hash_table_insert (manager->assigned_services, (gpointer) service->system_bus_name, info);
}
+#endif
}
static void
gsd_sharing_manager_init (GsdSharingManager *manager)
{
- int ret;
+ int ret = -1;
g_autofree char *systemd_unit = NULL;
manager->configurable_services = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, configurable_service_free);
@@ -1146,7 +1154,9 @@ gsd_sharing_manager_init (GsdSharingManager *manager)
manager->carrier_type = g_strdup ("");
manager->sharing_status = GSD_SHARING_STATUS_OFFLINE;
+#if HAVE_SYSTEMD_LIB
ret = sd_pid_get_user_unit (getpid (), &systemd_unit);
+#endif
if (ret < 0)
manager->is_systemd_managed = FALSE;
--
GitLab

View File

@ -105,6 +105,7 @@ src_configure() {
local emesonargs=( local emesonargs=(
-Dudev_dir="$(get_udevdir)" -Dudev_dir="$(get_udevdir)"
$(meson_use systemd) $(meson_use systemd)
$(meson_use elogind)
-Dalsa=true -Dalsa=true
-Dgudev=true -Dgudev=true
-Dgcr3=false -Dgcr3=false