[1/2] sbuild: place tmpdir below WORKDIR on rootless

Message ID 20260907114136.3946468-1-felix.moessbauer@siemens.com
State Under Review
Headers show
Series [1/2] sbuild: place tmpdir below WORKDIR on rootless | expand

Commit Message

Felix Moessbauer Sept. 7, 2026, 11:41 a.m. UTC
When running sbuild in rootless mode, it needs some scratch space to
extract the rootfs. If not configured otherwise, a tmpdir below /tmp is
used. In case of isar builds this is not desired, as /tmp could be too
small (e.g. on a tmpfs) and it also breaks the rule of only operating
below bitbakes TMPDIR.

We fix this by explicitly setting the TMPDIR env var to a dir below the
recipes WORKDIR. By that, each sbuild chroot is extracted to a tmpdir
below the recipe that needs it (it is automatically cleanded up by
sbuild after the build).

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes-recipe/dpkg.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/meta/classes-recipe/dpkg.bbclass b/meta/classes-recipe/dpkg.bbclass
index a42703d5..35408495 100644
--- a/meta/classes-recipe/dpkg.bbclass
+++ b/meta/classes-recipe/dpkg.bbclass
@@ -21,6 +21,8 @@  SBUILD_PASSTHROUGH_ADDITIONS ?= ""
 # can be set to "1" in the recipe.
 DPKG_BUILD_ENABLE_NETWORK ??= "0"
 
+SBUILD_TMPDIR ?= "${WORKDIR}/tmpdir"
+
 def expand_sbuild_pt_additions(d):
     cmds = ''
     for var in d.getVar('SBUILD_PASSTHROUGH_ADDITIONS').split():
@@ -41,6 +43,7 @@  CP_FLAGS:sid ?= "-L --update=none --no-preserve=owner"
 
 # Build package from sources using build script
 dpkg_runbuild[root_cleandirs] += "${WORKDIR}/rootfs"
+dpkg_runbuild[cleandirs] += "${SBUILD_TMPDIR}"
 dpkg_runbuild[vardepsexclude] += "${SBUILD_PASSTHROUGH_ADDITIONS}"
 dpkg_runbuild() {
     E="${@ isar_export_proxies(d)}"
@@ -126,6 +129,7 @@  dpkg_runbuild() {
         sbuild_network_option="--enable-network"
     fi
 
+    TMPDIR=${SBUILD_TMPDIR} \
     sbuild -n -c ${SBUILD_CHROOT} \
         --chroot-mode=${ISAR_CHROOT_MODE} \
         --host=${PACKAGE_ARCH} --build=${BUILD_ARCH} ${profiles} \