File 0001-btrfs-progs-build-make-libudev-selectable.patch of Package btrfsprogs.24931

From e8b5a2b6bea29ba539c0a413d0b2415c3e33d16d Mon Sep 17 00:00:00 2001
From: David Sterba <dsterba@suse.com>
Date: Tue, 5 Oct 2021 16:43:02 +0200
Subject: [PATCH] btrfs-progs: build: make libudev selectable

Previously the build would be optional based on what is installed on the
system. Add an option to make this selectable by user, ie. to allow
build without libudev even if it is installed on the system.

For most users and distros libudev dependency should be ok, but we've
had requests to disable various features (embedded, systems with
non-systemd user space base system) so let's do the same.

Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 INSTALL      |  6 ++++++
 configure.ac | 12 +++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/INSTALL b/INSTALL
index 1cb01e8708b9..510819f6d190 100644
--- a/INSTALL
+++ b/INSTALL
@@ -14,6 +14,12 @@ Installation instructions
 - e2fsprogs - ext2/ext3/ext4 file system libraries, or called e2fslibs
 - libreiserfscore - reiserfs file system library version >= 3.6.27
 
+Optionally, multipath device detection requires libudev and running udev
+daemon, as it's the only source of the path information. Static build has a
+fallback and does not need static version of libudev.
+
+- libudev
+
 Generating documentation:
 
 - asciidoc - text document format tool
diff --git a/configure.ac b/configure.ac
index a8a59fe16293..a55682552542 100644
--- a/configure.ac
+++ b/configure.ac
@@ -233,13 +233,14 @@ fi
 AS_IF([test "x$enable_zstd" = xyes], [BTRFSRESTORE_ZSTD=1], [BTRFSRESTORE_ZSTD=0])
 AC_SUBST(BTRFSRESTORE_ZSTD)
 
-PKG_CHECK_EXISTS([libudev], [pkg_config_libudev=yes], [pkg_config_libudev=no])
-if test "x$pkg_config_libudev" = xyes; then
+AC_ARG_ENABLE([libudev],
+      AS_HELP_STRING([--disable-libudev], [build without libudev support (for multipath)]),
+      [], [enable_libudev=yes]
+)
+
+if test "x$enable_libudev" = xyes; then
 	PKG_CHECK_MODULES([LIBUDEV], [libudev])
 	AC_DEFINE([HAVE_LIBUDEV], [1], [Define to 1 if libudev is available])
-else
-	AC_MSG_CHECKING([for LIBUDEV])
-	AC_MSG_RESULT([no])
 fi
 
 AC_ARG_ENABLE([python],
@@ -316,6 +317,7 @@ AC_MSG_RESULT([
 	btrfs-restore zstd: ${enable_zstd}
 	Python bindings:    ${enable_python}
 	Python interpreter: ${PYTHON}
+	libudev:            ${enable_libudev}
 
 	Type 'make' to compile.
 ])
-- 
2.25.1

openSUSE Build Service is sponsored by