All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed
@ 2014-04-30 13:01 Radek Dostal
  2014-04-30 15:46 ` Richard Purdie
  0 siblings, 1 reply; 5+ messages in thread
From: Radek Dostal @ 2014-04-30 13:01 UTC (permalink / raw)
  To: openembedded-core; +Cc: Radek Dostal

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
+            then
+                sed -i -e s:${D}::g "$i"
+            fi
         done
 
         if test -e ${D}${bindir} ; then	
-- 
1.7.9.5



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

* Re: [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed
  2014-04-30 13:01 [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed Radek Dostal
@ 2014-04-30 15:46 ` Richard Purdie
  2014-05-02  9:00   ` Radek Dostal
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2014-04-30 15:46 UTC (permalink / raw)
  To: Radek Dostal; +Cc: openembedded-core

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
> 




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

* [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed
  2014-04-30 15:46 ` Richard Purdie
@ 2014-05-02  9:00   ` Radek Dostal
  2014-05-03  1:36     ` Christopher Larson
  0 siblings, 1 reply; 5+ messages in thread
From: Radek Dostal @ 2014-05-02  9:00 UTC (permalink / raw)
  To: richard.purdie; +Cc: Radek Dostal, openembedded-core

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..18e1a34 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 (grep "${D}" "$i") >/dev/null 2>&1
+            then
+                sed -i -e s:${D}::g "$i"
+            fi
         done
 
         if test -e ${D}${bindir} ; then	
-- 
1.7.9.5



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

* Re: [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed
  2014-05-02  9:00   ` Radek Dostal
@ 2014-05-03  1:36     ` Christopher Larson
  2014-05-05  7:38       ` [PATCH v3] " Radek Dostal
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Larson @ 2014-05-03  1:36 UTC (permalink / raw)
  To: Radek Dostal; +Cc: Patches and discussions about the oe-core layer

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

On Fri, May 2, 2014 at 2:00 AM, Radek Dostal <
radek.dostal@streamunlimited.com> wrote:

> -            sed -i -e s:${D}::g "$i"
> +            # only modify file if it contains path to avoid recompilation
> on the target
> +            if (grep "${D}" "$i") >/dev/null 2>&1


If you're to go this route, I'd suggest:

    if grep -q "${D}" "$i"; then

Avoids the unnecessary re-directions, and unnecessary sub-shell.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

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

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

* [PATCH v3] distutils.bbclass: only modify *.py file if it contains path to be removed
  2014-05-03  1:36     ` Christopher Larson
@ 2014-05-05  7:38       ` Radek Dostal
  0 siblings, 0 replies; 5+ messages in thread
From: Radek Dostal @ 2014-05-05  7:38 UTC (permalink / raw)
  To: clarson; +Cc: Radek Dostal, openembedded-core

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 |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index f3da023..12f2603 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -43,7 +43,10 @@ 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 grep -q "${D}" "$i"; then
+                sed -i -e s:${D}::g "$i"
+            fi
         done
 
         if test -e ${D}${bindir} ; then	
-- 
1.7.9.5



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

end of thread, other threads:[~2014-05-05  7:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 13:01 [PATCH] distutils.bbclass: only modify *.py file if it contains path to be removed Radek Dostal
2014-04-30 15:46 ` Richard Purdie
2014-05-02  9:00   ` Radek Dostal
2014-05-03  1:36     ` Christopher Larson
2014-05-05  7:38       ` [PATCH v3] " Radek Dostal

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.