Skip to content

Commit f9f1114

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix distro detection for SUSE Linux Enterprise"
2 parents 5378755 + b6f04ca commit f9f1114

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

functions-common

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,14 @@ function GetDistro {
379379
elif [[ "$os_VENDOR" =~ (Fedora) ]]; then
380380
# For Fedora, just use 'f' and the release
381381
DISTRO="f$os_RELEASE"
382-
elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then
382+
elif is_opensuse; then
383383
DISTRO="opensuse-$os_RELEASE"
384384
# Tumbleweed uses "n/a" as a codename, and the release is a datestring
385385
# like 20180218, so not very useful. Leap however uses a release
386386
# with a "dot", so for example 15.0
387387
[ "$os_CODENAME" = "n/a" -a "$os_RELEASE" = "${os_RELEASE/\./}" ] && \
388388
DISTRO="opensuse-tumbleweed"
389-
elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then
389+
elif is_suse_linux_enterprise; then
390390
# just use major release
391391
DISTRO="sle${os_RELEASE%.*}"
392392
elif [[ "$os_VENDOR" =~ (Red.*Hat) || \
@@ -460,11 +460,30 @@ function is_fedora {
460460
# (openSUSE, SLE).
461461
# is_suse
462462
function is_suse {
463+
is_opensuse || is_suse_linux_enterprise
464+
}
465+
466+
467+
# Determine if current distribution is an openSUSE distribution
468+
# is_opensuse
469+
function is_opensuse {
470+
if [[ -z "$os_VENDOR" ]]; then
471+
GetOSVersion
472+
fi
473+
474+
[[ "$os_VENDOR" =~ (openSUSE) ]]
475+
}
476+
477+
478+
# Determine if current distribution is a SUSE Linux Enterprise (SLE)
479+
# distribution
480+
# is_suse_linux_enterprise
481+
function is_suse_linux_enterprise {
463482
if [[ -z "$os_VENDOR" ]]; then
464483
GetOSVersion
465484
fi
466485

467-
[[ "$os_VENDOR" =~ (openSUSE) || "$os_VENDOR" == "SUSE LINUX" ]]
486+
[[ "$os_VENDOR" =~ (^SUSE) ]]
468487
}
469488

470489

0 commit comments

Comments
 (0)