From a53bb614e1b2256d7b39c01812ac8a84d9a9ce63 Mon Sep 17 00:00:00 2001
From: Ninette Adhikari <ninette@thehoodiefirm.com>
Date: Wed, 22 May 2024 16:52:52 +0200
Subject: [PATCH 1/3] sstate: fixing possible race codition

Fixes race condition between parallel execution of
functions registered in `SSTATEPOSTINSTFUNCS` and
rename operations on folders related to sstate

Signed-off-by: Pedro Ferreira <pmi183@gmail.com>
---
 meta/classes-global/sstate.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index 76a7b59636..9887169e4f 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -403,7 +403,6 @@ def sstate_installpkgdir(ss, d):
     for state in ss['dirs']:
         prepdir(state[1])
         bb.utils.rename(sstateinst + state[0], state[1])
-    sstate_install(ss, d)
 
     for plain in ss['plaindirs']:
         workdir = d.getVar('WORKDIR')
@@ -416,6 +415,8 @@ def sstate_installpkgdir(ss, d):
         prepdir(dest)
         bb.utils.rename(src, dest)
 
+    sstate_install(ss, d)
+
     return True
 
 python sstate_hardcode_path_unpack () {
-- 
2.25.1

