All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH v5] kernel.bbclass: make do_symlink_kernelsrc reentrant
@ 2023-12-22 10:11 ecordonnier
  0 siblings, 0 replies; 10+ messages in thread
From: ecordonnier @ 2023-12-22 10:11 UTC (permalink / raw)
  To: openembedded-core; +Cc: Etienne Cordonnier

From: Etienne Cordonnier <ecordonnier@snap.com>

The function do_symlink_kernsrc is not reentrant in the case where S is defined
to a non-default value. This causes build-failures e.g. when building linux-yocto, then updating
poky to a commit which modifies kernel.bbclass, and then building linux-yocto again.

Bugzilla: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15325

Tested with a recipe "my-custom-linux" which unpacks sources to a custom ${S} directory
and ran symlink_kernsrc several times:
$ bitbake -f -c symlink_kernsrc my-custom-linux

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 9ff37f5c38..45b63f1fa1 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -189,11 +189,17 @@ python do_symlink_kernsrc () {
             # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as
             # directory name and fail
             s = s[:-1]
-        if d.getVar("EXTERNALSRC"):
+        if d.getVar("EXTERNALSRC") and not os.path.islink(s):
             # With EXTERNALSRC S will not be wiped so we can symlink to it
             os.symlink(s, kernsrc)
         else:
             import shutil
+            # perform idempotent/reentrant copy
+            s_copy = s + ".orig"
+            if not os.path.isdir(s_copy):
+                shutil.copytree(s, s_copy, ignore_dangling_symlinks=True)
+            bb.utils.remove(s, recurse=True)
+            shutil.copytree(s_copy, s, ignore_dangling_symlinks=True)
             shutil.move(s, kernsrc)
             os.symlink(kernsrc, s)
 }
-- 
2.36.1.vfs.0.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [OE-core][PATCH v5] kernel.bbclass: make do_symlink_kernelsrc reentrant
@ 2023-12-21 21:49 Etienne Cordonnier
  2024-02-09 17:36 ` Richard Purdie
  0 siblings, 1 reply; 10+ messages in thread
From: Etienne Cordonnier @ 2023-12-21 21:49 UTC (permalink / raw)
  To: openembedded-core; +Cc: Etienne Cordonnier

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

From: Etienne Cordonnier <ecordonnier@snap.com>

The function do_symlink_kernsrc is not reentrant in the case where S is
defined
to a non-default value. This causes build-failures e.g. when building
linux-yocto, then updating
poky to a commit which modifies kernel.bbclass, and then building
linux-yocto again.

Bugzilla: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15325

Tested with a recipe "my-custom-linux" which unpacks sources to a custom
${S} directory
and ran symlink_kernsrc several times:
$ bitbake -f -c symlink_kernsrc my-custom-linux

Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/meta/classes-recipe/kernel.bbclass
b/meta/classes-recipe/kernel.bbclass
index 9ff37f5c38..45b63f1fa1 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -189,11 +189,17 @@ python do_symlink_kernsrc () {
             # drop trailing slash, so that os.symlink(kernsrc, s) doesn't
use s as
             # directory name and fail
             s = s[:-1]
-        if d.getVar("EXTERNALSRC"):
+        if d.getVar("EXTERNALSRC") and not os.path.islink(s):
             # With EXTERNALSRC S will not be wiped so we can symlink to it
             os.symlink(s, kernsrc)
         else:
             import shutil
+            # perform idempotent/reentrant copy
+            s_copy = s + ".orig"
+            if not os.path.isdir(s_copy):
+                shutil.copytree(s, s_copy, ignore_dangling_symlinks=True)
+            bb.utils.remove(s, recurse=True)
+            shutil.copytree(s_copy, s, ignore_dangling_symlinks=True)
             shutil.move(s, kernsrc)
             os.symlink(kernsrc, s)
 }
-- 
2.34.1

[-- Attachment #2: Type: text/html, Size: 2245 bytes --]

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

end of thread, other threads:[~2024-05-27 18:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <17A2F72F5D272934.28089@lists.openembedded.org>
2023-12-21 21:50 ` [OE-core][PATCH v5] kernel.bbclass: make do_symlink_kernelsrc reentrant Etienne Cordonnier
     [not found] ` <17A2F73D8934EE37.10357@lists.openembedded.org>
2024-01-30 15:39   ` Etienne Cordonnier
2024-01-31 16:53     ` Alexandre Belloni
2024-01-31 17:17       ` Etienne Cordonnier
2024-02-04 14:15         ` Alexandre Belloni
2023-12-22 10:11 ecordonnier
  -- strict thread matches above, loose matches on Subject: below --
2023-12-21 21:49 Etienne Cordonnier
2024-02-09 17:36 ` Richard Purdie
2024-05-27  9:45   ` Etienne Cordonnier
2024-05-27 18:34     ` Alexandre Belloni

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.