]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/oeqa: Replace subprocess.check_call() with check_output()
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 23 Jan 2017 17:43:40 +0000 (17:43 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 23 Jan 2017 23:30:44 +0000 (23:30 +0000)
If you use subprocess.check_output() the traceback will contain the output
when the command fails which is very useful for debugging. There is no
good reason not to use this everywhere.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/sstate.bbclass
meta/classes/staging.bbclass
meta/classes/uninative.bbclass
meta/lib/oe/rootfs.py
meta/lib/oeqa/sdk/utils/sdkbuildproject.py
meta/lib/oeqa/utils/buildproject.py
meta/lib/oeqa/utils/targetbuild.py

index a767a0203b99c01297e3119d8ef046424e8390ca..0fdeb9dfe8defeb7d15a33826c2a931346135666 100644 (file)
@@ -573,14 +573,14 @@ python sstate_hardcode_path () {
     sstate_hardcode_cmd = "%s | xargs %s | %s | xargs %s %s" % (sstate_scan_cmd, sstate_grep_cmd, sstate_filelist_cmd, xargs_no_empty_run_cmd, sstate_sed_cmd)
 
     bb.note("Removing hardcoded paths from sstate package: '%s'" % (sstate_hardcode_cmd))
-    subprocess.check_call(sstate_hardcode_cmd, shell=True, cwd=sstate_builddir)
+    subprocess.check_output(sstate_hardcode_cmd, shell=True, cwd=sstate_builddir)
 
         # If the fixmefn is empty, remove it..
     if os.stat(fixmefn).st_size == 0:
         os.remove(fixmefn)
     else:
         bb.note("Replacing absolute paths in fixmepath file: '%s'" % (sstate_filelist_relative_cmd))
-        subprocess.check_call(sstate_filelist_relative_cmd, shell=True)
+        subprocess.check_output(sstate_filelist_relative_cmd, shell=True)
 }
 
 def sstate_package(ss, d):
index 1a4668e5d3eb9145ac16dc18a2e9b6a17a11973a..fc387eaf4bb52971e111ae7deac7d7d6fc389337 100644 (file)
@@ -290,7 +290,7 @@ def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d):
         fixme_path = d.getVar(fixmevar)
         cmd += " -e 's:FIXME_%s:%s:g'" % (fixmevar, fixme_path)
     bb.note(cmd)
-    subprocess.check_call(cmd, shell=True)
+    subprocess.check_output(cmd, shell=True)
 
 
 def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
@@ -333,7 +333,7 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d):
 
     staging_processfixme(fixme, targetdir, targetsysroot, nativesysroot, d)
     for p in postinsts:
-        subprocess.check_call(p, shell=True)
+        subprocess.check_output(p, shell=True)
 
 #
 # Manifests here are complicated. The main sysroot area has the unpacked sstate
@@ -561,7 +561,7 @@ python extend_recipe_sysroot() {
             staging_processfixme(fixme[f], multilibs[f].getVar("RECIPE_SYSROOT"), recipesysroot, recipesysrootnative, d)
 
     for p in postinsts:
-        subprocess.check_call(p, shell=True)
+        subprocess.check_output(p, shell=True)
 
     for dep in configuredeps:
         c = setscenedeps[dep][0]
index ba7ca63b8f8320b11d79ade8a3bd86816a2480ce..410fb72d26ea81dc869cb2833767c78537e8d6ed 100644 (file)
@@ -60,7 +60,7 @@ python uninative_event_fetchloader() {
                     os.symlink(localpath, tarballpath)
 
         cmd = d.expand("mkdir -p ${UNINATIVE_STAGING_DIR}-uninative; cd ${UNINATIVE_STAGING_DIR}-uninative; tar -xjf ${UNINATIVE_DLDIR}/%s/${UNINATIVE_TARBALL}; ${UNINATIVE_STAGING_DIR}-uninative/relocate_sdk.py ${UNINATIVE_STAGING_DIR}-uninative/${BUILD_ARCH}-linux ${UNINATIVE_LOADER} ${UNINATIVE_LOADER} ${UNINATIVE_STAGING_DIR}-uninative/${BUILD_ARCH}-linux/${bindir_native}/patchelf-uninative ${UNINATIVE_STAGING_DIR}-uninative/${BUILD_ARCH}-linux${base_libdir_native}/libc*.so" % chksum)
-        subprocess.check_call(cmd, shell=True)
+        subprocess.check_output(cmd, shell=True)
 
         with open(loaderchksum, "w") as f:
             f.write(chksum)
index 5b842ba46a7d1736db427e6890d8251a0f42ef85..9c8a0ebb7e31e5e973ff2583c1654b3e41f8e2ff 100644 (file)
@@ -303,10 +303,10 @@ class Rootfs(object, metaclass=ABCMeta):
             bb.note("> Executing %s intercept ..." % script)
 
             try:
-                subprocess.check_call(script_full)
+                subprocess.check_output(script_full)
             except subprocess.CalledProcessError as e:
-                bb.warn("The postinstall intercept hook '%s' failed (exit code: %d)! See log for details!" %
-                        (script, e.returncode))
+                bb.warn("The postinstall intercept hook '%s' failed (exit code: %d)! See log for details! (Output: %s)" %
+                        (script, e.returncode, e.output))
 
                 with open(script_full) as intercept:
                     registered_pkgs = None
index cc34e0c9f57ad204367b0c04c8500c22a456fd69..4e4e5077c086b5843c719159c0456cddfb6589c5 100644 (file)
@@ -24,7 +24,7 @@ class SDKBuildProject(BuildProject):
         self._download_archive()
 
         cmd = 'tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir)
-        subprocess.check_call(cmd, shell=True)
+        subprocess.check_output(cmd, shell=True)
 
         #Change targetdir to project folder
         self.targetdir = os.path.join(self.targetdir, self.fname)
index 386a927881820c58e2775dabab29aa7bdbed663d..b3c487b6c661e0393aea7c41536507eaeb53718d 100644 (file)
@@ -29,7 +29,7 @@ class BuildProject(metaclass=ABCMeta):
             return
 
         cmd = "wget -O %s %s" % (self.localarchive, self.uri)
-        subprocess.check_call(cmd, shell=True)
+        subprocess.check_output(cmd, shell=True)
 
     # This method should provide a way to run a command in the desired environment.
     @abstractmethod
index c001602b54d2446bb5003947c049bbd59aa723d4..6f237b56f3d835be0bf4680fa9d54c9c03c0415f 100644 (file)
@@ -45,7 +45,7 @@ class BuildProject(metaclass=ABCMeta):
                 cmd = 'export ' + var + '=\"%s\"; %s' % (val, cmd)
 
         cmd = cmd + "wget -O %s %s" % (self.localarchive, self.uri)
-        subprocess.check_call(cmd, shell=True)
+        subprocess.check_output(cmd, shell=True)
 
     # This method should provide a way to run a command in the desired environment.
     @abstractmethod
@@ -114,7 +114,7 @@ class SDKBuildProject(BuildProject):
         self._download_archive()
 
         cmd = 'tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir)
-        subprocess.check_call(cmd, shell=True)
+        subprocess.check_output(cmd, shell=True)
 
         #Change targetdir to project folder
         self.targetdir = os.path.join(self.targetdir, self.fname)