[3/4] fix(dpkg-build): scan DEPLOY_DIR_DEB only once in do_deploy_deb

Message ID 20260910140201.250854-4-felix.moessbauer@siemens.com
State New
Headers show
Series Fix various race conditions on multiconfig | expand

Commit Message

Felix Moessbauer Sept. 10, 2026, 2:02 p.m. UTC
do_deploy_deb removed the packages from isar-apt via deb_clean() and then
scanned DEPLOY_DIR_DEB to add them back. DEPLOY_DIR_DEB is shared by all
multiconfigs with the same DISTRO and DISTRO_ARCH, and is transiently
empty while do_dpkg_build of one of them rebuilds the recipe, between
sstate_clean() in its prefunc and sstate_install() in its postfunc. A
do_deploy_deb of another multiconfig hitting that window removed the
package from isar-apt and added nothing back, while still reporting
success. The package was then missing from isar-apt although present in
DEPLOY_DIR_DEB, and do_rootfs_install failed to install it much later:

  E: Unable to locate package example-module-armmp

Scan DEPLOY_DIR_DEB once and skip the update entirely when it is empty,
leaving isar-apt untouched instead of clearing it. That is safe: the
multiconfig doing the rebuild runs its own do_deploy_deb once
do_dpkg_build completed.

Fixes: 1182a45b ("fix(dpkg-build): deploy debs via shared sstate dir")
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes-recipe/dpkg-base.bbclass | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/classes-recipe/dpkg-base.bbclass b/meta/classes-recipe/dpkg-base.bbclass
index 66f4d177..fbb952bd 100644
--- a/meta/classes-recipe/dpkg-base.bbclass
+++ b/meta/classes-recipe/dpkg-base.bbclass
@@ -255,12 +255,21 @@  do_clean[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
 do_clean[network] = "${TASK_USE_SUDO}"
 
 do_deploy_deb() {
-    deb_clean
+    # Removal is by source name and architecture (deb_clean), so a single scan
+    # of DEPLOY_DIR_DEB is only needed for the addition below.
     debs=$(find ${DEPLOY_DIR_DEB} -maxdepth 1 -name '*.deb')
-    if [ -n "${debs}" ]; then
-        repo_add_packages "${REPO_ISAR_DIR}"/"${DISTRO}" \
-            "${REPO_ISAR_DB_DIR}"/"${DISTRO}" "${DEBDISTRONAME}" ${debs}
+    if [ -z "${debs}" ]; then
+        # DEPLOY_DIR_DEB is shared by all multiconfigs with the same DISTRO and
+        # DISTRO_ARCH. It is transiently empty while do_dpkg_build of another
+        # multiconfig rebuilds this recipe, between sstate_clean() in its
+        # prefunc and sstate_install() in its postfunc. Skipping is safe: that
+        # multiconfig runs its own do_deploy_deb once the rebuild completed.
+        bbnote "${DEPLOY_DIR_DEB} is empty, leaving isar-apt untouched"
+        return
     fi
+    deb_clean
+    repo_add_packages "${REPO_ISAR_DIR}"/"${DISTRO}" \
+        "${REPO_ISAR_DB_DIR}"/"${DISTRO}" "${DEBDISTRONAME}" ${debs}
 }
 
 addtask deploy_deb after do_dpkg_build before do_build