All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pgowda" <pgowda.cve@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: richard.purdie@linuxfoundation.org, rwmacleod@gmail.com,
	umesh.kalappa0@gmail.com, vinay.m.engg@gmail.com,
	Pgowda <pgowda.cve@gmail.com>
Subject: [PATCH] state/staging: Fix directory not deleted for race
Date: Wed, 15 Sep 2021 04:46:18 -0700	[thread overview]
Message-ID: <20210915114618.157245-1-pgowda.cve@gmail.com> (raw)

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


             reply	other threads:[~2021-09-15 11:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 11:46 Pgowda [this message]
2021-09-16  7:45 ` [PATCH] state/staging: Fix directory not deleted for race 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210915114618.157245-1-pgowda.cve@gmail.com \
    --to=pgowda.cve@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    --cc=rwmacleod@gmail.com \
    --cc=umesh.kalappa0@gmail.com \
    --cc=vinay.m.engg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.