All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] state/staging: Fix directory not deleted for race
@ 2021-09-15 11:46 Pgowda
  2021-09-16  7:45 ` Richard Purdie
       [not found] ` <16A53DBD300C0C8E.4388@lists.openembedded.org>
  0 siblings, 2 replies; 14+ messages in thread
From: Pgowda @ 2021-09-15 11:46 UTC (permalink / raw)
  To: openembedded-core
  Cc: richard.purdie, rwmacleod, umesh.kalappa0, vinay.m.engg, Pgowda

The race issue resulted in some empty directories not being deleted.
During staging_copyfile, it results in "file already exists error" on
creating link for directories during do_prepare_recipe_sysroot.
The following patch checks whether the directory and its sub directories
have no files in it and removes them.

The issue was observed on running rust-hello-world for glibc and musl
one after the other.
TCLIBC=glibc MACHINE=qemuarm bitbake rust-hello-world
TCLIBC=musl MACHINE=qemuarm bitbake rust-hello-world

On fixing the above issue, it was found that
arm-poky-linux-musleabi.json files are not being generated.
$/del/build/tmp/work/x86_64-linux/rust-cross-arm/1.54.0-r0/targets/
arm-poky-linux-musleabi.json': No such file or directory

It is generated and builds successfully when musl lib is built standalone.
However, when musl is built after glibc or viceversa results in the
latter json file not being generated.

Signed-off-by: Pgowda <pgowda.cve@gmail.com>
---
 meta/classes/staging.bbclass | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index af3397bab6..4b751af4d3 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -145,6 +145,16 @@ def staging_copyfile(c, target, dest, postinsts, seendirs):
     if os.path.islink(c):
         linkto = os.readlink(c)
         if os.path.lexists(dest):
+            # Check if directory is not deleted for race issue
+            if os.path.isdir(dest):
+                count = 0
+                for root, dirs, files in os.walk(dest):
+                    for Files in files:
+                        count += 1
+                if count == 0:
+                    import shutil
+                    shutil.rmtree(dest)
+                    os.symlink(linkto, dest)
             if not os.path.islink(dest):
                 raise OSError(errno.EEXIST, "Link %s already exists as a file" % dest, dest)
             if os.readlink(dest) == linkto:
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-10-19  4:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 11:46 [PATCH] state/staging: Fix directory not deleted for race Pgowda
2021-09-16  7:45 ` Richard Purdie
     [not found] ` <16A53DBD300C0C8E.4388@lists.openembedded.org>
2021-09-16  7:53   ` [OE-core] " Richard Purdie
2021-09-16  8:28     ` Pgowda
2021-09-28 15:12       ` Randy MacLeod
2021-09-28 20:21       ` Richard Purdie
2021-10-01  7:24         ` [PATCH v2] " Pgowda
2021-10-18 12:53           ` Richard Purdie
2021-10-18 13:47             ` pgowda cve
2021-10-18 14:52               ` Richard Purdie
2021-10-18 14:59                 ` [OE-core] " Martin Jansa
2021-10-19  4:43                 ` pgowda cve
2021-10-01  7:28         ` [OE-core] [PATCH] " pgowda cve
     [not found]         ` <16A9D78EAA10C9CD.7289@lists.openembedded.org>
2021-10-18  7:43           ` pgowda cve

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.