[PATCH v2] classes/image-postproc: chroot before postprocessing /etc/machine-id

12 views
Skip to first unread message

alexander...@siemens.com

unread,
Sep 17, 2025, 5:28:52 AMSep 17
to isar-...@googlegroups.com, felix.mo...@siemens.com, Alexander Heinisch
From: Alexander Heinisch <alexander...@siemens.com>

If /etc/machine-id happens to be a link to e.g. /var/...
the postprocessing overrides build-hosts /var/... instead of
the desired file on the rootfs.

Signed-off-by: Alexander Heinisch <alexander...@siemens.com>
---
meta/classes/image-postproc-extension.bbclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/image-postproc-extension.bbclass b/meta/classes/image-postproc-extension.bbclass
index 991bac4c..b332e826 100644
--- a/meta/classes/image-postproc-extension.bbclass
+++ b/meta/classes/image-postproc-extension.bbclass
@@ -63,7 +63,7 @@ image_postprocess_machine_id() {
if dpkg --compare-versions "$SYSTEMD_VERSION" "lt" "247"; then
MACHINE_ID=""
fi
- echo "$MACHINE_ID" | sudo tee '${IMAGE_ROOTFS}/etc/machine-id'
+ echo "$MACHINE_ID" | sudo chroot ${IMAGE_ROOTFS} tee /etc/machine-id
sudo rm -f '${IMAGE_ROOTFS}/var/lib/dbus/machine-id'
}

--
2.39.5

Heinisch, Alexander

unread,
Oct 21, 2025, 7:22:52 AM (10 days ago) Oct 21
to isar-...@googlegroups.com, MOESSBAUER, Felix
Any updates on this patch? Seems it got lost.

On Wed, 2025-09-17 at 11:28 +0200, alexander...@siemens.com
wrote:
Alexander Heinisch
Siemens AG
www.siemens.com

cedric.h...@siemens.com

unread,
Oct 21, 2025, 11:58:18 AM (10 days ago) Oct 21
to Heinisch, Alexander, isar-...@googlegroups.com, MOESSBAUER, Felix
On Tue, 2025-10-21 at 11:22 +0000, 'Heinisch, Alexander' via isar-users
wrote:
we could use the newly introduced rootfs_cmd to avoid a sudo call here.
reach out if you need some clarification on how to use rootfs_cmd

> >      sudo rm -f '${IMAGE_ROOTFS}/var/lib/dbus/machine-id'
> >  }
> >  
>
> --
> Alexander Heinisch
> Siemens AG
> www.siemens.com
>

--
Cedric Hombourger
Siemens AG
www.siemens.com

cedric.h...@siemens.com

unread,
Oct 22, 2025, 5:09:53 AM (9 days ago) Oct 22
to Heinisch, Alexander, isar-...@googlegroups.com, MOESSBAUER, Felix
Just to update everyone. Alexander and I discussed and concluded that
rootfs_cmd may not be used here since we require write access to a
root-owned file (rootfs_cmd is only an alternative to sudo chroot for
commands where we do not require elevated privileges)

Zhihang Wei

unread,
Oct 23, 2025, 12:02:32 PM (8 days ago) Oct 23
to Heinisch, Alexander, isar-...@googlegroups.com, MOESSBAUER, Felix, Cedric Hombourger
Hi,

The patch previously encountered an error during the full CI run. However,
this error cannot be reproduced after multiple runs on the CI server or
on my
local machine. We believe the issue is related to the CI itself rather than
the patch.

Since it seems that the next version (v3) is on the way, we’ll wait for it
before running CI again. If that’s not the case, please let me know.

Best regards,
Zhihang

Heinisch, Alexander

unread,
Oct 23, 2025, 3:26:07 PM (8 days ago) Oct 23
to isar-...@googlegroups.com, w...@ilbers.de, cedric.h...@siemens.com, MOESSBAUER, Felix
On Thu, 2025-10-23 at 18:02 +0200, Zhihang Wei wrote:
> Hi,
>
> The patch previously encountered an error during the full CI run.
> However,
> this error cannot be reproduced after multiple runs on the CI server
> or
> on my
> local machine. We believe the issue is related to the CI itself
> rather than
> the patch.
>
> Since it seems that the next version (v3) is on the way, we’ll wait
> for it
> before running CI again. If that’s not the case, please let me know.
>
All remarks of Cedric got resolved, without changes required.
Thus, as of now, no v3 is planned.

BR Alexander

Zhihang Wei

unread,
Oct 24, 2025, 11:56:07 AM (7 days ago) Oct 24
to alexander...@siemens.com, isar-...@googlegroups.com, felix.mo...@siemens.com
Applied to next, thanks.

Best regards,
Zhihang
Reply all
Reply to author
Forward
0 new messages