summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-20 15:44:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-07-24 11:52:27 +0100
commit1d8924f1727d3d3c954d4c9002fe8827552bf5bf (patch)
tree39e4a1b7dd62da802911fa2766a09993df8339ff /meta
parent9928614e9437a49cbff4a36baa1e1cca3becb754 (diff)
downloadpoky-1d8924f1727d3d3c954d4c9002fe8827552bf5bf.tar.gz
package: Clean up getstatusoutput usage
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls. The call is just a wraper to the subprocess call of the same name and requires the caller to handle exceptions themselves. We usually do this badly, failing to show the output or the command or the return code. Its much safer to rely on a call like subprocess.check_output() instead. This also makes it easier to spot and remove cases where shell=True isn't needed in a later cleanup. (From OE-Core rev: 9f058857fb692f1251deb43bcaa7ed0120140093) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/package.bbclass24
1 files changed, 11 insertions, 13 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 81cb0c049c..2fab39005c 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -430,6 +430,7 @@ def copydebugsources(debugsrcdir, d):
430 # and copied to the destination here. 430 # and copied to the destination here.
431 431
432 import stat 432 import stat
433 import subprocess
433 434
434 sourcefile = d.expand("${WORKDIR}/debugsources.list") 435 sourcefile = d.expand("${WORKDIR}/debugsources.list")
435 if debugsrcdir and os.path.isfile(sourcefile): 436 if debugsrcdir and os.path.isfile(sourcefile):
@@ -466,23 +467,20 @@ def copydebugsources(debugsrcdir, d):
466 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)" 467 processdebugsrc += "(cd '%s' ; cpio -pd0mlL --no-preserve-owner '%s%s' 2>/dev/null)"
467 468
468 cmd = processdebugsrc % (sourcefile, workbasedir, localsrc_prefix, workparentdir, dvar, debugsrcdir) 469 cmd = processdebugsrc % (sourcefile, workbasedir, localsrc_prefix, workparentdir, dvar, debugsrcdir)
469 (retval, output) = oe.utils.getstatusoutput(cmd) 470 try:
470 # Can "fail" if internal headers/transient sources are attempted 471 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
471 #if retval: 472 except subprocess.CalledProcessError:
472 # bb.fatal("debug source copy failed with exit code %s (cmd was %s)" % (retval, cmd)) 473 # Can "fail" if internal headers/transient sources are attempted
474 pass
473 475
474 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced. 476 # cpio seems to have a bug with -lL together and symbolic links are just copied, not dereferenced.
475 # Work around this by manually finding and copying any symbolic links that made it through. 477 # Work around this by manually finding and copying any symbolic links that made it through.
476 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s' 2>/dev/null)" % (dvar, debugsrcdir, dvar, debugsrcdir, workparentdir, dvar, debugsrcdir) 478 cmd = "find %s%s -type l -print0 -delete | sed s#%s%s/##g | (cd '%s' ; cpio -pd0mL --no-preserve-owner '%s%s' 2>/dev/null)" % (dvar, debugsrcdir, dvar, debugsrcdir, workparentdir, dvar, debugsrcdir)
477 (retval, output) = oe.utils.getstatusoutput(cmd) 479 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
478 if retval:
479 bb.fatal("debugsrc symlink fixup failed with exit code %s (cmd was %s)" % (retval, cmd))
480 480
481 # The copy by cpio may have resulted in some empty directories! Remove these 481 # The copy by cpio may have resulted in some empty directories! Remove these
482 cmd = "find %s%s -empty -type d -delete" % (dvar, debugsrcdir) 482 cmd = "find %s%s -empty -type d -delete" % (dvar, debugsrcdir)
483 (retval, output) = oe.utils.getstatusoutput(cmd) 483 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
484 if retval:
485 bb.fatal("empty directory removal failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
486 484
487 # Also remove debugsrcdir if its empty 485 # Also remove debugsrcdir if its empty
488 for p in nosuchdir[::-1]: 486 for p in nosuchdir[::-1]:
@@ -643,6 +641,8 @@ python package_do_split_locales() {
643} 641}
644 642
645python perform_packagecopy () { 643python perform_packagecopy () {
644 import subprocess
645
646 dest = d.getVar('D') 646 dest = d.getVar('D')
647 dvar = d.getVar('PKGD') 647 dvar = d.getVar('PKGD')
648 648
@@ -650,9 +650,7 @@ python perform_packagecopy () {
650 # files to operate on 650 # files to operate on
651 # Preserve sparse files and hard links 651 # Preserve sparse files and hard links
652 cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (dest, dvar) 652 cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (dest, dvar)
653 (retval, output) = oe.utils.getstatusoutput(cmd) 653 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
654 if retval:
655 bb.fatal("file copy failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else ""))
656 654
657 # replace RPATHs for the nativesdk binaries, to make them relocatable 655 # replace RPATHs for the nativesdk binaries, to make them relocatable
658 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d): 656 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d):