[poky] [PATCH] rm_work.bbclass: allow a shell var to override rm_work

Frans Meulenbroeks fransmeulenbroeks at gmail.com
Sun Dec 12 07:02:12 PST 2010


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 at gmail.com>
---
 meta/classes/rm_work.bbclass |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/meta/classes/rm_work.bbclass b/meta/classes/rm_work.bbclass
index 53fcda2..45d2830 100644
--- a/meta/classes/rm_work.bbclass
+++ b/meta/classes/rm_work.bbclass
@@ -14,22 +14,25 @@ RMWORK_ORIG_TASK := "${BB_DEFAULT_TASK}"
 BB_DEFAULT_TASK = "rm_work_all"
 
 do_rm_work () {
-    # Ensure pseudo is no longer active
-    if [ -d ${WORKDIR}/pseudo ]; then
-        ${FAKEROOT} -S
-    fi
-    cd ${WORKDIR}
-    for dir in *
-    do
-        if [ `basename ${S}` = $dir ]; then
-            rm -rf $dir
-        elif [ $dir != 'temp' ]; then
-            rm -rf $dir
+    if [ ! $KEEP_WORK ]
+    then
+        # Ensure pseudo is no longer active
+        if [ -d ${WORKDIR}/pseudo ]; then
+            ${FAKEROOT} -S
         fi
-    done
-    # Need to add pseudo back or subsqeuent work in this workdir
-    # might fail since setscene may not rerun to recreate it
-    mkdir ${WORKDIR}/pseudo/
+        cd ${WORKDIR}
+        for dir in *
+        do
+            if [ `basename ${S}` = $dir ]; then
+                rm -rf $dir
+            elif [ $dir != 'temp' ]; then
+                rm -rf $dir
+            fi
+        done
+        # Need to add pseudo back or subsqeuent work in this workdir
+        # might fail since setscene may not rerun to recreate it
+        mkdir ${WORKDIR}/pseudo/
+    fi
 }
 addtask rm_work after do_${RMWORK_ORIG_TASK}
 
-- 
1.6.4.2




More information about the poky mailing list