All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios
@ 2026-07-16  6:15 Himani Ramesh Barde
  2026-07-17 18:02 ` [OE-core] " Mathieu Dubois-Briand
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Himani Ramesh Barde @ 2026-07-16  6:15 UTC (permalink / raw)
  To: openembedded-core; +Cc: Randy.MacLeod, Shiva.Komati, Himani Ramesh Barde

When packages are installed outside of Yocto's normal image creation
(e.g., using multistrap, debootstrap, or dpkg directly on a host),
the postinst script fails to enable systemd services.

The issue is that the entire enable logic is gated behind
"if systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
- If systemctl is absent on the host: the check fails, script is skipped
- If host systemctl is present: it cannot find target unit files

Fix this by separating the offline ($D set) and online ($D unset)
code paths into distinct branches. The previous code used a single
OPTS variable to switch between "--root=$D" (offline) and "" (online)
within one unified block. This variable is removed because the two
scenarios now have dedicated branches with different logic:

- Offline ($D set): Tries "systemctl --root=$D preset" first, which
  reads preset files from the target rootfs and creates symlinks
  without needing the host systemctl to understand the target's unit
  files. Falls back to "systemctl --root=$D enable" per service.

- Online ($D unset): Same as before - enable, daemon-reload, preset,
  restart. No behavioral change for on-target installs.

The OPTS variable is no longer needed because each branch now directly
uses the appropriate systemctl invocation for its context, making the
intent clearer and the offline path functional.

Fixes [YOCTO #14118]

Signed-off-by: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
---
 meta/classes-recipe/systemd.bbclass | 32 +++++++++++++++++------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 0f7e3b5..2f655c4 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -29,26 +29,32 @@ python __anonymous() {
 }
 
 systemd_postinst() {
-if systemctl >/dev/null 2>/dev/null; then
-	OPTS=""
-
-	if [ -n "$D" ]; then
-		OPTS="--root=$D"
+if [ -n "$D" ]; then
+	# Offline/cross-install: apply presets to the target rootfs.
+	# This handles multistrap, debootstrap, and similar tools that
+	# install packages outside of Yocto's normal image creation.
+	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+		if systemctl --root=$D preset ${SYSTEMD_SERVICE_ESCAPED} 2>/dev/null; then
+			:
+		elif systemctl >/dev/null 2>/dev/null; then
+			for service in ${SYSTEMD_SERVICE_ESCAPED}; do
+				systemctl --root=$D enable "$service" 2>/dev/null || true
+			done
+		fi
 	fi
-
+elif systemctl >/dev/null 2>/dev/null; then
+	# Online: running on the target system
 	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
 		for service in ${SYSTEMD_SERVICE_ESCAPED}; do
-			systemctl ${OPTS} enable "$service"
+			systemctl enable "$service"
 		done
 	fi
 
-	if [ -z "$D" ]; then
-		systemctl daemon-reload
-		systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
+	systemctl daemon-reload
+	systemctl preset ${SYSTEMD_SERVICE_ESCAPED}
 
-		if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
-			systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
-		fi
+	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+		systemctl --no-block restart ${SYSTEMD_SERVICE_ESCAPED}
 	fi
 fi
 }
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [OE-core] [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-16  6:15 [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios Himani Ramesh Barde
@ 2026-07-17 18:02 ` Mathieu Dubois-Briand
  2026-07-22  6:47 ` [PATCH v2] " Himani Ramesh Barde
  2026-07-22 10:14 ` [PATCH v3] " Himani Ramesh Barde
  2 siblings, 0 replies; 7+ messages in thread
From: Mathieu Dubois-Briand @ 2026-07-17 18:02 UTC (permalink / raw)
  To: HimaniRamesh.Barde, openembedded-core; +Cc: Randy.MacLeod, Shiva.Komati

On Thu Jul 16, 2026 at 8:15 AM CEST, Himani Ramesh Barde via lists.openembedded.org wrote:
> When packages are installed outside of Yocto's normal image creation
> (e.g., using multistrap, debootstrap, or dpkg directly on a host),
> the postinst script fails to enable systemd services.
>
> The issue is that the entire enable logic is gated behind
> "if systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
> - If systemctl is absent on the host: the check fails, script is skipped
> - If host systemctl is present: it cannot find target unit files
>
> Fix this by separating the offline ($D set) and online ($D unset)
> code paths into distinct branches. The previous code used a single
> OPTS variable to switch between "--root=$D" (offline) and "" (online)
> within one unified block. This variable is removed because the two
> scenarios now have dedicated branches with different logic:
>
> - Offline ($D set): Tries "systemctl --root=$D preset" first, which
>   reads preset files from the target rootfs and creates symlinks
>   without needing the host systemctl to understand the target's unit
>   files. Falls back to "systemctl --root=$D enable" per service.
>
> - Online ($D unset): Same as before - enable, daemon-reload, preset,
>   restart. No behavioral change for on-target installs.
>
> The OPTS variable is no longer needed because each branch now directly
> uses the appropriate systemctl invocation for its context, making the
> intent clearer and the offline path functional.
>
> Fixes [YOCTO #14118]
>
> Signed-off-by: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
> ---

Hi Himani Ramesh,

I tried to pick this patch, but I can see some conflicts with the master
branch. Can you confirm this is targeting the master branch and based on
a recent master?

Thanks,
Mathieu

-- 
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-16  6:15 [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios Himani Ramesh Barde
  2026-07-17 18:02 ` [OE-core] " Mathieu Dubois-Briand
@ 2026-07-22  6:47 ` Himani Ramesh Barde
  2026-07-22  6:49   ` Barde, Himani Ramesh
  2026-07-22  9:49   ` [OE-core] " Jörg Sommer
  2026-07-22 10:14 ` [PATCH v3] " Himani Ramesh Barde
  2 siblings, 2 replies; 7+ messages in thread
From: Himani Ramesh Barde @ 2026-07-22  6:47 UTC (permalink / raw)
  To: openembedded-core; +Cc: Randy.MacLeod, Shiva.Komati, Himani Ramesh Barde

When packages are installed outside of Yocto's normal image creation
(e.g., using multistrap, debootstrap, or dpkg directly on a host),
the postinst script fails to enable systemd services.

The issue is that the entire enable logic is gated behind
"if type systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
- If systemctl is absent on the host: the check fails, script is skipped
- If host systemctl is present: it cannot find target unit files

Fix this by separating the offline ($D set) and online ($D unset)
code paths into distinct branches. The previous code used a single
OPTS variable to switch between "--root=$D" (offline) and "" (online)
within one unified block. This variable is removed because the two
scenarios now have dedicated branches with different logic:

- Offline ($D set): Uses "systemctl --root=$D preset" per service,
  which reads preset files from the target rootfs and creates symlinks
  without needing the host systemctl to understand the target's unit
  files. Falls back to "systemctl --root=$D enable" per service.

- Online ($D unset): Same as before - enable, daemon-reload, preset,
  restart. No behavioral change for on-target installs.

The OPTS variable is no longer needed because each branch now directly
uses the appropriate systemctl invocation for its context, making the
intent clearer and the offline path functional.

Fixes [YOCTO #14118]

Signed-off-by: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
---
 meta/classes-recipe/systemd.bbclass | 30 ++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 26eaaf1..c209bb3 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -27,24 +27,36 @@ python __anonymous() {
 }
 
 systemd_postinst() {
-if type systemctl >/dev/null 2>/dev/null; then
-	OPTS=""
-
-	if [ -n "$D" ]; then
-		OPTS="--root=$D"
+if [ -n "$D" ]; then
+	# Offline/cross-install: apply presets to the target rootfs.
+	# This handles multistrap, debootstrap, and similar tools that
+	# install packages outside of Yocto's normal image creation.
+	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+		if type systemctl >/dev/null 2>/dev/null; then
+			for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
+				systemctl --root=$D preset "$service" 2>/dev/null || \
+					systemctl --root=$D enable "$service" 2>/dev/null || true
+			done
+
+			for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
+				systemctl --global --root=$D preset "$service" 2>/dev/null || \
+					systemctl --global --root=$D enable "$service" 2>/dev/null || true
+			done
+		fi
 	fi
-
+elif type systemctl >/dev/null 2>/dev/null; then
+	# Online: running on the target system
 	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
 		for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
-			systemctl ${OPTS} enable "$service"
+			systemctl enable "$service"
 		done
 
 		for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
-			systemctl --global ${OPTS} enable "$service"
+			systemctl --global enable "$service"
 		done
 	fi
 
-	if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then
+	if systemctl >/dev/null 2>/dev/null; then
 		# Reload only system service manager
 		# --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284
 		systemctl daemon-reload
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-22  6:47 ` [PATCH v2] " Himani Ramesh Barde
@ 2026-07-22  6:49   ` Barde, Himani Ramesh
  2026-07-22  9:49   ` [OE-core] " Jörg Sommer
  1 sibling, 0 replies; 7+ messages in thread
From: Barde, Himani Ramesh @ 2026-07-22  6:49 UTC (permalink / raw)
  To: Mathieu Dubois-Briand, openembedded-core@lists.openembedded.org
  Cc: MacLeod, Randy, Komati, Shiva

[-- Attachment #1: Type: text/plain, Size: 4742 bytes --]

Hi Mathieu,

Thanks for pointing that out. The v1 was based on scarthgap. I've sent a v2 rebased on the latest master.

Regards,
Himani
________________________________
From: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
Sent: Wednesday, July 22, 2026 12:17 PM
To: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Cc: MacLeod, Randy <Randy.MacLeod@windriver.com>; Komati, Shiva <Shiva.Komati@windriver.com>; Barde, Himani Ramesh <HimaniRamesh.Barde@windriver.com>
Subject: [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios

When packages are installed outside of Yocto's normal image creation
(e.g., using multistrap, debootstrap, or dpkg directly on a host),
the postinst script fails to enable systemd services.

The issue is that the entire enable logic is gated behind
"if type systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
- If systemctl is absent on the host: the check fails, script is skipped
- If host systemctl is present: it cannot find target unit files

Fix this by separating the offline ($D set) and online ($D unset)
code paths into distinct branches. The previous code used a single
OPTS variable to switch between "--root=$D" (offline) and "" (online)
within one unified block. This variable is removed because the two
scenarios now have dedicated branches with different logic:

- Offline ($D set): Uses "systemctl --root=$D preset" per service,
  which reads preset files from the target rootfs and creates symlinks
  without needing the host systemctl to understand the target's unit
  files. Falls back to "systemctl --root=$D enable" per service.

- Online ($D unset): Same as before - enable, daemon-reload, preset,
  restart. No behavioral change for on-target installs.

The OPTS variable is no longer needed because each branch now directly
uses the appropriate systemctl invocation for its context, making the
intent clearer and the offline path functional.

Fixes [YOCTO #14118]

Signed-off-by: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
---
 meta/classes-recipe/systemd.bbclass | 30 ++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 26eaaf1..c209bb3 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -27,24 +27,36 @@ python __anonymous() {
 }

 systemd_postinst() {
-if type systemctl >/dev/null 2>/dev/null; then
-       OPTS=""
-
-       if [ -n "$D" ]; then
-               OPTS="--root=$D"
+if [ -n "$D" ]; then
+       # Offline/cross-install: apply presets to the target rootfs.
+       # This handles multistrap, debootstrap, and similar tools that
+       # install packages outside of Yocto's normal image creation.
+       if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+               if type systemctl >/dev/null 2>/dev/null; then
+                       for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
+                               systemctl --root=$D preset "$service" 2>/dev/null || \
+                                       systemctl --root=$D enable "$service" 2>/dev/null || true
+                       done
+
+                       for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
+                               systemctl --global --root=$D preset "$service" 2>/dev/null || \
+                                       systemctl --global --root=$D enable "$service" 2>/dev/null || true
+                       done
+               fi
         fi
-
+elif type systemctl >/dev/null 2>/dev/null; then
+       # Online: running on the target system
         if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
                 for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
-                       systemctl ${OPTS} enable "$service"
+                       systemctl enable "$service"
                 done

                 for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
-                       systemctl --global ${OPTS} enable "$service"
+                       systemctl --global enable "$service"
                 done
         fi

-       if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then
+       if systemctl >/dev/null 2>/dev/null; then
                 # Reload only system service manager
                 # --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284
                 systemctl daemon-reload
--
2.54.0


[-- Attachment #2: Type: text/html, Size: 9895 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [OE-core] [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-22  6:47 ` [PATCH v2] " Himani Ramesh Barde
  2026-07-22  6:49   ` Barde, Himani Ramesh
@ 2026-07-22  9:49   ` Jörg Sommer
  2026-07-22 10:16     ` Barde, Himani Ramesh
  1 sibling, 1 reply; 7+ messages in thread
From: Jörg Sommer @ 2026-07-22  9:49 UTC (permalink / raw)
  To: HimaniRamesh.Barde; +Cc: openembedded-core, Randy.MacLeod, Shiva.Komati

[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

Himani Ramesh Barde via lists.openembedded.org schrieb am Mi 22. Jul, 06:47 (+0000):
> When packages are installed outside of Yocto's normal image creation
> (e.g., using multistrap, debootstrap, or dpkg directly on a host),
> the postinst script fails to enable systemd services.
> 
> The issue is that the entire enable logic is gated behind
> "if type systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
> - If systemctl is absent on the host: the check fails, script is skipped
> - If host systemctl is present: it cannot find target unit files
> 
> Fix this by separating the offline ($D set) and online ($D unset)

May it be better to say off-side and on-side or image-build and on-target?

> code paths into distinct branches. The previous code used a single
> OPTS variable to switch between "--root=$D" (offline) and "" (online)
> within one unified block. This variable is removed because the two
> scenarios now have dedicated branches with different logic:
> 
> - Offline ($D set): Uses "systemctl --root=$D preset" per service,
>   which reads preset files from the target rootfs and creates symlinks
>   without needing the host systemctl to understand the target's unit
>   files. Falls back to "systemctl --root=$D enable" per service.
> 
> - Online ($D unset): Same as before - enable, daemon-reload, preset,
>   restart. No behavioral change for on-target installs.


-- 
Navimatix GmbH           T: 03641 - 327 99 0
Tatzendpromenade 2       F: 03641 - 526 306
07745 Jena               www.navimatix.de

Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6684 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-16  6:15 [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios Himani Ramesh Barde
  2026-07-17 18:02 ` [OE-core] " Mathieu Dubois-Briand
  2026-07-22  6:47 ` [PATCH v2] " Himani Ramesh Barde
@ 2026-07-22 10:14 ` Himani Ramesh Barde
  2 siblings, 0 replies; 7+ messages in thread
From: Himani Ramesh Barde @ 2026-07-22 10:14 UTC (permalink / raw)
  To: openembedded-core; +Cc: Randy.MacLeod, Shiva.Komati, Himani Ramesh Barde

When packages are installed outside of Yocto's normal image creation
(e.g., using multistrap, debootstrap, or dpkg directly on a host),
the postinst script fails to enable systemd services.

The issue is that the entire enable logic is gated behind
"if type systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
- If systemctl is absent on the host: the check fails, script is skipped
- If host systemctl is present: it cannot find target unit files

Fix this by separating the image-build ($D set) and on-target ($D unset)
code paths into distinct branches. The previous code used a single
OPTS variable to switch between "--root=$D" (image-build) and ""
(on-target) within one unified block. This variable is removed because
the two scenarios now have dedicated branches with different logic:

- Image-build ($D set): Uses "systemctl --root=$D preset" per service,
  which reads preset files from the target rootfs and creates symlinks
  without needing the host systemctl to understand the target's unit
  files. Falls back to "systemctl --root=$D enable" per service.

- On-target ($D unset): Same as before - enable, daemon-reload, preset,
  restart. No behavioral change for on-target installs.

The OPTS variable is no longer needed because each branch now directly
uses the appropriate systemctl invocation for its context, making the
intent clearer and the image-build path functional.

Fixes [YOCTO #14118]

Signed-off-by: Himani Ramesh Barde <HimaniRamesh.Barde@windriver.com>
---
 meta/classes-recipe/systemd.bbclass | 30 ++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 26eaaf1..bdbfb7c 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -27,24 +27,36 @@ python __anonymous() {
 }
 
 systemd_postinst() {
-if type systemctl >/dev/null 2>/dev/null; then
-	OPTS=""
-
-	if [ -n "$D" ]; then
-		OPTS="--root=$D"
+if [ -n "$D" ]; then
+	# Image-build/cross-install: apply presets to the target rootfs.
+	# This handles multistrap, debootstrap, and similar tools that
+	# install packages outside of Yocto's normal image creation.
+	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
+		if type systemctl >/dev/null 2>/dev/null; then
+			for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
+				systemctl --root=$D preset "$service" 2>/dev/null || \
+					systemctl --root=$D enable "$service" 2>/dev/null || true
+			done
+
+			for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
+				systemctl --global --root=$D preset "$service" 2>/dev/null || \
+					systemctl --global --root=$D enable "$service" 2>/dev/null || true
+			done
+		fi
 	fi
-
+elif type systemctl >/dev/null 2>/dev/null; then
+	# On-target: running on the actual device
 	if [ "${SYSTEMD_AUTO_ENABLE}" = "enable" ]; then
 		for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", False, d)}; do
-			systemctl ${OPTS} enable "$service"
+			systemctl enable "$service"
 		done
 
 		for service in ${@systemd_filter_services("${SYSTEMD_SERVICE_ESCAPED}", True, d)}; do
-			systemctl --global ${OPTS} enable "$service"
+			systemctl --global enable "$service"
 		done
 	fi
 
-	if [ -z "$D" ] && systemctl >/dev/null 2>/dev/null; then
+	if systemctl >/dev/null 2>/dev/null; then
 		# Reload only system service manager
 		# --global for daemon-reload is not supported: https://github.com/systemd/systemd/issues/19284
 		systemctl daemon-reload
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [OE-core] [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios
  2026-07-22  9:49   ` [OE-core] " Jörg Sommer
@ 2026-07-22 10:16     ` Barde, Himani Ramesh
  0 siblings, 0 replies; 7+ messages in thread
From: Barde, Himani Ramesh @ 2026-07-22 10:16 UTC (permalink / raw)
  To: Jörg Sommer
  Cc: openembedded-core@lists.openembedded.org, MacLeod, Randy,
	Komati, Shiva

[-- Attachment #1: Type: text/plain, Size: 2100 bytes --]

Hi,

Thanks for the suggestion. Updated the wording to "image-build" and "on-target" in v3.

Regards,
Himani


________________________________
From: Jörg Sommer
Sent: Wednesday, July 22, 2026 3:19 PM
To: Barde, Himani Ramesh
Cc: openembedded-core@lists.openembedded.org; MacLeod, Randy; Komati, Shiva
Subject: Re: [OE-core] [PATCH v2] systemd.bbclass: fix service enablement for cross-install scenarios

Himani Ramesh Barde via lists.openembedded.org schrieb am Mi 22. Jul, 06:47 (+0000):
> When packages are installed outside of Yocto's normal image creation
> (e.g., using multistrap, debootstrap, or dpkg directly on a host),
> the postinst script fails to enable systemd services.
>
> The issue is that the entire enable logic is gated behind
> "if type systemctl >/dev/null 2>/dev/null". In cross-install scenarios:
> - If systemctl is absent on the host: the check fails, script is skipped
> - If host systemctl is present: it cannot find target unit files
>
> Fix this by separating the offline ($D set) and online ($D unset)

May it be better to say off-side and on-side or image-build and on-target?

> code paths into distinct branches. The previous code used a single
> OPTS variable to switch between "--root=$D" (offline) and "" (online)
> within one unified block. This variable is removed because the two
> scenarios now have dedicated branches with different logic:
>
> - Offline ($D set): Uses "systemctl --root=$D preset" per service,
>   which reads preset files from the target rootfs and creates symlinks
>   without needing the host systemctl to understand the target's unit
>   files. Falls back to "systemctl --root=$D enable" per service.
>
> - Online ($D unset): Same as before - enable, daemon-reload, preset,
>   restart. No behavioral change for on-target installs.


--
Navimatix GmbH           T: 03641 - 327 99 0
Tatzendpromenade 2       F: 03641 - 526 306
07745 Jena               www.navimatix.de<http://www.navimatix.de>

Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480

[-- Attachment #2: Type: text/html, Size: 4460 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-07-22 10:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  6:15 [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios Himani Ramesh Barde
2026-07-17 18:02 ` [OE-core] " Mathieu Dubois-Briand
2026-07-22  6:47 ` [PATCH v2] " Himani Ramesh Barde
2026-07-22  6:49   ` Barde, Himani Ramesh
2026-07-22  9:49   ` [OE-core] " Jörg Sommer
2026-07-22 10:16     ` Barde, Himani Ramesh
2026-07-22 10:14 ` [PATCH v3] " Himani Ramesh Barde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.