From: Tomas Krizek Date: Tue, 18 Jun 2019 14:53:37 +0000 (+0200) Subject: meson: properly detect libsystemd dependency X-Git-Tag: v4.1.0~17^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7944a24d162726eb14d834d06956cdda4762ec41;p=thirdparty%2Fknot-resolver.git meson: properly detect libsystemd dependency --- diff --git a/daemon/main.c b/daemon/main.c index 83d101bb3..3237b8f18 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -27,7 +27,7 @@ #include #include -#ifdef HAS_SYSTEMD +#if SYSTEMD_VERSION > 0 #include #endif #include @@ -445,7 +445,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se memcpy(&engine->ipc_set, ipc_set, sizeof(*ipc_set)); /* Notify supervisor. */ -#ifdef HAS_SYSTEMD +#if SYSTEMD_VERSION > 0 sd_notify(0, "READY=1"); #endif /* Run event loop */ @@ -457,7 +457,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se return EXIT_SUCCESS; } -#ifdef HAS_SYSTEMD +#if SYSTEMD_VERSION >= 227 static void free_sd_socket_names(char **socket_names, int count) { for (int i = 0; i < count; i++) { @@ -670,7 +670,7 @@ int main(int argc, char **argv) ret = bind_sockets(&args.addrs_tls, true, &args.fds); if (ret) goto cleanup_args; -#ifdef HAS_SYSTEMD +#if SYSTEMD_VERSION >= 227 /* Accept passed sockets from systemd supervisor. */ char **socket_names = NULL; int sd_nsocks = sd_listen_fds_with_names(0, &socket_names); diff --git a/meson.build b/meson.build index 4d9d96b4f..4d901fbb9 100644 --- a/meson.build +++ b/meson.build @@ -85,9 +85,10 @@ group = get_option('group') ## Systemd message('--- systemd socket activation ---') -libsystemd = dependency('libsystemd', version: '>=227', required: false) +libsystemd = dependency('libsystemd', required: false) systemd_files = get_option('systemd_files') -if systemd_files == 'enabled' and not libsystemd.found() +if systemd_files == 'enabled' and ( + not libsystemd.found() or libsystemd.version().version_compare('<227')) error('systemd_files=enabled requires libsystemd >= 227') endif message('---------------------------') @@ -133,7 +134,8 @@ conf_data.set_quoted('libzscanner_SONAME', libzscanner.get_pkgconfig_variable('soname')) conf_data.set_quoted('libknot_SONAME', libknot.get_pkgconfig_variable('soname')) -conf_data.set('HAS_SYSTEMD', libsystemd.found()) +conf_data.set('SYSTEMD_VERSION', + libsystemd.found() ? libsystemd.version().to_int() : -1) conf_data.set('NOVERBOSELOG', not verbose_log) kresconfig = configure_file( diff --git a/systemd/nosocket/kresd@.service.in b/systemd/nosocket/kresd@.service.in index d5be474ed..284473362 100644 --- a/systemd/nosocket/kresd@.service.in +++ b/systemd/nosocket/kresd@.service.in @@ -4,7 +4,7 @@ Documentation=man:kresd.systemd.nosocket(7) Documentation=man:kresd(8) [Service] -Type=simple +Type=notify WorkingDirectory=@systemd_work_dir@ ExecStart=@sbin_dir@/kresd --config=@etc_dir@/kresd.conf --forks=1 Restart=on-abnormal