diff --git a/misc/config_tools/board_inspector/board_inspector.py b/misc/config_tools/board_inspector/board_inspector.py index 0fbc7caa0..dbfd28650 100755 --- a/misc/config_tools/board_inspector/board_inspector.py +++ b/misc/config_tools/board_inspector/board_inspector.py @@ -16,6 +16,30 @@ from cpuparser import parse_cpuid, get_online_cpu_ids script_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(script_dir)) +def check_deps(): + # Check that the required tools are installed on the system + BIN_LIST = ['cpuid', 'rdmsr', 'lspci', ' dmidecode', 'blkid', 'stty'] + cpuid_min_ver = 20170122 + for execute in BIN_LIST: + res = subprocess.Popen("which {}".format(execute), + shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, close_fds=True) + + line = res.stdout.readline().decode('ascii') + if not line: + logging.warning("'{}' cannot be found, please install it!".format(execute)) + sys.exit(1) + + if execute == 'cpuid': + res = subprocess.Popen("cpuid -v", + shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, close_fds=True) + line = res.stdout.readline().decode('ascii') + version = line.split()[2] + if int(version) < cpuid_min_ver: + logging.warning("This tool requires CPUID version >= {}".format(cpuid_min_ver)) + sys.exit(1) + def native_check(): cpu_ids = get_online_cpu_ids() cpu_id = cpu_ids.pop(0) @@ -25,6 +49,9 @@ def native_check(): "supported under KVM/QEMU. Unexpected results may occur when deviating from that combination.") def main(board_name, board_xml, args): + # Check that the dependencies are met + check_deps() + # Check if this is native os native_check() diff --git a/misc/config_tools/board_inspector/legacy/board_parser.py b/misc/config_tools/board_inspector/legacy/board_parser.py index f90e7f278..0d4762464 100755 --- a/misc/config_tools/board_inspector/legacy/board_parser.py +++ b/misc/config_tools/board_inspector/legacy/board_parser.py @@ -18,12 +18,8 @@ import parser_lib OUTPUT = "./out/" PY_CACHE = "__pycache__" -# This file store information which query from hw board -BIN_LIST = ['cpuid', 'rdmsr', 'lspci', ' dmidecode', 'blkid', 'stty'] - CPU_VENDOR = "GenuineIntel" - def check_permission(): """Check if it is root permission""" if os.getuid(): @@ -51,27 +47,6 @@ def check_env(): parser_lib.print_red("Please run this tools on {}!".format(CPU_VENDOR)) sys.exit(1) - # check if required tools are exists - for excute in BIN_LIST: - res = subprocess.Popen("which {}".format(excute), - shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, close_fds=True) - - line = res.stdout.readline().decode('ascii') - if not line: - parser_lib.print_yel("'{}' not found, please install it!".format(excute)) - sys.exit(1) - - if excute == 'cpuid': - res = subprocess.Popen("cpuid -v", - shell=True, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, close_fds=True) - line = res.stdout.readline().decode('ascii') - version = line.split()[2] - if int(version) < 20170122: - parser_lib.print_yel("Need CPUID version >= 20170122") - sys.exit(1) - if os.path.exists(OUTPUT): shutil.rmtree(OUTPUT)