[oe-commits] Chris Larson : packaged-staging: use oe_run rather than os.system

git version control git at git.openembedded.org
Thu Sep 9 19:33:34 UTC 2010


Module: openembedded.git
Branch: org.openembedded.dev
Commit: c11ebb74995012f3370a780123483d9c9a973719
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=c11ebb74995012f3370a780123483d9c9a973719

Author: Chris Larson <chris_larson at mentor.com>
Date:   Thu Sep  9 12:32:44 2010 -0700

packaged-staging: use oe_run rather than os.system

This ensures that the output of the stage manager is swallowed, rather than
shown unnecessarily to the user.

Signed-off-by: Chris Larson <chris_larson at mentor.com>

---

 classes/packaged-staging.bbclass |   73 ++++++++++++++++++++------------------
 1 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass
index 85f08ee..d251102 100644
--- a/classes/packaged-staging.bbclass
+++ b/classes/packaged-staging.bbclass
@@ -112,25 +112,26 @@ def pstage_set_pkgmanager(d):
 
 
 def pstage_cleanpackage(pkgname, d):
-	path = bb.data.getVar("PATH", d, 1)
-	pstage_set_pkgmanager(d)
-	list_cmd = bb.data.getVar("PSTAGE_LIST_CMD", d, True)
-
-	bb.debug(2, "Checking if staging package installed")
-	lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d))
-	ret = os.system("PATH=\"%s\" %s | grep %s" % (path, list_cmd, pkgname))
-	if ret == 0:
-		bb.debug(1, "Uninstalling package from staging...")
-		removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1)
-		ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, pkgname))
-		if ret != 0:
-			bb.note("Failure removing staging package")
-	else:
-		bb.debug(1, "Manually removing any installed files from staging...")
-		pstage_manualclean("sysroots", "STAGING_DIR", d)
-		pstage_manualclean("deploy", "DEPLOY_DIR", d)
-
-	bb.utils.unlockfile(lf)
+    pstage_set_pkgmanager(d)
+    list_cmd = bb.data.getVar("PSTAGE_LIST_CMD", d, True)
+
+    bb.debug(2, "Checking if staging package installed")
+    lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d))
+    try:
+        oe_run(d, "%s | grep %s" % (list_cmd, pkgname))
+    except RuntimeError:
+        bb.debug(1, "Manually removing any installed files from staging...")
+        pstage_manualclean("sysroots", "STAGING_DIR", d)
+        pstage_manualclean("deploy", "DEPLOY_DIR", d)
+    else:
+        bb.debug(1, "Uninstalling package from staging...")
+        removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1)
+        try:
+            oe_run(d, "%s %s" % (removecmd, pkgname))
+        except RuntimeError:
+            bb.note("Failure removing staging package")
+
+    bb.utils.unlockfile(lf)
 
 do_clean_prepend() {
 	"""
@@ -208,7 +209,6 @@ python packagestage_scenefunc () {
         staging_fetch(stagepkg, d)
 
     if os.path.exists(stagepkg):
-        path = bb.data.getVar("PATH", d, 1)
         pstage_set_pkgmanager(d)
         file = bb.data.getVar("FILE", d, True)
         bb.debug(2, "Packaged staging active for %s\n" % file)
@@ -218,8 +218,9 @@ python packagestage_scenefunc () {
         #
         bb.mkdirhier(bb.data.expand("${WORKDIR}/tstage/${libdir_native}/opkg/info/ ", d))
         cmd = bb.data.expand("${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${WORKDIR}/tstage install", d)
-        ret = os.system("PATH=\"%s\" %s %s" % (path, cmd, stagepkg))
-        if ret != 0:
+        try:
+            oe_run(d, "%s %s" % (cmd, stagepkg))
+        except RuntimeError:
             bb.fatal("Couldn't install the staging package to a temp directory")
 
         #
@@ -234,14 +235,15 @@ python packagestage_scenefunc () {
         # Copy the stamp files into the main stamps directoy
         #
         cmd = bb.data.expand("cp -dpR ${WORKDIR}/tstage/stamps/* ${TMPDIR}/stamps/", d)
-        ret = os.system(cmd)
-        if ret != 0:
+        try:
+            ret = oe_run(d, cmd)
+        except RuntimeError:
             bb.utils.unlockfile(lf)
             bb.fatal("Couldn't copy the staging package stamp files")
 
         #
         # Iterate over the stamps seeing if they're valid. If we find any that
-        # are invalid or the task wasn't in the taskgraph, assume caution and 
+        # are invalid or the task wasn't in the taskgraph, assume caution and
         # do a rebuild.
         #
         # FIXME - some tasks are safe to ignore in the task graph. e.g. package_write_*
@@ -268,10 +270,12 @@ python packagestage_scenefunc () {
         if stageok:
             bb.note("Staging package found, using it for %s." % file)
             installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1)
-            ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg))
-            bb.utils.unlockfile(lf)
-            if ret != 0:
+            try:
+                ret = oe_run(d, "%s %s" % (installcmd, stagepkg))
+            except RuntimeError:
                 bb.note("Failure installing prestage package")
+            finally:
+                bb.utils.unlockfile(lf)
 
             bb.build.exec_func("staging_package_libtoolhack", d)
 
@@ -350,7 +354,7 @@ staging_packager () {
 	echo "Priority: Optional"               >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
 	echo "Maintainer: ${MAINTAINER}"        >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
 	echo "Architecture: ${PSTAGE_PKGARCH}"  >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control
-	
+
 	# Protect against empty SRC_URI
 	srcuri="${SRC_URI}"
 	if [ "$srcuri" == "" ]; then
@@ -366,7 +370,7 @@ staging_packager () {
                 sed -i -e s:${STAGING_DIR}:FIXMESTAGINGDIR:g $i
                 echo $i | sed -e 's:${PSTAGE_TMPDIR_STAGE}/::' >> ${PSTAGE_TMPDIR_STAGE}/sysroots/fixmepath
         done
-        
+
 	${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${PSTAGE_DIR}/${PSTAGE_PKGPATH}
 }
 
@@ -401,7 +405,7 @@ python staging_package_libtoolhack () {
             fixmefd.close()
             oe.path.remove(fixmefn)
             for file in fixmefiles:
-                os.system("sed -i -e s:FIXMESTAGINGDIR:%s:g %s" % (staging, tmpdir + '/' + file))
+                oe_run(d, "sed -i -e s:FIXMESTAGINGDIR:%s:g %s" % (staging, tmpdir + '/' + file))
         except IOError:
             pass
 }
@@ -443,7 +447,6 @@ python do_package_stage () {
                 if os.path.exists(srcfile):
                     destpath = ipkpath + "/" + arch + "/"
                     bb.mkdirhier(destpath)
-		    print destpath
                     bb.copyfile(srcfile, destpath + srcname)
 
             if bb.data.inherits_class('package_deb', d):
@@ -453,7 +456,7 @@ python do_package_stage () {
                     srcname = bb.data.expand(pkgname + "_${PV}-" + pr + "${DISTRO_PR}" + "_${DPKG_ARCH}.deb", d)
                 srcfile = bb.data.expand("${DEPLOY_DIR_DEB}/" + arch + "/" + srcname, d)
                 if os.path.exists(srcfile):
-                    destpath = debpath + "/" + arch + "/" 
+                    destpath = debpath + "/" + arch + "/"
                     bb.mkdirhier(destpath)
                     bb.copyfile(srcfile, destpath + srcname)
 
@@ -464,7 +467,7 @@ python do_package_stage () {
                 srcname = bb.data.expand(pkgname + "-${RPMPV}-" + pr + "${DISTRO_PR}" + ".${TARGET_ARCH}.rpm", d)
                 srcfile = bb.data.expand("${DEPLOY_DIR_RPM}/" + arch + "/" + srcname, d)
                 if os.path.exists(srcfile):
-                    destpath = rpmpath + "/" + arch + "/" 
+                    destpath = rpmpath + "/" + arch + "/"
                     bb.mkdirhier(destpath)
                     bb.copyfile(srcfile, destpath + srcname)
 
@@ -477,7 +480,7 @@ python do_package_stage () {
     bb.mkdirhier(destdir)
     # We need to include the package_stage stamp in the staging package so create one
     bb.build.make_stamp("do_package_stage", d)
-    os.system("cp -dpR %s.do_* %s/" % (stampfn, destdir))
+    oe_run(d, "cp -dpR %s.do_* %s/" % (stampfn, destdir))
 
     pstage_set_pkgmanager(d)
     bb.build.exec_func("staging_helper", d)





More information about the Openembedded-commits mailing list