diff mbox series

[meta-oe,wrynose,2/2] discoverable-disk-image: stage systemd-repart below WORKDIR

Message ID 20261205080329.1886963-2-johannes.schneider@leica-geosystems.com
State New
Headers show
Series [meta-oe,wrynose,1/2] discoverable-disk-image: drop do_unpack deptask | expand

Commit Message

Johannes Schneider Dec. 5, 2026, 8:03 a.m. UTC
systemd-repart copies the rootfs into a temporary directory from
var_tmp_dir() to populate the filesystems. With $TMPDIR, $TEMP and $TMP
unset in the task, that is the host's /var/tmp, which the class adds to
PSEUDO_INCLUDE_PATHS for the faked ownership to apply there. pseudo
then tracks a host-wide directory shared by all builds and users, and
an interrupted run can leave its staging tree outside the build
directory.

Stage into ${WORKDIR}/repart-tmp instead, recreated on every run, and
cover only that with pseudo. The location is passed through $TMP rather
than $TMPDIR, because pseudo derives its own runtime paths from $TMPDIR.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
(cherry picked from commit 15a584c0938ff426f859a9d495adca36a6808916)
---

Backport for wrynose: keeps the systemd-repart staging and pseudo's
coverage inside the build directory instead of the host's /var/tmp.
Independent of 1/2; cherry-picks cleanly.

 meta-oe/classes/discoverable-disk-image.bbclass | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/classes/discoverable-disk-image.bbclass b/meta-oe/classes/discoverable-disk-image.bbclass
index 02ad900d0f..604f316d5f 100644
--- a/meta-oe/classes/discoverable-disk-image.bbclass
+++ b/meta-oe/classes/discoverable-disk-image.bbclass
@@ -77,17 +77,19 @@  REPART_DDI_TYPE ?= "sysext"
 
 REPART_DDI_EXTENSION ?= "ddi"
 
-# systemd-repart creates temporary directoryies under /var/tmp/.#repartXXXXXXX/,
-# to estimate partition size etc. Since files are copied there from the image/rootfs
-# folder - which are owned by pseudo-root - this temporary location has to be
-# added to the directories handled by pseudo; otherwise calls to e.g.
-# fchown(0,0) inside systemd git/src/shared/copy.c end up failing.
-PSEUDO_INCLUDE_PATHS .= ",/var/tmp/"
+# systemd-repart stages copies of the rootfs here; pseudo has to cover it
+REPART_WORKDIR = "${WORKDIR}/repart-tmp"
+PSEUDO_INCLUDE_PATHS .= ",${REPART_WORKDIR}"
 
 oe_image_systemd_repart_make_ddi() {
 
     local additional_args=""
 
+    # $TMP, not $TMPDIR: pseudo derives its own runtime paths from $TMPDIR
+    rm -rf "${REPART_WORKDIR}"
+    mkdir -p "${REPART_WORKDIR}"
+    export TMP="${REPART_WORKDIR}"
+
     if [ -n "${REPART_PRIVATE_KEY}" ]
     then
         if [ -n "${REPART_PRIVATE_KEY_SOURCE}" ]