From 737024bd447cfdbc7644d9057ad092138b0eef03 Mon Sep 17 00:00:00 2001 From: Oseltamvir Date: Fri, 1 Nov 2024 08:00:45 +0000 Subject: [PATCH] - changed to use env var to detect stderr, fixed some regexes --- automation/script/module.py | 8 ++++++-- script/get-generic-sys-util/_cm.json | 12 +++++++----- script/get-generic-sys-util/customize.py | 2 +- script/get-generic-sys-util/detect.sh | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/automation/script/module.py b/automation/script/module.py index 64226f5742..4a1b91f233 100644 --- a/automation/script/module.py +++ b/automation/script/module.py @@ -8,7 +8,7 @@ # TBD: when we have bandwidth and resources, we should refactor it # and make it cleaner and simpler while keeping full backwards compatibility. # - +import re import os import logging @@ -3979,7 +3979,11 @@ def parse_version(self, i): return r string = r['string'] - + match = re.search(match_text, string) + if debug: + print(f"Regex Pattern: {match_text}") + print(f"Matched String: {string}") + print(f"Match Groups: {match.groups()}") version = r['match'].group(group_number) which_env[env_key] = version diff --git a/script/get-generic-sys-util/_cm.json b/script/get-generic-sys-util/_cm.json index 51fe526c2a..345673d364 100644 --- a/script/get-generic-sys-util/_cm.json +++ b/script/get-generic-sys-util/_cm.json @@ -235,9 +235,10 @@ }, "libbz2-dev": { "env": { + "CM_SYS_UTIL_VERSION_CMD_USE_ERROR_STREAM": "yes", "CM_SYS_UTIL_NAME": "libbz2_dev", "CM_SYS_UTIL_VERSION_CMD": "bzcat --version", - "CM_SYS_UTIL_VERSION_RE": "\\b\\d+\\.\\d+(?:\\.\\d+)?\\b" + "CM_SYS_UTIL_VERSION_RE": "([\\d:]+\\.[\\d\\.-]+)" }, "state": { "libbz2_dev": { @@ -351,7 +352,7 @@ "env": { "CM_SYS_UTIL_NAME": "liblzma_dev", "CM_SYS_UTIL_VERSION_CMD": "xz --version", - "CM_SYS_UTIL_VERSION_RE": "[A-Za-z]+\\s\\d\\.\\d\\.\\d" + "CM_SYS_UTIL_VERSION_RE": "(\\d(\\.\\d)+)" }, "state": { "liblzma_dev": { @@ -475,8 +476,8 @@ "libreadline-dev": { "env": { "CM_SYS_UTIL_NAME": "libreadline_dev", - "CM_SYS_UTIL_VERSION_CMD": "readline --version", - "CM_SYS_UTIL_VERSION_RE": "readline, version ([\\d.]+)" + "CM_SYS_UTIL_VERSION_CMD": "pkg-config --modversion readline", + "CM_SYS_UTIL_VERSION_RE": "([\\d.]+)" }, "state": { "libreadline_dev": { @@ -490,7 +491,7 @@ "libsqlite3-dev": { "env": { "CM_SYS_UTIL_NAME": "libsqlite3_dev", - "CM_SYS_UTIL_VERSION_CMD": "sqlite3 --version", + "CM_SYS_UTIL_VERSION_CMD": "pkg-config --modversion sqlite3", "CM_SYS_UTIL_VERSION_RE": "([\\d.]+)" }, "state": { @@ -659,6 +660,7 @@ }, "psmisc": { "env": { + "CM_SYS_UTIL_VERSION_CMD_USE_ERROR_STREAM": "yes", "CM_SYS_UTIL_NAME": "psmisc", "CM_SYS_UTIL_VERSION_CMD": "pstree --version", "CM_SYS_UTIL_VERSION_RE": "pstree \\(PSmisc\\) (\\d+\\.\\d+(?:\\.\\d+)?)" diff --git a/script/get-generic-sys-util/customize.py b/script/get-generic-sys-util/customize.py index 5121708343..7480c77991 100644 --- a/script/get-generic-sys-util/customize.py +++ b/script/get-generic-sys-util/customize.py @@ -115,7 +115,7 @@ def detect_version(i): 'match_text': version_check_re, 'group_number': 1, 'env_key': version_env_key, - 'which_env': env, + 'which_env': env, #'debug': 1 }) if r['return'] > 0: diff --git a/script/get-generic-sys-util/detect.sh b/script/get-generic-sys-util/detect.sh index 42de864cde..dff0d91fd7 100755 --- a/script/get-generic-sys-util/detect.sh +++ b/script/get-generic-sys-util/detect.sh @@ -1,7 +1,7 @@ #!/bin/bash if [[ -n "${CM_SYS_UTIL_VERSION_CMD}" ]]; then - if [[ "${CM_SYS_UTIL_VERSION_CMD}" == *"pstree --version"* ]]; then + if [[ "${CM_SYS_UTIL_VERSION_CMD_USE_ERROR_STREAM}" == "yes" ]]; then # Redirect both stdout and stderr to tmp-ver.out ${CM_SYS_UTIL_VERSION_CMD} > tmp-ver.out 2>&1 else