From 12b70e646c7fdacd7fec035eb5998e141153b3ce Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Sun, 3 Nov 2024 20:26:57 +0000 Subject: [PATCH] Fix version detection only for install mode --- script/get-generic-sys-util/customize.py | 7 ++++--- script/get-generic-sys-util/detect.sh | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/script/get-generic-sys-util/customize.py b/script/get-generic-sys-util/customize.py index 0d15e14d2c..df852f624d 100644 --- a/script/get-generic-sys-util/customize.py +++ b/script/get-generic-sys-util/customize.py @@ -11,8 +11,9 @@ def preprocess(i): automation = i['automation'] if env['CM_SYS_UTIL_NAME'] == "psmisc" and env.get('CM_HOST_OS_PACKAGE_MANAGER', '') == "brew": - env['CM_SYS_UTIL_VERSION_CMD_OVERRIDE'] = "brew info pstree > tmp-ver.out 2>&1 | grep pstree:" + env['CM_SYS_UTIL_VERSION_CMD_OVERRIDE'] = "brew info pstree > tmp-ver.out 2>&1" env['CM_SYS_UTIL_VERSION_RE'] = r"\\b(\\d+\\.\\d+(?:\\.\\d+)?)\\b" + env['CM_TMP_VERSION_DETECT_GROUP_NUMBER'] = 0 #Use VERSION_CMD and CHECK_CMD if no CHECK_CMD is set if env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' and env.get('CM_SYS_UTIL_CHECK_CMD', '') == '': @@ -132,10 +133,10 @@ def postprocess(i): version_env_key = f"CM_{env['CM_SYS_UTIL_NAME'].upper()}_VERSION" - if (env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' or env.get('CM_SYS_UTIL_VERSION_CMD_OVERRIDE', '') != '') and (env['CM_GENERIC_SYS_UTIL_RUN_MODE'] == "install" or env.get(version_env_key, '') == '') and str(env.get('CM_TMP_GENERIC_SYS_UTIL_PACKAGE_INSTALL_IGNORED', '')).lower() not in ["yes", "1", "true"] and env.get('CM_GET_GENERIC_SYS_UTIL_INSTALL_FAILED', '') != 'yes': + if (env.get('CM_SYS_UTIL_VERSION_CMD', '') != '' or env.get('CM_SYS_UTIL_VERSION_CMD_OVERRIDE', '') != '') and (env['CM_GENERIC_SYS_UTIL_RUN_MODE'] == "install" and env.get(version_env_key, '') == '') and str(env.get('CM_TMP_GENERIC_SYS_UTIL_PACKAGE_INSTALL_IGNORED', '')).lower() not in ["yes", "1", "true"] and env.get('CM_GET_GENERIC_SYS_UTIL_INSTALL_FAILED', '') != 'yes': automation = i['automation'] r = automation.run_native_script({'run_script_input':i['run_script_input'], 'env':env, 'script_name':'detect'}) - if r['return'] > 0 and str(env.get('CM_GENERIC_SYS_UTIL_IGNORE_VERSION_DETECTION_FAILURE', '')).lower() not in [ "1", "yes", "true" ] and str(env.get('CM_TMP_FAIL_SAFE', '')).lower() not in [ "1", "yes", "true" ]: + if r['return'] > 0 and str(env.get('CM_GENERIC_SYS_UTIL_IGNORE_VERSION_DETECTION_FAILURE', '')).lower() not in [ "1", "yes", "true" ]: return {'return': 1, 'error': 'Version detection failed after installation. Please check the provided version command or use env.CM_GENERIC_SYS_UTIL_IGNORE_VERSION_DETECTION_FAILURE=yes to ignore the error.'} r = detect_version(i) diff --git a/script/get-generic-sys-util/detect.sh b/script/get-generic-sys-util/detect.sh index 90ef1312ba..2c35837992 100644 --- a/script/get-generic-sys-util/detect.sh +++ b/script/get-generic-sys-util/detect.sh @@ -1,4 +1,5 @@ #!/bin/bash + if [[ -n "${CM_SYS_UTIL_VERSION_CMD_OVERRIDE}" ]]; then cmd="${CM_SYS_UTIL_VERSION_CMD_OVERRIDE}" echo $cmd