Patchwork distutils.bbclass: only modify *.py file if it contains path to be removed

login
register
mail settings
Submitter Radek Dostal
Date April 30, 2014, 1:01 p.m.
Message ID <1398862918-1604-1-git-send-email-radek.dostal@streamunlimited.com>
Download mbox | patch
Permalink /patch/71321/
State New
Headers show

Comments

Radek Dostal - April 30, 2014, 1:01 p.m.
Currently sed command touches every single *.py file. This modifies the
timestamp of the file. All *.pyo files will be recompiled during the first
boot, because timestamp will not match. This should be only necessary if
sed command changes the file.

Signed-off-by: Radek Dostal <radek.dostal@streamunlimited.com>
---
 meta/classes/distutils.bbclass |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Richard Purdie - April 30, 2014, 3:46 p.m.
On Wed, 2014-04-30 at 15:01 +0200, Radek Dostal wrote:
> Currently sed command touches every single *.py file. This modifies the
> timestamp of the file. All *.pyo files will be recompiled during the first
> boot, because timestamp will not match. This should be only necessary if
> sed command changes the file.
> 
> Signed-off-by: Radek Dostal <radek.dostal@streamunlimited.com>
> ---
>  meta/classes/distutils.bbclass |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
> index f3da023..cd1d148 100644
> --- a/meta/classes/distutils.bbclass
> +++ b/meta/classes/distutils.bbclass
> @@ -43,7 +43,11 @@ distutils_do_install() {
>  
>          # support filenames with *spaces*
>          find ${D} -name "*.py" -print0 | while read -d $'\0' i ; do \
> -            sed -i -e s:${D}::g "$i"
> +            # only modify file if it contains path to avoid recompilation on the target
> +            if (cat "$i" | grep "${D}") >/dev/null 2>&1

Can we do something here which doesn't involve three different shell
calls please?

Cheers,

Richard


> +            then
> +                sed -i -e s:${D}::g "$i"
> +            fi
>          done
>  
>          if test -e ${D}${bindir} ; then	
> -- 
> 1.7.9.5
>

Patch

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index f3da023..cd1d148 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -43,7 +43,11 @@  distutils_do_install() {
 
         # support filenames with *spaces*
         find ${D} -name "*.py" -print0 | while read -d $'\0' i ; do \
-            sed -i -e s:${D}::g "$i"
+            # only modify file if it contains path to avoid recompilation on the target
+            if (cat "$i" | grep "${D}") >/dev/null 2>&1
+            then
+                sed -i -e s:${D}::g "$i"
+            fi
         done
 
         if test -e ${D}${bindir} ; then