Patchwork [dylan,master] populate_sdk_base: Fix relocate_sdk.py execution on Arch

login
register
mail settings
Submitter Richard Tollerton
Date Oct. 2, 2013, 11:18 p.m.
Message ID <1380755881-17842-1-git-send-email-rich.tollerton@ni.com>
Download mbox | patch
Permalink /patch/59215/
State New
Headers show

Comments

Richard Tollerton - Oct. 2, 2013, 11:18 p.m.
relocate_sdk.py is #!/usr/bin/env python, but is not python3-compatible.
The PEP 394 alias `python2` is sadly not universally supported, so
instead of modifying relocate_sdk.py directly, change the `exec` in
relocate_sdk.sh to use it if it exists.

Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
---
 meta/classes/populate_sdk_base.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Richard Purdie - Oct. 4, 2013, 11:33 a.m.
On Wed, 2013-10-02 at 18:18 -0500, Richard Tollerton wrote:
> relocate_sdk.py is #!/usr/bin/env python, but is not python3-compatible.
> The PEP 394 alias `python2` is sadly not universally supported, so
> instead of modifying relocate_sdk.py directly, change the `exec` in
> relocate_sdk.sh to use it if it exists.
> 
> Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> ---
>  meta/classes/populate_sdk_base.bbclass | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Wasn't the script fixed in master to avoid this problem?

Cheers,

Richard

> diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
> index e5bc0b4..e67d8b6 100644
> --- a/meta/classes/populate_sdk_base.bbclass
> +++ b/meta/classes/populate_sdk_base.bbclass
> @@ -256,8 +256,9 @@ if [ x$tdir = x ] ; then
>     echo "SDK relocate failed, could not create a temporary directory"
>     exit 1
>  fi
> +python_bin="$(command -v python2 2>/dev/null)" || python_bin=python
>  echo "#!/bin/bash" > $tdir/relocate_sdk.sh
> -echo exec ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
> +echo exec $python_bin ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
>  $SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
>  $SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh
>  rm -rf $tdir
Richard Tollerton - Oct. 4, 2013, 4:25 p.m.
D'oh! I checked master for changes to .sh generation but not the .py itself. My bad.

Change 175f20e2 (relocate_sdk.py: make it work also with python 3) appears to work fine.

---
Richard Tollerton <rich.tollerton@ni.com> (512)683-6346


-----Richard Purdie <richard.purdie@linuxfoundation.org> wrote: -----
To: Richard Tollerton <rich.tollerton@ni.com>
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: 10/04/2013 06:34AM
Cc: openembedded-core@lists.openembedded.org, paul.eggleton@linux.intel.com, gratian.crisan@ni.com, ken.sharp@ni.com
Subject: Re: [OE-core] [dylan, master][PATCH] populate_sdk_base: Fix relocate_sdk.py execution on Arch

On Wed, 2013-10-02 at 18:18 -0500, Richard Tollerton wrote:
> relocate_sdk.py is #!/usr/bin/env python, but is not python3-compatible.
> The PEP 394 alias `python2` is sadly not universally supported, so
> instead of modifying relocate_sdk.py directly, change the `exec` in
> relocate_sdk.sh to use it if it exists.
> 
> Signed-off-by: Richard Tollerton <rich.tollerton@ni.com>
> ---
>  meta/classes/populate_sdk_base.bbclass | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Wasn't the script fixed in master to avoid this problem?

Cheers,

Richard

> diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
> index e5bc0b4..e67d8b6 100644
> --- a/meta/classes/populate_sdk_base.bbclass
> +++ b/meta/classes/populate_sdk_base.bbclass
> @@ -256,8 +256,9 @@ if [ x$tdir = x ] ; then
>     echo "SDK relocate failed, could not create a temporary directory"
>     exit 1
>  fi
> +python_bin="$(command -v python2 2>/dev/null)" || python_bin=python
>  echo "#!/bin/bash" > $tdir/relocate_sdk.sh
> -echo exec ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
> +echo exec $python_bin ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
>  $SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
>  $SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh
>  rm -rf $tdir

Patch

diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index e5bc0b4..e67d8b6 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -256,8 +256,9 @@  if [ x$tdir = x ] ; then
    echo "SDK relocate failed, could not create a temporary directory"
    exit 1
 fi
+python_bin="$(command -v python2 2>/dev/null)" || python_bin=python
 echo "#!/bin/bash" > $tdir/relocate_sdk.sh
-echo exec ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
+echo exec $python_bin ${env_setup_script%/*}/relocate_sdk.py $target_sdk_dir $dl_path $executable_files >> $tdir/relocate_sdk.sh
 $SUDO_EXEC mv $tdir/relocate_sdk.sh ${env_setup_script%/*}/relocate_sdk.sh
 $SUDO_EXEC chmod 755 ${env_setup_script%/*}/relocate_sdk.sh
 rm -rf $tdir