[V2] utility-tasks.bbclass: Add distclean task for removing sources

Submitted by Noor Ahsan on April 11, 2012, 11:49 a.m.

Details

Message ID 1334144991-2630-1-git-send-email-noor_ahsan@mentor.com
State New
Headers show

Commit Message

Noor Ahsan April 11, 2012, 11:49 a.m.
From: Noor Ahsan <noor_ahsan@mentor.com>

* Bring distclean task from openembedded classic.

Signed-off-by: Noor Ahsan <noor_ahsan@mentor.com>
---
 meta/classes/utility-tasks.bbclass |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta/classes/utility-tasks.bbclass b/meta/classes/utility-tasks.bbclass
index cbb000a..8379de6 100644
--- a/meta/classes/utility-tasks.bbclass
+++ b/meta/classes/utility-tasks.bbclass
@@ -28,6 +28,36 @@  python do_clean() {
 		bb.build.exec_func(f, d)
 }
 
+addtask distclean
+do_distclean[nostamp] = "1"
+python do_distclean() {
+	"""clear downloaded sources, build and temp directories"""
+
+	bb.build.exec_func('do_clean', d)
+
+	src_uri = bb.data.getVar('SRC_URI', d, 1)
+	if not src_uri:
+		return
+
+	for uri in src_uri.split():
+		if bb.decodeurl(uri)[0] == "file":
+			continue
+
+		try:
+			local = bb.data.expand(bb.fetch.localpath(uri, d), d)
+		except bb.MalformedUrl, e:
+			bb.debug(1, 'Unable to generate local path for malformed uri: %s' % e)
+		else:
+			bb.note("removing %s" % base_path_out(local, d))
+			try:
+				if os.path.exists(local + ".done"):
+					os.remove(local + ".done")
+				if os.path.exists(local):
+					os.remove(local)
+			except OSError, e:
+				bb.note("Error in removal: %s" % e)
+}
+
 addtask checkuri
 do_checkuri[nostamp] = "1"
 python do_checkuri() {

Comments

Richard Purdie April 11, 2012, 12:03 p.m.
On Wed, 2012-04-11 at 16:49 +0500, Noor, Ahsan wrote:
> From: Noor Ahsan <noor_ahsan@mentor.com>
> 
> * Bring distclean task from openembedded classic.
> 
> Signed-off-by: Noor Ahsan <noor_ahsan@mentor.com>
> ---
>  meta/classes/utility-tasks.bbclass |   30 ++++++++++++++++++++++++++++++
>  1 files changed, 30 insertions(+), 0 deletions(-)

No thanks, I don't see the need for this. Please use the "cleanall" task
instead which correctly calls into the fetchers and removes the right
pieces rather than the random files distclean used to remove.

Cheers,

Richard