Skip to content

Commit f7bc67e

Browse files
authored
Merge pull request #85 from redhat-performance/84-add-support-for-sles-to-detect_os
Add SLES as a valid OS for detect_os Add code to detect when we can't find the package manager and exit properly
2 parents 5041956 + c65a32f commit f7bc67e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

configs/detect_os.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
identifier: fedora
1818
uname_pattern: \.fc[0-9]+\.
1919
uname_version_pattern: "[0-9]+"
20+
21+
- name: SLES
22+
identifier: sles

detect_os

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,13 @@ install_deps()
6060
if ! command -v wget > /dev/null 2>&1; then
6161
if command -v yum > /dev/null 2>&1; then
6262
yum install -y wget
63-
else
63+
elif command -v apt > /dev/null 2>&1; then
6464
apt install -y wget
65+
elif command -v zypper > /dev/null 2>&1; then
66+
zypper install -y wget
67+
else
68+
echo "Missing wget, and do not know what package manager is being used, exiting out"
69+
exit 1
6570
fi
6671
fi
6772

@@ -115,10 +120,15 @@ parse_uname()
115120
local identifier=`yq -r ".[$i].identifier" $config`
116121
local ver_pattern=`yq -r ".[$i].uname_version_pattern" $config`
117122

118-
if [ -z ver_pattern ]; then
123+
if [ -z "$ver_pattern" ]; then
119124
echo $identifier has no uname_version_pattern, skipping
120125
continue
121126
fi
127+
128+
if [ -z "$pattern" ]; then
129+
echo $identifier has no uname_pattern, skipping
130+
continue
131+
fi
122132

123133
local os_match=`echo $kinfo | grep -Eo $pattern`
124134

0 commit comments

Comments
 (0)