]> code.ossystems Code Review - openembedded-core.git/commitdiff
base/sstate: Add cleanall task to remove downloads and sstate cached files
authorRichard Purdie <rpurdie@linux.intel.com>
Fri, 22 Oct 2010 09:22:34 +0000 (10:22 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 22 Oct 2010 09:22:34 +0000 (10:22 +0100)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
meta/classes/base.bbclass
meta/classes/sstate.bbclass

index aee75297eb06b0fc6d03f1f59249b9ed654a102e..1547ed0305f096cd0665ab4ae4ee3a200db95cda 100644 (file)
@@ -621,4 +621,32 @@ def check_gcc3(data):
        
        return False
 
+addtask cleanall after do_clean
+python do_cleanall() {
+        sstate_clean_cachefiles(d)
+
+       localdata = bb.data.createCopy(d)
+       bb.data.update_data(localdata)
+
+       dl_dir = bb.data.getVar('DL_DIR', localdata, True)
+       dl_dir = os.path.realpath(dl_dir)
+
+       src_uri = bb.data.getVar('SRC_URI', localdata, True)
+       if not src_uri:
+               return
+       for url in src_uri.split():
+               try:
+                       local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
+               except bb.MalformedUrl, e:
+                       raise FuncFailed('Unable to generate local path for malformed uri: %s' % e)
+               if local is None:
+                       continue
+               local = os.path.realpath(local)
+                if local.startswith(dl_dir):
+                       bb.note("Removing %s*" % local)
+                       oe.path.remove(local + "*")
+}
+do_cleanall[nostamp] = "1"
+
+
 EXPORT_FUNCTIONS do_setscene do_fetch do_unpack do_configure do_compile do_install do_package
index 4a63d37d20de0cf60959dfbdfabed73662ac153f..92c3a274f044203891ccff9741bfd4e813497507 100644 (file)
@@ -44,11 +44,12 @@ def sstate_init(name, d):
     ss['lockfiles'] = []
     return ss
 
-def sstate_state_fromvars(d):
-    task = bb.data.getVar('BB_CURRENTTASK', d, True)
-    if not task:
-        bb.fatal("sstate code running without task context?!")
-    task = task.replace("_setscene", "")
+def sstate_state_fromvars(d, task = None):
+    if task is None:
+        task = bb.data.getVar('BB_CURRENTTASK', d, True)
+        if not task:
+            bb.fatal("sstate code running without task context?!")
+        task = task.replace("_setscene", "")
 
     name = bb.data.expand(bb.data.getVarFlag("do_" + task, 'sstate-name', d), d)
     inputs = (bb.data.expand(bb.data.getVarFlag("do_" + task, 'sstate-inputdirs', d) or "", d)).split()
@@ -158,6 +159,16 @@ def sstate_installpkg(ss, d):
 
     return True
 
+def sstate_clean_cachefile(ss, d):
+    sstatepkg = bb.data.getVar('SSTATE_PKG', d, True) + '_' + ss['name'] + ".tgz"
+    bb.note("Removing %s" % sstatepkg)
+    oe.path.remove(sstatepkg)
+
+def sstate_clean_cachefiles(d):
+    for task in (bb.data.getVar('SSTATETASKS', d, True) or "").split():
+        ss = sstate_state_fromvars(d, task[3:])
+        sstate_clean_cachefile(ss, d)
+
 def sstate_clean_manifest(manifest, d):
     import oe.path