diff mbox series

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

Message ID 20250716232931.127811-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 16, 2025, 11:29 p.m. UTC
From: Hiago De Franco <hiago.franco@toradex.com>

The libmount dependency was made optional on systemd upstream [2]. 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/blob/main/README#L216
[2] https://github.com/systemd/systemd/commit/d1ee3889cf8e8a9edc82e41d306155fb4c531c8f

Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
---
 .../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

Comments

Alexander Kanavin July 17, 2025, 9:53 a.m. UTC | #1
I don't understand. The backported patch adds a meson option, but not
any uses of it. Why is it needed?

Alex

On Thu, 17 Jul 2025 at 01:29, Hiago De Franco <hiagofranco@gmail.com> wrote:
>
> From: Hiago De Franco <hiago.franco@toradex.com>
>
> The libmount dependency was made optional on systemd upstream [2]. 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/blob/main/README#L216
> [2] https://github.com/systemd/systemd/commit/d1ee3889cf8e8a9edc82e41d306155fb4c531c8f
>
> Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
> ---
>  .../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 --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..b04acd6fef08
> --- /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] 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"
>
> --
> 2.39.5
>
Alexander Kanavin July 17, 2025, 9:56 a.m. UTC | #2
Ah nevermind. The dependency was already there, it's just converted
from floating to explicit?

Alex

On Thu, 17 Jul 2025 at 11:54, Alexander Kanavin via
lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org>
wrote:
>
> I don't understand. The backported patch adds a meson option, but not
> any uses of it. Why is it needed?
>
> Alex
>
> On Thu, 17 Jul 2025 at 01:29, Hiago De Franco <hiagofranco@gmail.com> wrote:
> >
> > From: Hiago De Franco <hiago.franco@toradex.com>
> >
> > The libmount dependency was made optional on systemd upstream [2]. 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/blob/main/README#L216
> > [2] https://github.com/systemd/systemd/commit/d1ee3889cf8e8a9edc82e41d306155fb4c531c8f
> >
> > Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
> > ---
> >  .../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 --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..b04acd6fef08
> > --- /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] 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"
> >
> > --
> > 2.39.5
> >
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#220528): https://lists.openembedded.org/g/openembedded-core/message/220528
> Mute This Topic: https://lists.openembedded.org/mt/114194829/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Hiago De Franco July 17, 2025, 12:55 p.m. UTC | #3
Hi Alex,

On Thu, Jul 17, 2025 at 11:56:10AM +0200, Alexander Kanavin wrote:
> Ah nevermind. The dependency was already there, it's just converted
> from floating to explicit?

Yes it was already there, but now we can set the option to build without
it, so we can remove it from DEPENDS and convert it into a
PACKAGECONFIG.

Thanks!

Hiago.

> 
> Alex
>
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..b04acd6fef08
--- /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] 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"