File bug-1233655_configure-add-option-disable-enable-sd-notify-and-au.patch of Package lvm2.41259

From c8b216d2fc4f3cabcf607b43ff52b1870d41e170 Mon Sep 17 00:00:00 2001
From: Su Yue <glass.su@suse.com>
Date: Mon, 9 Dec 2024 11:03:32 +0800
Subject: [PATCH] configure: add option disable/enable-sd-notify and autoreconf

This commit contains backports of upstream:

commit d8726b07c33fd9779c731fb5fcdef4accd8ed8b6
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Fri Dec 6 17:13:24 2024 +0100

    lvmlockd: utilize SD_NOTIFY_SUPPORT

    Update makefile and code to better utilize SD_NOTIFY_SUPPORT var.

commit ee97c5c6334df4bfc523be375bcc3ce580be4357
Author: Su Yue <glass.su@suse.com>
Date:   Tue Nov 26 14:23:04 2024 +0800

    configure.ac: add option disable/enable-sd-notify

commit 2b82e882edcbc0c92ea285a60b5436f881535d9c
Author: Zdenek Kabelac <zkabelac@redhat.com>
Date:   Fri Dec 6 17:02:24 2024 +0100

    configure: autoreconf

There are many conflicts of file configure between v2_03_22 and
futher v2_03_29 so here solve conflicts manually.

Signed-off-by: Su Yue <glass.su@suse.com>
---
 configure                        | 48 +++++++++++++++++++++++++++++++-
 configure.ac                     | 20 ++++++++++++-
 daemons/lvmlockd/Makefile.in     |  6 ++--
 daemons/lvmlockd/lvmlockd-core.c |  4 +--
 include/configure.h.in           |  3 ++
 5 files changed, 74 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 0bb5b3dbc6ca..8fc1edd8fa14 100755
--- a/configure
+++ b/configure
@@ -683,6 +683,7 @@ SNAPSHOTS
 SILENT_RULES
 SELINUX_STATIC_LIBS
 SELINUX_PC
+SD_NOTIFY_SUPPORT
 SBINDIR
 RT_LIBS
 PYTHON3DIR
@@ -970,6 +971,7 @@ with_lvmpolld_pidfile
 enable_notify_dbus
 enable_systemd_journal
 enable_app_machineid
+enable_sd_notify
 with_systemd_run
 enable_blkid_wiping
 enable_udev_sync
@@ -1710,6 +1712,7 @@ Optional Features:
   --disable-systemd-journal
                           disable LVM systemd journaling
   --disable-app-machineid disable LVM system ID using app-specific machine-id
+  --disable-sd-notify     disable LVM sd_notify
   --disable-blkid_wiping  disable libblkid detection of signatures when wiping
                           and use native code instead
   --enable-udev_sync      enable synchronization with udev processing
@@ -12606,6 +12609,7 @@ printf "%s\n" "#define DEFAULT_USE_LVMPOLLD $DEFAULT_USE_LVMPOLLD" >>confdefs.h
 
 
 SYSTEMD_MIN_VERSION=0
+SD_NOTIFY_SUPPORT="maybe"
 if test -n "$PKG_CONFIG" && \
     { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"systemd >= 221\""; } >&5
   ($PKG_CONFIG --exists --print-errors "systemd >= 221") 2>&5
@@ -12728,7 +12732,44 @@ printf "%s\n" "#define APP_MACHINEID_SUPPORT 1" >>confdefs.h
 
 fi
 
-if test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" || test "$APP_MACHINEID_SUPPORT" = "yes"
+################################################################################
+if test "$SD_NOTIFY_SUPPORT" != "no"
+then :
+  ac_fn_c_check_header_compile "$LINENO" "systemd/sd-daemon.h" "ac_cv_header_systemd_sd_daemon_h" "$ac_includes_default"
+if test "x$ac_cv_header_systemd_sd_daemon_h" = xyes
+then :
+  SD_NOTIFY_SUPPORT="yes"
+else case e in #(
+  e) SD_NOTIFY_SUPPORT="no" ;;
+esac
+fi
+
+fi
+# Check whether --enable-sd-notify was given.
+if test ${enable_sd_notify+y}
+then :
+  enableval=$enable_sd_notify; if test "$enableval" = "yes" && test "$SD_NOTIFY_SUPPORT" = "no"
+then :
+  as_fn_error $? "--enable-sd-notify requires systemd/sd-daemon.h. (--with-systemd=$with_systemd)" "$LINENO" 5
+fi
+	      SD_NOTIFY_SUPPORT=$enableval
+fi
+
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to enable to sd_notify" >&5
+printf %s "checking whether to enable to sd_notify... " >&6; }
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SD_NOTIFY_SUPPORT" >&5
+printf "%s\n" "$SD_NOTIFY_SUPPORT" >&6; }
+
+if test "$SD_NOTIFY_SUPPORT" = "yes"
+then :
+
+printf "%s\n" "#define SD_NOTIFY_SUPPORT 1" >>confdefs.h
+
+fi
+
+
+if test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" ||
+       test "$APP_MACHINEID_SUPPORT" = "yes" || test "$SD_NOTIFY_SUPPORT" = "yes"
 then :
 
 
@@ -17616,3 +17657,8 @@ then :
 printf "%s\n" "$as_me: WARNING: O_DIRECT disabled: low-memory pvmove may lock up" >&2;}
 fi
 
+if test "$BUILD_LVMLOCKD" = "yes" && test "$SD_NOTIFY_SUPPORT" = "no"
+then :
+  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Building lvmlockd without sd-notify support may block!" >&5
+printf "%s\n" "$as_me: WARNING: Building lvmlockd without sd-notify support may block!" >&2;}
+fi
diff --git a/configure.ac b/configure.ac
index b43d8b9be966..e147e4b059ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1012,6 +1012,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_USE_LVMPOLLD, [$DEFAULT_USE_LVMPOLLD],
 
 
 SYSTEMD_MIN_VERSION=0
+SD_NOTIFY_SUPPORT="maybe"
 PKG_CHECK_EXISTS(systemd >= 221, [SYSTEMD_MIN_VERSION=221])
 PKG_CHECK_EXISTS(systemd >= 234, [SYSTEMD_MIN_VERSION=234])
 
@@ -1066,10 +1067,27 @@ AS_IF([test "$APP_MACHINEID_SUPPORT" = "yes"],
       AC_DEFINE([APP_MACHINEID_SUPPORT], 1, [Define to 1 to include code that uses libsystemd machine-id apis.]))
 
 dnl -- Look for libsystemd libraries if needed
-AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" || test "$APP_MACHINEID_SUPPORT" = "yes"], [
+AS_IF([test "$NOTIFYDBUS_SUPPORT" = "yes" || test "$SYSTEMD_JOURNAL_SUPPORT" = "yes" ||
+       test "$APP_MACHINEID_SUPPORT" = "yes" || test "$SD_NOTIFY_SUPPORT" = "yes"], [
 	PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd])
 ])
 
+################################################################################
+dnl -- Build with sd_notify when the header file sd-daemon.h is present
+AS_IF([test "$SD_NOTIFY_SUPPORT" != "no"],
+      AC_CHECK_HEADER([systemd/sd-daemon.h], [SD_NOTIFY_SUPPORT="yes"], [SD_NOTIFY_SUPPORT="no"]))
+AC_ARG_ENABLE(sd-notify,
+	      AS_HELP_STRING([--disable-sd-notify],
+			     [disable LVM sd_notify]),
+	      AS_IF([test "$enableval" = "yes" && test "$SD_NOTIFY_SUPPORT" = "no"],
+		    AC_MSG_ERROR([--enable-sd-notify requires systemd/sd-daemon.h. (--with-systemd=$with_systemd)]))
+	      SD_NOTIFY_SUPPORT=$enableval, [])
+AC_MSG_CHECKING([whether to enable to sd_notify])
+AC_MSG_RESULT([$SD_NOTIFY_SUPPORT])
+
+AS_IF([test "$SD_NOTIFY_SUPPORT" = "yes"],
+      AC_DEFINE([SD_NOTIFY_SUPPORT], 1, [Define to 1 to include code that uses sd_notify.]))
+
 ################################################################################
 dnl -- Support override for systemd-run path if they need to (NixOS builds)
 AC_ARG_WITH(systemd-run,
diff --git a/daemons/lvmlockd/Makefile.in b/daemons/lvmlockd/Makefile.in
index 6d81d72fbc70..2f0b0fe83c4b 100644
--- a/daemons/lvmlockd/Makefile.in
+++ b/daemons/lvmlockd/Makefile.in
@@ -50,10 +50,10 @@ INCLUDES += -I$(top_srcdir)/libdaemon/server
 LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
 LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
 
-ifneq (,$(firstword $(LIBSYSTEMD_LIBS)))
-	CFLAGS += $(LIBSYSTEMD_CFLAGS) -DUSE_SD_NOTIFY
+#ifeq ("@SD_NOTIFY_SUPPORT@", "yes")
+	CFLAGS += $(LIBSYSTEMD_CFLAGS) -DSD_NOTIFY_SUPPORT
 	LIBS += $(LIBSYSTEMD_LIBS)
-endif
+#endif
 
 lvmlockd: $(OBJECTS) $(top_builddir)/libdaemon/server/libdaemonserver.a $(INTERNAL_LIBS)
 	@echo "    [CC] $@"
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 887226f1a742..3af6c7022079 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -31,7 +31,7 @@
 #include <sys/utsname.h>
 #include <sys/un.h>
 
-#ifdef USE_SD_NOTIFY
+#ifdef SD_NOTIFY_SUPPORT
 #include <systemd/sd-daemon.h>
 #endif
 
@@ -6106,7 +6106,7 @@ static int main_loop(daemon_state *ds_arg)
 	setup_worker_thread();
 	setup_restart();
 
-#ifdef USE_SD_NOTIFY
+#ifdef SD_NOTIFY_SUPPORT
 	sd_notify(0, "READY=1");
 #endif
 
diff --git a/include/configure.h.in b/include/configure.h.in
index 1953cba26326..58f17d041ebb 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -648,6 +648,9 @@
 /* Define to 1 to include the LVM readline shell. */
 #undef READLINE_SUPPORT
 
+/* Define to 1 to include code that uses sd_notify. */
+#undef SD_NOTIFY_SUPPORT
+
 /* Define to 1 to include built-in support for snapshots. */
 #undef SNAPSHOT_INTERNAL
 
-- 
2.47.0

openSUSE Build Service is sponsored by