aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-06-08 16:14:37 -0700
committerChris Larson <chris_larson@mentor.com>2010-06-10 11:35:00 -0700
commit2959eb8c60df3b7ea1833238f9eac05cdafe1c06 (patch)
tree094419d7ff16216256b043c52b7413394cc96acd
parent50d20ac55d111d2c0d25c3dba76a02b8d936a9c9 (diff)
downloadopenembedded-2959eb8c60df3b7ea1833238f9eac05cdafe1c06.tar.gz
Add a rm -rf utility function and use it in packaged-staging.bbclass
Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r--classes/packaged-staging.bbclass33
-rw-r--r--lib/oe/path.py11
2 files changed, 22 insertions, 22 deletions
diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass
index ac5cec23b1..8a98940c09 100644
--- a/classes/packaged-staging.bbclass
+++ b/classes/packaged-staging.bbclass
@@ -28,16 +28,6 @@ PSTAGE_NATIVEDEPENDS = "\
BB_STAMP_WHITELIST = "${PSTAGE_NATIVEDEPENDS}"
-def _package_unlink (f):
- import os, errno
- try:
- os.unlink(f)
- return True
- except OSError, e:
- if e.errno == errno.ENOENT:
- return False
- raise
-
python () {
pstage_allowed = True
@@ -106,7 +96,7 @@ def pstage_manualclean(srcname, destvarname, d):
if (file == "staging.lock"):
continue
filepath = os.path.join(walkroot, file).replace(src, dest)
- _package_unlink(filepath)
+ oe.path.remove(filepath)
def pstage_set_pkgmanager(d):
path = bb.data.getVar("PATH", d, 1)
@@ -148,10 +138,10 @@ do_clean_prepend() {
pstage_cleanpackage(removepkg, d)
stagepkg = bb.data.expand("${PSTAGE_PKG}", d)
- bb.note("Removing staging package %s" % base_path_out(stagepkg, d))
- # Add a wildcard to the end of stagepkg to also get its md5
- # if it's a fetched package
- os.system('rm -rf ' + stagepkg + '*')
+ if os.path.exists(stagepkg):
+ bb.note("Removing staging package %s" % base_path_out(stagepkg, d))
+ oe.path.remove(stagepkg)
+ oe.path.remove(stagepkg + ".md5")
}
staging_helper () {
@@ -270,10 +260,9 @@ python packagestage_scenefunc () {
# Remove the stamps and files we added above
# FIXME - we should really only remove the stamps we added
for fname in glob.glob(stamp + '.*'):
- _package_unlink(fname)
-
- os.system(bb.data.expand("rm -rf ${WORKDIR}/tstage", d))
+ oe.path.remove(fname)
+ oe.path.remove(bb.data.expand("${WORKDIR}/tstage", d))
if stageok:
bb.note("Staging package found, using it for %s." % file)
installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1)
@@ -305,9 +294,9 @@ python packagedstage_stampfixing_eventhandler() {
# We're targetting a task which was skipped with packaged staging
# so we need to remove the autogenerated stamps.
for task in taskscovered:
- dir = "%s.do_%s" % (e.stampPrefix[fn], task)
- _package_unlink(dir)
- _package_unlink(stamp)
+ covered = "%s.do_%s" % (e.stampPrefix[fn], task)
+ oe.path.remove(covered)
+ oe.path.remove(stamp)
}
populate_sysroot_preamble () {
@@ -417,7 +406,7 @@ python staging_package_libtoolhack () {
fixmefd = open(fixmefn,"r")
fixmefiles = fixmefd.readlines()
fixmefd.close()
- os.system('rm -f ' + fixmefn)
+ oe.path.remove(fixmefn)
for file in fixmefiles:
os.system("sed -i -e s:FIXMESTAGINGDIR:%s:g %s" % (staging, tmpdir + '/' + file))
except IOError:
diff --git a/lib/oe/path.py b/lib/oe/path.py
index 8902951581..a145456659 100644
--- a/lib/oe/path.py
+++ b/lib/oe/path.py
@@ -42,3 +42,14 @@ def format_display(path, metadata):
return path
else:
return rel
+
+def remove(path):
+ """Equivalent to rm -f or rm -rf"""
+ import os, errno, shutil
+ try:
+ os.unlink(path)
+ except OSError, exc:
+ if exc.errno == errno.EISDIR:
+ shutil.rmtree(path)
+ elif exc.errno != errno.ENOENT:
+ raise