summaryrefslogtreecommitdiffstats
path: root/meta/classes/sanity.bbclass
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-08-05 14:43:10 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-08 10:52:00 +0100
commit033fca16716de32cf7c6d7d1bbfc674c6392df0b (patch)
tree587506a3f7aaf01fdfcf89355a78a1cb6afd37df /meta/classes/sanity.bbclass
parent4a127a70a2b3fe6cb862fbb7508c48909e9588ac (diff)
downloadpoky-033fca16716de32cf7c6d7d1bbfc674c6392df0b.tar.gz
classes/sanity: Clean up getstatusoutput usage
Replace usage of oe.utils.getstatusoutput() with direct subprocess calls. (From OE-Core rev: 2f44b9b5babf8c95340b141917c1142081f1e594) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sanity.bbclass')
-rw-r--r--meta/classes/sanity.bbclass67
1 files changed, 38 insertions, 29 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index e0e57ceec1..4e8eae8946 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -336,11 +336,11 @@ def check_path_length(filepath, pathname, limit):
336 return "" 336 return ""
337 337
338def get_filesystem_id(path): 338def get_filesystem_id(path):
339 status, result = oe.utils.getstatusoutput("stat -f -c '%s' '%s'" % ("%t", path)) 339 import subprocess
340 if status == 0: 340 try:
341 return result 341 return subprocess.check_output(["stat", "-f", "-c", "%t", path]).decode('utf-8')
342 else: 342 except subprocess.CalledProcessError:
343 bb.warn("Can't get the filesystem id of: %s" % path) 343 bb.warn("Can't get filesystem id of: %s" % path)
344 return None 344 return None
345 345
346# Check that the path isn't located on nfs. 346# Check that the path isn't located on nfs.
@@ -463,7 +463,7 @@ def check_patch_version(sanity_data):
463 import re, subprocess 463 import re, subprocess
464 464
465 try: 465 try:
466 result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT, universal_newlines=True) 466 result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
467 version = re.search(r"[0-9.]+", result.splitlines()[0]).group() 467 version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
468 if LooseVersion(version) < LooseVersion("2.7"): 468 if LooseVersion(version) < LooseVersion("2.7"):
469 return "Your version of patch is older than 2.7 and has bugs which will break builds. Please install a newer version of patch.\n" 469 return "Your version of patch is older than 2.7 and has bugs which will break builds. Please install a newer version of patch.\n"
@@ -476,9 +476,12 @@ def check_patch_version(sanity_data):
476# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate. 476# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
477def check_make_version(sanity_data): 477def check_make_version(sanity_data):
478 from distutils.version import LooseVersion 478 from distutils.version import LooseVersion
479 status, result = oe.utils.getstatusoutput("make --version") 479 import subprocess
480 if status != 0: 480
481 return "Unable to execute make --version, exit code %d\n" % status 481 try:
482 result = subprocess.check_output(['make', '--version'], stderr=subprocess.STDOUT).decode('utf-8')
483 except subprocess.CalledProcessError as e:
484 return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output)
482 version = result.split()[2] 485 version = result.split()[2]
483 if LooseVersion(version) == LooseVersion("3.82"): 486 if LooseVersion(version) == LooseVersion("3.82"):
484 # Construct a test file 487 # Construct a test file
@@ -493,18 +496,18 @@ def check_make_version(sanity_data):
493 f.close() 496 f.close()
494 497
495 # Check if make 3.82 has been patched 498 # Check if make 3.82 has been patched
496 status,result = oe.utils.getstatusoutput("make -f makefile_test") 499 try:
497 500 subprocess.check_call(['make', '-f', 'makefile_test'])
498 os.remove("makefile_test") 501 except subprocess.CalledProcessError as e:
499 if os.path.exists("makefile_test_a.c"):
500 os.remove("makefile_test_a.c")
501 if os.path.exists("makefile_test_b.c"):
502 os.remove("makefile_test_b.c")
503 if os.path.exists("makefile_test.a"):
504 os.remove("makefile_test.a")
505
506 if status != 0:
507 return "Your version of make 3.82 is broken. Please revert to 3.81 or install a patched version.\n" 502 return "Your version of make 3.82 is broken. Please revert to 3.81 or install a patched version.\n"
503 finally:
504 os.remove("makefile_test")
505 if os.path.exists("makefile_test_a.c"):
506 os.remove("makefile_test_a.c")
507 if os.path.exists("makefile_test_b.c"):
508 os.remove("makefile_test_b.c")
509 if os.path.exists("makefile_test.a"):
510 os.remove("makefile_test.a")
508 return None 511 return None
509 512
510 513
@@ -512,9 +515,11 @@ def check_make_version(sanity_data):
512# but earlier versions do not; this needs to work properly for sstate 515# but earlier versions do not; this needs to work properly for sstate
513def check_tar_version(sanity_data): 516def check_tar_version(sanity_data):
514 from distutils.version import LooseVersion 517 from distutils.version import LooseVersion
515 status, result = oe.utils.getstatusoutput("tar --version") 518 import subprocess
516 if status != 0: 519 try:
517 return "Unable to execute tar --version, exit code %d\n" % status 520 result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
521 except subprocess.CalledProcessError as e:
522 return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output)
518 version = result.split()[3] 523 version = result.split()[3]
519 if LooseVersion(version) < LooseVersion("1.24"): 524 if LooseVersion(version) < LooseVersion("1.24"):
520 return "Your version of tar is older than 1.24 and has bugs which will break builds. Please install a newer version of tar.\n" 525 return "Your version of tar is older than 1.24 and has bugs which will break builds. Please install a newer version of tar.\n"
@@ -525,9 +530,11 @@ def check_tar_version(sanity_data):
525# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped 530# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
526def check_git_version(sanity_data): 531def check_git_version(sanity_data):
527 from distutils.version import LooseVersion 532 from distutils.version import LooseVersion
528 status, result = oe.utils.getstatusoutput("git --version 2> /dev/null") 533 import subprocess
529 if status != 0: 534 try:
530 return "Unable to execute git --version, exit code %d\n" % status 535 result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
536 except subprocess.CalledProcessError as e:
537 return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output)
531 version = result.split()[2] 538 version = result.split()[2]
532 if LooseVersion(version) < LooseVersion("1.8.3.1"): 539 if LooseVersion(version) < LooseVersion("1.8.3.1"):
533 return "Your version of git is older than 1.8.3.1 and has bugs which will break builds. Please install a newer version of git.\n" 540 return "Your version of git is older than 1.8.3.1 and has bugs which will break builds. Please install a newer version of git.\n"
@@ -535,13 +542,15 @@ def check_git_version(sanity_data):
535 542
536# Check the required perl modules which may not be installed by default 543# Check the required perl modules which may not be installed by default
537def check_perl_modules(sanity_data): 544def check_perl_modules(sanity_data):
545 import subprocess
538 ret = "" 546 ret = ""
539 modules = ( "Text::ParseWords", "Thread::Queue", "Data::Dumper" ) 547 modules = ( "Text::ParseWords", "Thread::Queue", "Data::Dumper" )
540 errresult = '' 548 errresult = ''
541 for m in modules: 549 for m in modules:
542 status, result = oe.utils.getstatusoutput("perl -e 'use %s'" % m) 550 try:
543 if status != 0: 551 subprocess.check_output(["perl", "-e", "use %s" % m])
544 errresult += result 552 except subprocess.CalledProcessError as e:
553 errresult += e.output
545 ret += "%s " % m 554 ret += "%s " % m
546 if ret: 555 if ret:
547 return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult) 556 return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult)