mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 00:39:46 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
4a127a70a2
commit
033fca1671
+38
-29
@@ -336,11 +336,11 @@ def check_path_length(filepath, pathname, limit):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_filesystem_id(path):
|
def get_filesystem_id(path):
|
||||||
status, result = oe.utils.getstatusoutput("stat -f -c '%s' '%s'" % ("%t", path))
|
import subprocess
|
||||||
if status == 0:
|
try:
|
||||||
return result
|
return subprocess.check_output(["stat", "-f", "-c", "%t", path]).decode('utf-8')
|
||||||
else:
|
except subprocess.CalledProcessError:
|
||||||
bb.warn("Can't get the filesystem id of: %s" % path)
|
bb.warn("Can't get filesystem id of: %s" % path)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Check that the path isn't located on nfs.
|
# Check that the path isn't located on nfs.
|
||||||
@@ -463,7 +463,7 @@ def check_patch_version(sanity_data):
|
|||||||
import re, subprocess
|
import re, subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT, universal_newlines=True)
|
result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
||||||
version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
|
version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
|
||||||
if LooseVersion(version) < LooseVersion("2.7"):
|
if LooseVersion(version) < LooseVersion("2.7"):
|
||||||
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"
|
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):
|
|||||||
# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
|
# Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
|
||||||
def check_make_version(sanity_data):
|
def check_make_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
status, result = oe.utils.getstatusoutput("make --version")
|
import subprocess
|
||||||
if status != 0:
|
|
||||||
return "Unable to execute make --version, exit code %d\n" % status
|
try:
|
||||||
|
result = subprocess.check_output(['make', '--version'], stderr=subprocess.STDOUT).decode('utf-8')
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return "Unable to execute make --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[2]
|
version = result.split()[2]
|
||||||
if LooseVersion(version) == LooseVersion("3.82"):
|
if LooseVersion(version) == LooseVersion("3.82"):
|
||||||
# Construct a test file
|
# Construct a test file
|
||||||
@@ -493,18 +496,18 @@ def check_make_version(sanity_data):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Check if make 3.82 has been patched
|
# Check if make 3.82 has been patched
|
||||||
status,result = oe.utils.getstatusoutput("make -f makefile_test")
|
try:
|
||||||
|
subprocess.check_call(['make', '-f', 'makefile_test'])
|
||||||
os.remove("makefile_test")
|
except subprocess.CalledProcessError as e:
|
||||||
if os.path.exists("makefile_test_a.c"):
|
|
||||||
os.remove("makefile_test_a.c")
|
|
||||||
if os.path.exists("makefile_test_b.c"):
|
|
||||||
os.remove("makefile_test_b.c")
|
|
||||||
if os.path.exists("makefile_test.a"):
|
|
||||||
os.remove("makefile_test.a")
|
|
||||||
|
|
||||||
if status != 0:
|
|
||||||
return "Your version of make 3.82 is broken. Please revert to 3.81 or install a patched version.\n"
|
return "Your version of make 3.82 is broken. Please revert to 3.81 or install a patched version.\n"
|
||||||
|
finally:
|
||||||
|
os.remove("makefile_test")
|
||||||
|
if os.path.exists("makefile_test_a.c"):
|
||||||
|
os.remove("makefile_test_a.c")
|
||||||
|
if os.path.exists("makefile_test_b.c"):
|
||||||
|
os.remove("makefile_test_b.c")
|
||||||
|
if os.path.exists("makefile_test.a"):
|
||||||
|
os.remove("makefile_test.a")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -512,9 +515,11 @@ def check_make_version(sanity_data):
|
|||||||
# but earlier versions do not; this needs to work properly for sstate
|
# but earlier versions do not; this needs to work properly for sstate
|
||||||
def check_tar_version(sanity_data):
|
def check_tar_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
status, result = oe.utils.getstatusoutput("tar --version")
|
import subprocess
|
||||||
if status != 0:
|
try:
|
||||||
return "Unable to execute tar --version, exit code %d\n" % status
|
result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return "Unable to execute tar --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[3]
|
version = result.split()[3]
|
||||||
if LooseVersion(version) < LooseVersion("1.24"):
|
if LooseVersion(version) < LooseVersion("1.24"):
|
||||||
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"
|
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):
|
|||||||
# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
|
# The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
|
||||||
def check_git_version(sanity_data):
|
def check_git_version(sanity_data):
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
status, result = oe.utils.getstatusoutput("git --version 2> /dev/null")
|
import subprocess
|
||||||
if status != 0:
|
try:
|
||||||
return "Unable to execute git --version, exit code %d\n" % status
|
result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return "Unable to execute git --version, exit code %d\n%s\n" % (e.returncode, e.output)
|
||||||
version = result.split()[2]
|
version = result.split()[2]
|
||||||
if LooseVersion(version) < LooseVersion("1.8.3.1"):
|
if LooseVersion(version) < LooseVersion("1.8.3.1"):
|
||||||
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"
|
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):
|
|||||||
|
|
||||||
# Check the required perl modules which may not be installed by default
|
# Check the required perl modules which may not be installed by default
|
||||||
def check_perl_modules(sanity_data):
|
def check_perl_modules(sanity_data):
|
||||||
|
import subprocess
|
||||||
ret = ""
|
ret = ""
|
||||||
modules = ( "Text::ParseWords", "Thread::Queue", "Data::Dumper" )
|
modules = ( "Text::ParseWords", "Thread::Queue", "Data::Dumper" )
|
||||||
errresult = ''
|
errresult = ''
|
||||||
for m in modules:
|
for m in modules:
|
||||||
status, result = oe.utils.getstatusoutput("perl -e 'use %s'" % m)
|
try:
|
||||||
if status != 0:
|
subprocess.check_output(["perl", "-e", "use %s" % m])
|
||||||
errresult += result
|
except subprocess.CalledProcessError as e:
|
||||||
|
errresult += e.output
|
||||||
ret += "%s " % m
|
ret += "%s " % m
|
||||||
if ret:
|
if ret:
|
||||||
return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult)
|
return "Required perl module(s) not found: %s\n\n%s\n" % (ret, errresult)
|
||||||
|
|||||||
Reference in New Issue
Block a user