Patchwork rm_work.bbclass: allow a shell var to override rm_work

login
register
mail settings
Submitter Frans Meulenbroeks
Date Dec. 12, 2010, 3:03 p.m.
Message ID <1292166229-23112-1-git-send-email-fransmeulenbroeks@gmail.com>
Download mbox | patch
Permalink /patch/53/
State New, archived
Headers show

Comments

Frans Meulenbroeks - Dec. 12, 2010, 3:03 p.m.
Sometimes one is building with rm_work, but for a specific build you want to
keep the work even if the build is successful.
One way to achieve this is to comment the INHERIT += "rm_work" from your
local.conf file, but this means that all recipes need to be reparsed which takes some time.

This patch introduces a variable KEEP_WORK
If this variable is set the work will not be removed.
Intended use is
KEEP_WORK=1 bitbake yourrecipe.bb
Default behaviour is kept the same (in case KEEP_WORK is not set)

Note that in order for this to work KEEP_WORK needs to be added to the env var BB_ENV_EXTRAWHITE
e.g. export BB_ENV_EXTRAWHITE="KEEP_WORK"

We still might want to improve the test so it only keeps the work if KEEP_WORK is > 0
(or do not execute the task at all if KEEP_WORK is not set).
Also we might want to add KEEP_WORK to the whitelist of vars that are always ok

Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
---
 classes/rm_work.bbclass |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
Andreas Oberritter - Dec. 14, 2010, 12:51 p.m.
On 12/12/2010 04:03 PM, Frans Meulenbroeks wrote:
> Sometimes one is building with rm_work, but for a specific build you want to
> keep the work even if the build is successful.
> One way to achieve this is to comment the INHERIT += "rm_work" from your
> local.conf file, but this means that all recipes need to be reparsed which takes some time.
> 
> This patch introduces a variable KEEP_WORK
> If this variable is set the work will not be removed.
> Intended use is
> KEEP_WORK=1 bitbake yourrecipe.bb
> Default behaviour is kept the same (in case KEEP_WORK is not set)
> 
> Note that in order for this to work KEEP_WORK needs to be added to the env var BB_ENV_EXTRAWHITE
> e.g. export BB_ENV_EXTRAWHITE="KEEP_WORK"
> 
> We still might want to improve the test so it only keeps the work if KEEP_WORK is > 0
> (or do not execute the task at all if KEEP_WORK is not set).
> Also we might want to add KEEP_WORK to the whitelist of vars that are always ok
> 
> Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>

I'd prefer a variable with a prefix like OE_, but that's probably just a
matter of taste. Are there any guidelines?

This patch motivates me to enable rm_work by default for our distro. It
would be nice if this variable would become documented on the wiki.

Acked-by: Andreas Oberritter <obi@opendreambox.org>
Frans Meulenbroeks - Dec. 14, 2010, 7:23 p.m.
2010/12/14 Andreas Oberritter <obi@opendreambox.org>:
> On 12/12/2010 04:03 PM, Frans Meulenbroeks wrote:
>> Sometimes one is building with rm_work, but for a specific build you want to
>> keep the work even if the build is successful.
>> One way to achieve this is to comment the INHERIT += "rm_work" from your
>> local.conf file, but this means that all recipes need to be reparsed which takes some time.
>>
>> This patch introduces a variable KEEP_WORK
>> If this variable is set the work will not be removed.
>> Intended use is
>> KEEP_WORK=1 bitbake yourrecipe.bb
>> Default behaviour is kept the same (in case KEEP_WORK is not set)
>>
>> Note that in order for this to work KEEP_WORK needs to be added to the env var BB_ENV_EXTRAWHITE
>> e.g. export BB_ENV_EXTRAWHITE="KEEP_WORK"
>>
>> We still might want to improve the test so it only keeps the work if KEEP_WORK is > 0
>> (or do not execute the task at all if KEEP_WORK is not set).
>> Also we might want to add KEEP_WORK to the whitelist of vars that are always ok
>>
>> Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
>
> I'd prefer a variable with a prefix like OE_, but that's probably just a
> matter of taste. Are there any guidelines?
>
> This patch motivates me to enable rm_work by default for our distro. It
> would be nice if this variable would become documented on the wiki.
>
> Acked-by: Andreas Oberritter <obi@opendreambox.org>
>
>
I can document it if it becomes accepted behaviour.
Wrt the naming: I have no real preference.
I'm not aware of any guidelines

Frans

Patch

diff --git a/classes/rm_work.bbclass b/classes/rm_work.bbclass
index e6f3aa0..cab74cc 100644
--- a/classes/rm_work.bbclass
+++ b/classes/rm_work.bbclass
@@ -14,15 +14,18 @@  RMWORK_ORIG_TASK := "${BB_DEFAULT_TASK}"
 BB_DEFAULT_TASK = "rm_work_all"
 
 do_rm_work () {
-    cd ${WORKDIR}
-    for dir in *
-    do
-        if [ `basename ${dir}` = "temp" ]; then
-            echo "Not removing temp"
-        else 
-            echo "Removing $dir" ; rm -rf $dir
-        fi
-    done
+    if [ ! ${KEEP_WORK} ]
+    then
+        cd ${WORKDIR}
+        for dir in *
+        do
+            if [ `basename ${dir}` = "temp" ]; then
+                echo "Not removing temp"
+            else 
+                echo "Removing $dir" ; rm -rf $dir
+            fi
+        done
+    fi
 }
 addtask rm_work after do_${RMWORK_ORIG_TASK}