diff mbox series

kernel-devsrc: fix incorrect python shebang replacement

Message ID 20251028021830.3937223-1-jiaying.song.cn@windriver.com
State New
Headers show
Series kernel-devsrc: fix incorrect python shebang replacement | expand

Commit Message

Song, Jiaying (CN) Oct. 28, 2025, 2:18 a.m. UTC
From: Jiaying Song <jiaying.song.cn@windriver.com>

Update the replacement strategy to use a stricter pattern that matches
all versioned python paths and correctly replaces them with
'/usr/bin/env python3'.

The previous sed rule would incorrectly change the Python shebang in
/lib/modules/6.16.11-yocto-standard/build/scripts/macro_checker.py from
'#!/usr/bin/python3' to '#!/usr/bin/env python33'.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bruce Ashfield Oct. 28, 2025, 4:01 a.m. UTC | #1
On Mon, Oct 27, 2025 at 10:18 PM Song, Jiaying (CN) via
lists.openembedded.org <Jiaying.Song.CN=windriver.com@lists.openembedded.org>
wrote:

> From: Jiaying Song <jiaying.song.cn@windriver.com>
>
> Update the replacement strategy to use a stricter pattern that matches
> all versioned python paths and correctly replaces them with
> '/usr/bin/env python3'.
>
> The previous sed rule would incorrectly change the Python shebang in
> /lib/modules/6.16.11-yocto-standard/build/scripts/macro_checker.py from
> '#!/usr/bin/python3' to '#!/usr/bin/env python33'.
>
> Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
> ---
>  meta/recipes-kernel/linux/kernel-devsrc.bb | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb
> b/meta/recipes-kernel/linux/kernel-devsrc.bb
> index 04dd683dde..aaed0cd127 100644
> --- a/meta/recipes-kernel/linux/kernel-devsrc.bb
> +++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
> @@ -400,7 +400,7 @@ do_install() {
>      for ss in $(find $kerneldir/build/scripts -type f -name '*'); do
>          sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss"
>          sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss"
> -        sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss"
> +        sed -i 's,/usr/bin/python[0-9.]*,/usr/bin/env python3,' "$ss"
>

An anchored expression would be better. We are only interested
in changing "python" to "python3", not python3 to python3 or python33 to
python3, etc.

Bruce



>      done
>
>      chown -R root:root ${D}
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#225372):
> https://lists.openembedded.org/g/openembedded-core/message/225372
> Mute This Topic: https://lists.openembedded.org/mt/115987922/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Song, Jiaying (CN) Oct. 28, 2025, 10:21 a.m. UTC | #2
Hi Bruce,

Thanks for the feedback. I have updated the patch and sent a v2 that addresses the strict matching issue.

Best regards,
Jiaying
From: Bruce Ashfield <bruce.ashfield@gmail.com>
Sent: Tuesday, October 28, 2025 12:01 PM
To: Song, Jiaying (CN) <Jiaying.Song.CN@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH] kernel-devsrc: fix incorrect python shebang replacement

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.


On Mon, Oct 27, 2025 at 10:18 PM Song, Jiaying (CN) via lists.openembedded.org<https://urldefense.com/v3/__http:/lists.openembedded.org__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo8u3haXJ$> <Jiaying.Song.CN<https://urldefense.com/v3/__http:/Jiaying.Song.CN__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5i3G-56$>=windriver.com@lists.openembedded.org<mailto:windriver.com@lists.openembedded.org>> wrote:
From: Jiaying Song <jiaying.song.cn@windriver.com<mailto:jiaying.song.cn@windriver.com>>

Update the replacement strategy to use a stricter pattern that matches
all versioned python paths and correctly replaces them with
'/usr/bin/env python3'.

The previous sed rule would incorrectly change the Python shebang in
/lib/modules/6.16.11-yocto-standard/build/scripts/macro_checker.py<https://urldefense.com/v3/__http:/macro_checker.py__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo_z9RkBW$> from
'#!/usr/bin/python3' to '#!/usr/bin/env python33'.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com<mailto:jiaying.song.cn@windriver.com>>
---
 meta/recipes-kernel/linux/kernel-devsrc.bb<https://urldefense.com/v3/__http:/kernel-devsrc.bb__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5EJdzLy$> | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb<https://urldefense.com/v3/__http:/kernel-devsrc.bb__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5EJdzLy$> b/meta/recipes-kernel/linux/kernel-devsrc.bb<https://urldefense.com/v3/__http:/kernel-devsrc.bb__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5EJdzLy$>
index 04dd683dde..aaed0cd127 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb<https://urldefense.com/v3/__http:/kernel-devsrc.bb__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5EJdzLy$>
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb<https://urldefense.com/v3/__http:/kernel-devsrc.bb__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5EJdzLy$>
@@ -400,7 +400,7 @@ do_install() {
     for ss in $(find $kerneldir/build/scripts -type f -name '*'); do
         sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss"
         sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss"
-        sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss"
+        sed -i 's,/usr/bin/python[0-9.]*,/usr/bin/env python3,' "$ss"

An anchored expression would be better. We are only interested
in changing "python" to "python3", not python3 to python3 or python33 to python3, etc.

Bruce


     done

     chown -R root:root ${D}
--
2.34.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#225372): https://lists.openembedded.org/g/openembedded-core/message/225372<https://urldefense.com/v3/__https:/lists.openembedded.org/g/openembedded-core/message/225372__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVoz32U288$>
Mute This Topic: https://lists.openembedded.org/mt/115987922/1050810<https://urldefense.com/v3/__https:/lists.openembedded.org/mt/115987922/1050810__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVoySeYYE8$>
Group Owner: openembedded-core+owner@lists.openembedded.org<mailto:openembedded-core%2Bowner@lists.openembedded.org>
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub<https://urldefense.com/v3/__https:/lists.openembedded.org/g/openembedded-core/unsub__;!!AjveYdw8EvQ!Zz9UdfJDRZUR88v-qhUt7_2VLP9bIYVpgbjDjWGBLFR0N0IfaqQnSPOIf_Mt7bwvkvGY872TAojXiiBMSw0dA9QVo5vMhCUR$> [bruce.ashfield@gmail.com<mailto:bruce.ashfield@gmail.com>]
-=-=-=-=-=-=-=-=-=-=-=-


--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
diff mbox series

Patch

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 04dd683dde..aaed0cd127 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -400,7 +400,7 @@  do_install() {
     for ss in $(find $kerneldir/build/scripts -type f -name '*'); do
         sed -i 's,/usr/bin/python2,/usr/bin/env python3,' "$ss"
         sed -i 's,/usr/bin/env python2,/usr/bin/env python3,' "$ss"
-        sed -i 's,/usr/bin/python,/usr/bin/env python3,' "$ss"
+        sed -i 's,/usr/bin/python[0-9.]*,/usr/bin/env python3,' "$ss"
     done
 
     chown -R root:root ${D}