diff mbox series

[v2,1/2] systemd: drop build dependency on util-linux

Message ID 20250717211621.7122-2-hiagofranco@gmail.com
State New
Headers show
Series systemd: drop libmount dependency and add blkid and fdisk PACKAGECONFIGs | expand

Commit Message

Hiago De Franco July 17, 2025, 9:16 p.m. UTC
From: Hiago De Franco <hiago.franco@toradex.com>

The libmount dependency was made optional on systemd upstream [1]. By
backporting this upstream change, we can drop util-linux as a build
dependency for systemd, making it only as a runtime dependency.

This is important to fix a circular dependency between util-linux and
systemd when util-linux is built with the systemd PACKAGECONFIG enabled.
Without this change, each recipe depends on the other, triggering the
circular dependency error.

[1] https://github.com/systemd/systemd/commit/d1ee3889cf8e8a9edc82e41d306155fb4c531c8f

Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
---
v1->v2:
- commit description fixed, there was a link mentioned that was not
  being referenced on v1.
---
 .../0001-meson-Add-libmount-feature.patch     | 58 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_257.6.bb    |  7 ++-
 2 files changed, 63 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-core/systemd/systemd/0001-meson-Add-libmount-feature.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd/0001-meson-Add-libmount-feature.patch b/meta/recipes-core/systemd/systemd/0001-meson-Add-libmount-feature.patch
new file mode 100644
index 000000000000..b593e5cc7d4f
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-meson-Add-libmount-feature.patch
@@ -0,0 +1,58 @@ 
+From 821c809e1e1e449f5a2fe591d6aae1343b141b6c Mon Sep 17 00:00:00 2001
+From: Daan De Meyer <daan.j.demeyer@gmail.com>
+Date: Thu, 5 Jun 2025 11:05:08 +0200
+Subject: [PATCH 1/2] meson: Add libmount feature
+
+Let's reduce the dependencies required to build just libsystemd by
+making libmount optional. The meson disabler feature makes this quite
+trivial.
+
+Upstream-Status: Backport [d1ee3889cf8e8a9edc82e41d306155fb4c531c8f]
+Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
+---
+ meson.build       | 4 +++-
+ meson_options.txt | 2 ++
+ tools/oss-fuzz.sh | 2 +-
+ 3 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 957e00ecad..594fadbb37 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1179,7 +1179,9 @@ else
+ endif
+ 
+ libmount = dependency('mount',
+-                      version : fuzzer_build ? '>= 0' : '>= 2.30')
++                      version : fuzzer_build ? '>= 0' : '>= 2.30',
++                      disabler : true,
++                      required : get_option('libmount'))
+ 
+ libfdisk = dependency('fdisk',
+                       version : '>= 2.32',
+diff --git a/meson_options.txt b/meson_options.txt
+index f30b3f5238..f292732d62 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -471,6 +471,8 @@ option('dbus', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'd
+        description : 'libdbus support (for tests only)')
+ option('libarchive', type : 'feature',
+        description : 'libarchive support')
++option('libmount', type : 'feature',
++       description : 'libmount support')
+ 
+ option('bootloader', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' },
+        description : 'sd-boot/stub and userspace tools')
+diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh
+index df3d39eba6..b7a70207df 100755
+--- a/tools/oss-fuzz.sh
++++ b/tools/oss-fuzz.sh
+@@ -32,7 +32,7 @@ meson_args=("-Db_lundef=false")
+ if [ -z "$FUZZING_ENGINE" ]; then
+     meson_args+=("-Dllvm-fuzz=true")
+ else
+-    meson_args+=("-Doss-fuzz=true" "--auto-features=disabled")
++    meson_args+=("-Doss-fuzz=true" "--auto-features=disabled" "-Dlibmount=enabled")
+ 
+     apt-get update
+     apt-get install -y gperf m4 gettext python3-pip \
diff --git a/meta/recipes-core/systemd/systemd_257.6.bb b/meta/recipes-core/systemd/systemd_257.6.bb
index 9092d02c5109..d73c0cfe0d8b 100644
--- a/meta/recipes-core/systemd/systemd_257.6.bb
+++ b/meta/recipes-core/systemd/systemd_257.6.bb
@@ -4,7 +4,7 @@  PROVIDES = "udev"
 
 PE = "1"
 
-DEPENDS = "gperf-native libcap util-linux python3-jinja2-native"
+DEPENDS = "gperf-native libcap python3-jinja2-native"
 
 SECTION = "base/shell"
 
@@ -29,6 +29,7 @@  SRC_URI += " \
            file://0001-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
            file://0002-implment-systemd-sysv-install-for-OE.patch \
            file://0001-Do-not-create-var-log-README.patch \
+           file://0001-meson-Add-libmount-feature.patch \
            "
 
 # patches needed by musl
@@ -81,6 +82,7 @@  PACKAGECONFIG ??= " \
     idn \
     ima \
     kmod \
+    libmount \
     localed \
     logind \
     machined \
@@ -172,6 +174,7 @@  PACKAGECONFIG[kmod] = "-Dkmod=enabled,-Dkmod=disabled,kmod,libkmod"
 PACKAGECONFIG[ldconfig] = "-Dldconfig=true,-Dldconfig=false,,ldconfig"
 PACKAGECONFIG[libidn] = "-Dlibidn=enabled,-Dlibidn=disabled,libidn,,libidn"
 PACKAGECONFIG[libidn2] = "-Dlibidn2=enabled,-Dlibidn2=disabled,libidn2,,libidn2"
+PACKAGECONFIG[libmount] = "-Dlibmount=enabled,-Dlibmount=disabled,util-linux,util-linux-mount util-linux-umount"
 # Link udev shared with systemd helper library.
 # If enabled the udev package depends on the systemd package (which has the needed shared library).
 PACKAGECONFIG[link-udev-shared] = "-Dlink-udev-shared=true,-Dlink-udev-shared=false"
@@ -742,7 +745,7 @@  FILES:${PN} = " ${base_bindir}/* \
 
 FILES:${PN}-dev += "${base_libdir}/security/*.la ${datadir}/dbus-1/interfaces/ ${sysconfdir}/rpm/macros.systemd"
 
-RDEPENDS:${PN} += "kmod ${VIRTUAL-RUNTIME_dbus} util-linux-mount util-linux-umount udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck util-linux-swaponoff util-linux-mkswap"
+RDEPENDS:${PN} += "kmod ${VIRTUAL-RUNTIME_dbus} udev (= ${EXTENDPKGV}) systemd-udev-rules util-linux-agetty util-linux-fsck util-linux-swaponoff util-linux-mkswap"
 RDEPENDS:${PN} += "systemd-serialgetty"
 RDEPENDS:${PN} += "volatile-binds"