We have multiple bugs ocurring because when do_unpack reruns, it just
dumps the data base into WORKDIR. This means if a file was removed from
a directory in a file://subdir/ url, that file would be left in the
build confusing users.

Also if files are entirely removed from SRC_URI, they would still exist
in WORKDIR. Read the shadow recipe and the /etc/pam.d/ conditionals
for an example of how this can break in interesting ways.

To work around these issues, improve the cleaning code to remove anything
except temp/ since it contains logs of the currently running task and
*recipe-sysroot* since do_fetch and do_unpack have dependencies which may
be added there already. That directory is setup to look after itself.

We also have to create ${S} since that is a side effect of the current
[cleandirs] which is no longer needed after this change.

Signed-off-by: Richard Purdie <[email protected]>
---
 meta/classes/base.bbclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 4c681cc870d..97b7e8feca6 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -166,9 +166,14 @@ python base_do_fetch() {
 addtask unpack after do_fetch
 do_unpack[dirs] = "${WORKDIR}"
 
-do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != 
os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}"
-
 python base_do_unpack() {
+    workdir = d.getVar("WORKDIR")
+    for p in os.listdir(workdir):
+        if p == "temp" or "recipe-sysroot" in p:
+            continue
+        bb.utils.remove(workdir + "/" + p, recurse=True)
+    bb.utils.mkdirhier(d.getVar("S"))
+
     src_uri = (d.getVar('SRC_URI') or "").split()
     if len(src_uri) == 0:
         return
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#142808): 
https://lists.openembedded.org/g/openembedded-core/message/142808
Mute This Topic: https://lists.openembedded.org/mt/77128536/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to