All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] packaged-staging.bbclass: use 'os.unlink()' instead of spawning 'rm'
@ 2010-03-16 12:23 Enrico Scholz
  2010-03-17  2:05 ` Tom Rini
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Enrico Scholz @ 2010-03-16 12:23 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Enrico Scholz

Doing a '-c clean' operation on a staged package with very much files
(e.g. glibc) took several minutes because

* every removed file was reported
* an 'rm' instance was spawned for every file

This patch uses the native 'os.unlink()' method for removing files and
reports only the removed root directory instead of the single files.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 classes/packaged-staging.bbclass |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass
index 1ede25c..5ab9eb5 100644
--- a/classes/packaged-staging.bbclass
+++ b/classes/packaged-staging.bbclass
@@ -26,6 +26,14 @@ PSTAGE_NATIVEDEPENDS = "\
 
 BB_STAMP_WHITELIST = "${PSTAGE_NATIVEDEPENDS}"
 
+def _package_unlink (f):
+    import os
+    try:
+	os.unlink(f)
+	return True
+    except:
+	return False
+
 python () {
     pstage_allowed = True
 
@@ -87,10 +95,10 @@ def pstage_manualclean(srcname, destvarname, d):
 	dest = bb.data.getVar(destvarname, d, True)
 
 	for walkroot, dirs, files in os.walk(src):
+		bb.note("rm %s" % walkroot)
 		for file in files:
 			filepath = os.path.join(walkroot, file).replace(src, dest)
-			bb.note("rm %s" % filepath)
-			os.system("rm %s" % filepath)
+			_package_unlink(filepath)
 
 def pstage_set_pkgmanager(d):
     path = bb.data.getVar("PATH", d, 1)
@@ -162,6 +170,7 @@ PSTAGE_TASKS_COVERED = "fetch unpack munge patch configure qa_configure rig_loca
 SCENEFUNCS += "packagestage_scenefunc"
 
 python packagestage_scenefunc () {
+    import glob
     if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "0":
         return
 
@@ -217,7 +226,9 @@ python packagestage_scenefunc () {
 
         # Remove the stamps and files we added above
         # FIXME - we should really only remove the stamps we added
-        os.system('rm -f ' + stamp + '.*')
+	for fname in glob.glob(stamp + '.*'):
+	    _package_unlink(fname)
+
         os.system(bb.data.expand("rm -rf ${WORKDIR}/tstage", d))
 
         if stageok:
@@ -251,8 +262,8 @@ python packagedstage_stampfixing_eventhandler() {
                     # so we need to remove the autogenerated stamps.
                     for task in taskscovered:
                         dir = "%s.do_%s" % (e.stampPrefix[fn], task)
-                        os.system('rm -f ' + dir)
-                    os.system('rm -f ' + stamp)
+			_package_unlink(dir)
+		    _package_unlink(stamp)
 
     return NotHandled
 }
-- 
1.6.6.1




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

end of thread, other threads:[~2010-04-14 14:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16 12:23 [PATCH] packaged-staging.bbclass: use 'os.unlink()' instead of spawning 'rm' Enrico Scholz
2010-03-17  2:05 ` Tom Rini
2010-03-17 10:00   ` Enrico Scholz
2010-03-17 17:05 ` Tom Rini
2010-03-17 17:39   ` Michael 'Mickey' Lauer
2010-03-17 17:48     ` Tom Rini
2010-03-17 18:18       ` Tom Rini
2010-04-14  9:55 ` [PATCH v2] " Enrico Scholz
2010-04-14 12:48   ` Sebastian Spaeth
2010-04-14 13:21     ` Enrico Scholz
2010-04-14 14:52   ` Tom Rini

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.