Fix distro detection for SUSE Linux Enterprise
On SUSE Linux Enterprise distributions, lsb_release -i typically returns "SUSE" not "SUSE LINUX" as the vendor string. To avoid duplication of the same regular expressions in multiple places, add is_opensuse() and is_sle() helper functions, and modify is_suse to invoke those. This may also be helpful in the future for distinguishing some corner cases where things are handled differently between openSUSE and SLE. Change-Id: I43bf163bc963758ddbb6289928837f5f6512f265
This commit is contained in:
parent
7a52311d80
commit
b6f04ca5c9
@ -379,14 +379,14 @@ function GetDistro {
|
||||
elif [[ "$os_VENDOR" =~ (Fedora) ]]; then
|
||||
# For Fedora, just use 'f' and the release
|
||||
DISTRO="f$os_RELEASE"
|
||||
elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then
|
||||
elif is_opensuse; then
|
||||
DISTRO="opensuse-$os_RELEASE"
|
||||
# Tumbleweed uses "n/a" as a codename, and the release is a datestring
|
||||
# like 20180218, so not very useful. Leap however uses a release
|
||||
# with a "dot", so for example 15.0
|
||||
[ "$os_CODENAME" = "n/a" -a "$os_RELEASE" = "${os_RELEASE/\./}" ] && \
|
||||
DISTRO="opensuse-tumbleweed"
|
||||
elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then
|
||||
elif is_suse_linux_enterprise; then
|
||||
# just use major release
|
||||
DISTRO="sle${os_RELEASE%.*}"
|
||||
elif [[ "$os_VENDOR" =~ (Red.*Hat) || \
|
||||
@ -460,11 +460,30 @@ function is_fedora {
|
||||
# (openSUSE, SLE).
|
||||
# is_suse
|
||||
function is_suse {
|
||||
is_opensuse || is_suse_linux_enterprise
|
||||
}
|
||||
|
||||
|
||||
# Determine if current distribution is an openSUSE distribution
|
||||
# is_opensuse
|
||||
function is_opensuse {
|
||||
if [[ -z "$os_VENDOR" ]]; then
|
||||
GetOSVersion
|
||||
fi
|
||||
|
||||
[[ "$os_VENDOR" =~ (openSUSE) || "$os_VENDOR" == "SUSE LINUX" ]]
|
||||
[[ "$os_VENDOR" =~ (openSUSE) ]]
|
||||
}
|
||||
|
||||
|
||||
# Determine if current distribution is a SUSE Linux Enterprise (SLE)
|
||||
# distribution
|
||||
# is_suse_linux_enterprise
|
||||
function is_suse_linux_enterprise {
|
||||
if [[ -z "$os_VENDOR" ]]; then
|
||||
GetOSVersion
|
||||
fi
|
||||
|
||||
[[ "$os_VENDOR" =~ (^SUSE) ]]
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user