summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-25 16:52:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-25 17:42:58 +0000
commit7a8f3f7a012fd323df8d812d969d4190d956a82e (patch)
tree635eb88e6c6dc62f5e66fec38aab605890171782
parentd12980ff1d47df0b6b8c10c595779af16cb76ffa (diff)
downloadpoky-7a8f3f7a012fd323df8d812d969d4190d956a82e.tar.gz
package.bbclass: Handle subprocess errors correctly
If an error occurs in subprocess.call() we currently don't catch it. In particular we have issues where debugedit is segfaulting unnoticed. This fixes up various code paths to catch the errors. [YOCTO #4089] (From OE-Core rev: 262a69ffd33e9d001a7a15fc73671a015e3b5dd1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/package.bbclass32
1 files changed, 26 insertions, 6 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index b6f87674a0..5dca1043d7 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -254,14 +254,23 @@ def splitdebuginfo(file, debugfile, debugsrcdir, d):
254 254
255 # We need to extract the debug src information here... 255 # We need to extract the debug src information here...
256 if debugsrcdir: 256 if debugsrcdir:
257 subprocess.call("'%s' -b '%s' -d '%s' -i -l '%s' '%s'" % (debugedit, workparentdir, debugsrcdir, sourcefile, file), shell=True) 257 cmd = "'%s' -b '%s' -d '%s' -i -l '%s' '%s'" % (debugedit, workparentdir, debugsrcdir, sourcefile, file)
258 retval = subprocess.call(cmd, shell=True)
259 if retval:
260 bb.fatal("debugedit failed with exit code %s (cmd was %s)" % (retval, cmd))
258 261
259 bb.utils.mkdirhier(os.path.dirname(debugfile)) 262 bb.utils.mkdirhier(os.path.dirname(debugfile))
260 263
261 subprocess.call("'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile), shell=True) 264 cmd = "'%s' --only-keep-debug '%s' '%s'" % (objcopy, file, debugfile)
265 retval = subprocess.call(cmd, shell=True)
266 if retval:
267 bb.fatal("objcopy failed with exit code %s (cmd was %s)" % (retval, cmd))
262 268
263 # Set the debuglink to have the view of the file path on the target 269 # Set the debuglink to have the view of the file path on the target
264 subprocess.call("'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file), shell=True) 270 cmd = "'%s' --add-gnu-debuglink='%s' '%s'" % (objcopy, debugfile, file)
271 retval = subprocess.call(cmd, shell=True)
272 if retval:
273 bb.fatal("objcopy failed with exit code %s (cmd was %s)" % (retval, cmd))
265 274
266 if newmode: 275 if newmode:
267 os.chmod(file, origmode) 276 os.chmod(file, origmode)
@@ -298,10 +307,18 @@ def copydebugsources(debugsrcdir, d):
298 processdebugsrc += "fgrep -z '%s' | " 307 processdebugsrc += "fgrep -z '%s' | "
299 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" 308 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)"
300 309
301 subprocess.call(processdebugsrc % (sourcefile, workbasedir, workparentdir, dvar, debugsrcdir), shell=True) 310 cmd = processdebugsrc % (sourcefile, workbasedir, workparentdir, dvar, debugsrcdir)
311 retval = subprocess.call(cmd, shell=True)
312 # Can "fail" if internal headers/transient sources are attempted
313 #if retval:
314 # bb.fatal("debug source copy failed with exit code %s (cmd was %s)" % (retval, cmd))
315
302 316
303 # The copy by cpio may have resulted in some empty directories! Remove these 317 # The copy by cpio may have resulted in some empty directories! Remove these
304 subprocess.call("find %s%s -empty -type d -delete" % (dvar, debugsrcdir), shell=True) 318 cmd = "find %s%s -empty -type d -delete" % (dvar, debugsrcdir)
319 retval = subprocess.call(cmd, shell=True)
320 if retval:
321 bb.fatal("empty directory removal failed with exit code %s (cmd was %s)" % (retval, cmd))
305 322
306 # Also remove debugsrcdir if its empty 323 # Also remove debugsrcdir if its empty
307 for p in nosuchdir[::-1]: 324 for p in nosuchdir[::-1]:
@@ -431,7 +448,10 @@ python perform_packagecopy () {
431 # Start by package population by taking a copy of the installed 448 # Start by package population by taking a copy of the installed
432 # files to operate on 449 # files to operate on
433 # Preserve sparse files and hard links 450 # Preserve sparse files and hard links
434 subprocess.call('tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar), shell=True) 451 cmd = 'tar -cf - -C %s -ps . | tar -xf - -C %s' % (dest, dvar)
452 retval = subprocess.call(cmd, shell=True)
453 if retval:
454 bb.fatal("file copy failed with exit code %s (cmd was %s)" % (retval, cmd))
435 455
436 # replace RPATHs for the nativesdk binaries, to make them relocatable 456 # replace RPATHs for the nativesdk binaries, to make them relocatable
437 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d): 457 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d):