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
... | ... |
@@ -379,14 +379,14 @@ function GetDistro { |
379 | 379 |
elif [[ "$os_VENDOR" =~ (Fedora) ]]; then |
380 | 380 |
# For Fedora, just use 'f' and the release |
381 | 381 |
DISTRO="f$os_RELEASE" |
382 |
- elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then |
|
382 |
+ elif is_opensuse; then |
|
383 | 383 |
DISTRO="opensuse-$os_RELEASE" |
384 | 384 |
# Tumbleweed uses "n/a" as a codename, and the release is a datestring |
385 | 385 |
# like 20180218, so not very useful. Leap however uses a release |
386 | 386 |
# with a "dot", so for example 15.0 |
387 | 387 |
[ "$os_CODENAME" = "n/a" -a "$os_RELEASE" = "${os_RELEASE/\./}" ] && \ |
388 | 388 |
DISTRO="opensuse-tumbleweed" |
389 |
- elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then |
|
389 |
+ elif is_suse_linux_enterprise; then |
|
390 | 390 |
# just use major release |
391 | 391 |
DISTRO="sle${os_RELEASE%.*}" |
392 | 392 |
elif [[ "$os_VENDOR" =~ (Red.*Hat) || \ |
... | ... |
@@ -460,11 +460,30 @@ function is_fedora { |
460 | 460 |
# (openSUSE, SLE). |
461 | 461 |
# is_suse |
462 | 462 |
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 { |
|
463 | 482 |
if [[ -z "$os_VENDOR" ]]; then |
464 | 483 |
GetOSVersion |
465 | 484 |
fi |
466 | 485 |
|
467 |
- [[ "$os_VENDOR" =~ (openSUSE) || "$os_VENDOR" == "SUSE LINUX" ]] |
|
486 |
+ [[ "$os_VENDOR" =~ (^SUSE) ]] |
|
468 | 487 |
} |
469 | 488 |
|
470 | 489 |
|