Skip to content

Commit

Permalink
- changed to use env var to detect stderr, fixed some regexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oseltamivir committed Nov 1, 2024
1 parent 6723d2c commit 737024b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions automation/script/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions script/get-generic-sys-util/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down Expand Up @@ -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+)?)"
Expand Down
2 changes: 1 addition & 1 deletion script/get-generic-sys-util/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion script/get-generic-sys-util/detect.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 737024b

Please sign in to comment.