Skip to contentSkip to conversation

kernel.bbclass: make do_symlink_kernelsrc reentrant

PATCH Etienne Cordonnier 2 participants 5 messages Dec 21, 2023 – Feb 4, 2024 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

patch v5: added ignore_dangling_symlinks to avoid error when linux sources contain dangling symlinks

Quoted 63 lines · Etienne Cordonnier via lists.openembedded.org

From: Etienne Cordonnier <[email protected]>

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
<https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=e9FG4cG4GbLjCy8loEN6qVisSUax4Ngvd_Ok8TPonvY&e=>

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
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes-recipe/kernel.bbclass +0 -0
index 9ff37f5c38..45b63f1fa1 100644
@@ -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]
meta/classes-recipe/kernel.bbclass +7 -2
-        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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#192850):
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_message_192850&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=nSj1eesCBnUi3mKI3TDrQr4rYtnlCUqYquM2YdP3kwc&e=
Mute This Topic:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_mt_103308574_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=xqoor0ld3IbCh7N9Dbyl9PAlnSZbl2j66iPA0PYKAl0&e=
Group Owner: [email protected] Unsubscribe:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=cvRKeVUNWw1O0f_mV9dU_qkoh5ifOuu8pqC7Wg81hSg&e=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
In reply to a message not in the archive

Hi,
what is the status of this patch? Was it rejected?

Étienne

Quoted 75 lines · Etienne Cordonnier via lists.openembedded.org

patch v5: added ignore_dangling_symlinks to avoid error when linux sources contain dangling symlinks

On Thu, Dec 21, 2023 at 10:49 PM Etienne Cordonnier via lists.openembedded.org
<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=Af3lZ-qHdVwBo6b8tlJ45PXYNer8GU6q0uxJ740caCA&e=>

Quoted 49 lines · <[email protected]> wrote:

From: Etienne Cordonnier <[email protected]>

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
<https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=e9FG4cG4GbLjCy8loEN6qVisSUax4Ngvd_Ok8TPonvY&e=>

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
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes-recipe/kernel.bbclass +0 -0
index 9ff37f5c38..45b63f1fa1 100644
@@ -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]
meta/classes-recipe/kernel.bbclass +1 -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

meta/classes-recipe/kernel.bbclass +6 -1
+            # 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)
 }
--
Quoted 5 lines

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#192851):
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_message_192851&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=B4VcMp4VsG3L9jLpib5LmpAeOIt_ttUjQEayF-XUy_4&e=
Mute This Topic:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_mt_103308574_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=5tvkZnNNtvxAsWwN88Hi9dl8qljZl0T9lLH0iQgy0Z0&e=
Group Owner: [email protected] Unsubscribe:
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=Ka7j1CI_uOKYxtXQbSnfvzJwM4X1moECnj3FEMOL_UI&e=
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 3 lines · Etienne Cordonnier via lists.openembedded.org

Hi,
what is the status of this patch? Was it rejected?

I'll test it again because I don't remember but I possibly add a build/test failure.

Quoted 80 lines

Étienne

Quoted 54 lines · Etienne Cordonnier via lists.openembedded.org

patch v5: added ignore_dangling_symlinks to avoid error when linux sources contain dangling symlinks

On Thu, Dec 21, 2023 at 10:49 PM Etienne Cordonnier via lists.openembedded.org
<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=Af3lZ-qHdVwBo6b8tlJ45PXYNer8GU6q0uxJ740caCA&e=>

Quoted 46 lines · <[email protected]> wrote:

From: Etienne Cordonnier <[email protected]>

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
<https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=e9FG4cG4GbLjCy8loEN6qVisSUax4Ngvd_Ok8TPonvY&e=>

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
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes-recipe/kernel.bbclass +0 -0
index 9ff37f5c38..45b63f1fa1 100644
@@ -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]
meta/classes-recipe/kernel.bbclass +1 -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

meta/classes-recipe/kernel.bbclass +6 -0
+            # 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)
Quoted 11 lines
Quoted 8 lines

os.symlink(kernsrc, s)
}
--
2.34.1

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

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

Thanks, note that based on the discussion at
https://lists.openembedded.org/g/openembedded-core/message/192676?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Acreated%2C0%2Creentrant%2C20%2C2%2C0%2C103208527
I indeed expect a build failure on an incremental build where S is overridden, and the existing build directory has an "incorrect" structure due to a previous build. In this case a one-time clean of the kernel is required.

Quoted 112 lines · Alexandre Belloni
Quoted 3 lines · Etienne Cordonnier via lists.openembedded.org

Hi,
what is the status of this patch? Was it rejected?

I'll test it again because I don't remember but I possibly add a build/test failure.

Quoted 4 lines

Étienne

On Thu, Dec 21, 2023 at 10:50 PM Etienne Cordonnier via lists.openembedded.org <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

patch v5: added ignore_dangling_symlinks to avoid error when linux

sources

Quoted 5 lines
Quoted 5 lines

contain dangling symlinks

On Thu, Dec 21, 2023 at 10:49 PM Etienne Cordonnier via lists.openembedded.org
<

https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=Af3lZ-qHdVwBo6b8tlJ45PXYNer8GU6q0uxJ740caCA&e=

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines · <[email protected]> wrote:

From: Etienne Cordonnier <[email protected]>

The function do_symlink_kernsrc is not reentrant in the case where S

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=01DEoIZCmVtfygqQ3U_vRyh1Y1G_g-TrnrOOEXd0ysU&e=

Quoted 1 line
Quoted 1 line
Quoted 1 line

<

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=e9FG4cG4GbLjCy8loEN6qVisSUax4Ngvd_Ok8TPonvY&e=

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Tested with a recipe "my-custom-linux" which unpacks sources to a

custom

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

${S} directory
and ran symlink_kernsrc several times:

$ bitbake -f -c symlink_kernsrc my-custom-linux
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
meta/classes-recipe/kernel.bbclass +0 -0
index 9ff37f5c38..45b63f1fa1 100644
Quoted 8 lines

meta/classes-recipe/kernel.bbclass

Quoted 8 lines
meta/classes-recipe/kernel.bbclass +0 -0
@@ -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]
meta/classes-recipe/kernel.bbclass +1 -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

Quoted 8 lines
Quoted 8 lines

meta/classes-recipe/kernel.bbclass

Quoted 8 lines

it
os.symlink(s, kernsrc)
else:
import shutil

meta/classes-recipe/kernel.bbclass +4 -0
+            # perform idempotent/reentrant copy
+            s_copy = s + ".orig"
+            if not os.path.isdir(s_copy):
+                shutil.copytree(s, s_copy,

ignore_dangling_symlinks=True)

Quoted 16 lines
Quoted 14 lines
Quoted 11 lines
meta/classes-recipe/kernel.bbclass +2 -1
+            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

Quoted 3 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#194496):

https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_message_194496&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=G7I8YhqpwqafPUBBHcpFpmThNk5vTFfDQAA3EdTet9U&e=

Quoted 1 line

Mute This Topic:

https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_mt_104055728_3617179&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=7KEXcFZJh3ku2w0FRlLPGNz6p-IBgg7CaGGFAfBHrnA&e=

Quoted 2 lines

Group Owner: [email protected] Unsubscribe:

https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_openembedded-2Dcore_unsub&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=Y9laBkE0P4fGE0KBQVjm585hG7rjyw1Zh2YxwQ5crX0&e=
[[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering

https://urldefense.proofpoint.com/v2/url?u=https-3A__bootlin.com&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=3OVhEgy2jWuMpzbOdK2jsZDChCURAw-6geaZ2FOllTs&e=

#6 lore raw
Quoted 6 lines · Etienne Cordonnier via lists.openembedded.org

Thanks, note that based on the discussion at
https://lists.openembedded.org/g/openembedded-core/message/192676?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Acreated%2C0%2Creentrant%2C20%2C2%2C0%2C103208527
I indeed expect a build failure on an incremental build where S is overridden, and the existing build directory has an "incorrect" structure due to a previous build. In this case a one-time clean of the kernel is required.

Actually, I've been carrying the patch for a while and it is waiting to be reviewed/applied.

Quoted 116 lines
Quoted 96 lines · Alexandre Belloni
Quoted 3 lines · Etienne Cordonnier via lists.openembedded.org

Hi,
what is the status of this patch? Was it rejected?

I'll test it again because I don't remember but I possibly add a build/test failure.

Quoted 4 lines

Étienne

On Thu, Dec 21, 2023 at 10:50 PM Etienne Cordonnier via lists.openembedded.org <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines

patch v5: added ignore_dangling_symlinks to avoid error when linux

sources

Quoted 5 lines
Quoted 5 lines

contain dangling symlinks

On Thu, Dec 21, 2023 at 10:49 PM Etienne Cordonnier via lists.openembedded.org
<

https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.openembedded.org&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=UCoMTsJKrnqkV-eQGGRGBeC-wIGTP7H0LRPvcTWkn9673LluHqkCpFInRctDEEct&s=Af3lZ-qHdVwBo6b8tlJ45PXYNer8GU6q0uxJ740caCA&e=

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines · <[email protected]> wrote:

From: Etienne Cordonnier <[email protected]>

The function do_symlink_kernsrc is not reentrant in the case where S

is

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=01DEoIZCmVtfygqQ3U_vRyh1Y1G_g-TrnrOOEXd0ysU&e=

Quoted 1 line
Quoted 1 line
Quoted 1 line

<

https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.yoctoproject.org_show-5Fbug.cgi-3Fid-3D15325&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=eo9dzHi2uXPV1dA2f4GoA6Y7QoDiG2TTF1R2YQ__SwnF1U1d0O2JxX3PprS_T9BN&s=e9FG4cG4GbLjCy8loEN6qVisSUax4Ngvd_Ok8TPonvY&e=

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Tested with a recipe "my-custom-linux" which unpacks sources to a

custom

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

${S} directory
and ran symlink_kernsrc several times:

$ bitbake -f -c symlink_kernsrc my-custom-linux
---
 meta/classes-recipe/kernel.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
meta/classes-recipe/kernel.bbclass +0 -0
index 9ff37f5c38..45b63f1fa1 100644
Quoted 8 lines

meta/classes-recipe/kernel.bbclass

Quoted 8 lines
meta/classes-recipe/kernel.bbclass +0 -0
@@ -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]
meta/classes-recipe/kernel.bbclass +1 -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

Quoted 8 lines
Quoted 8 lines

meta/classes-recipe/kernel.bbclass

Quoted 8 lines

it
os.symlink(s, kernsrc)
else:
import shutil

meta/classes-recipe/kernel.bbclass +4 -0
+            # perform idempotent/reentrant copy
+            s_copy = s + ".orig"
+            if not os.path.isdir(s_copy):
+                shutil.copytree(s, s_copy,

ignore_dangling_symlinks=True)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/classes-recipe/kernel.bbclass +2 -1
+            bb.utils.remove(s, recurse=True)
+            shutil.copytree(s_copy, s, ignore_dangling_symlinks=True)
             shutil.move(s, kernsrc)
             os.symlink(kernsrc, s)
 }
--
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines

2.34.1

Quoted 6 lines

--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering

https://urldefense.proofpoint.com/v2/url?u=https-3A__bootlin.com&d=DwIDaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=iKgaTl7foinidQ3odGNYB-M4jWUTar8G6CFMlnChcA57K40tJPv4CtbC0vRLjJpq&s=3OVhEgy2jWuMpzbOdK2jsZDChCURAw-6geaZ2FOllTs&e=

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

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com