Fix building on Linux with 7.x kernel versions
PATCH 1/1 Fix building on Linux with 7.x kernel versions
From: Richard Danter <[email protected]>
Some distros have moved to a v7.x kernel so we need to correctly handle building on these hosts.
Upstream-Status: Backport [The latest stable version 3.11 already fixed]
--- makedefs | 2 +- src/util/sys_defs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
makedefs +1 -1
@@ -625,7 +625,7 @@ EOF : ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"} : ${PLUGIN_LD="${CC-gcc} -shared"} ;; - Linux.[3456].*) + Linux.[34567].*) SYSTYPE=LINUX$RELEASE_MAJOR case "$CCARGS" in *-DNO_DB*) ;;
src/util/sys_defs.h +1 -1
@@ -763,7 +763,7 @@ extern int initgroups(const char *, int);* LINUX. */ #if defined(LINUX2 ) || defined(LINUX3 ) || defined(LINUX4 ) || defined(LINUX5 ) \ - || defined(LINUX6 ) + || defined(LINUX6 ) || defined(LINUX7 )#define SUPPORTED #define UINT32_TYPE unsigned int#define UINT16_TYPE unsigned short
Signature · 1 line
2.43.0
PATCH 1/1 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 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]
--- meta/classes-recipe/systemd.bbclass | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-)
meta/classes-recipe/systemd.bbclass +19 -13
@@ -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 }
Signature · 1 line
2.54.0
Re: [PATCH] systemd.bbclass: fix service enablement for cross-install scenarios
Please ignore/drop this patch for now. I need to rework it before it's ready for review — I'll send a v2 once it's sorted. Apologies for the noise.
Thanks,
Himani
________________________________
From: Barde, Himani Ramesh <[email protected]>
Sent: Wednesday, September 23, 2026 10:29 AM
To: [email protected] <[email protected]>
Cc: Term Li, Changqing <[email protected]>; MacLeod, Randy <[email protected]>; Barde, Himani Ramesh <[email protected]>
Subject: [PATCH] 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 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]
--- meta/classes-recipe/systemd.bbclass | 32 +++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-)
meta/classes-recipe/systemd.bbclass +19 -13
@@ -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