From 329583671602648623663655d073805e91882985 Mon Sep 17 00:00:00 2001 From: Phuc Vinh Date: Mon, 6 Nov 2023 17:11:24 -0800 Subject: [PATCH] To properly handle amazon 2023. --- build/os_version | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/build/os_version b/build/os_version index 07a072b..cdca39c 100755 --- a/build/os_version +++ b/build/os_version @@ -57,7 +57,7 @@ main() { *'centos'* ) distro_id='centos' ;; - *'redhat'* | *'rhel'* ) + *'redhat'* | *'rhel'* | *'red hat'* ) distro_id='rhel' ;; *'debian'* ) @@ -78,7 +78,7 @@ main() { release=$(cat /etc/redhat-release | tr '[:upper:]' '[:lower:]') fi release_version=${release##*release} - distro_version=${release_version%.*} + distro_version=${release_version%%.*} ;; 'debian' ) debian_version=$(cat /etc/debian_version | tr '[:upper:]' '[:lower:]') @@ -94,6 +94,25 @@ main() { distro_id=${distro_id//[[:space:]]/} distro_version=${distro_version//[[:space:]]/} + # Second chance for pre-release versions. + if [ -z "$distro_version" ] + then + case "$distro_id" in + 'debian' ) + debian_version=$(cat /etc/debian_version | tr '[:upper:]' '[:lower:]') + if [[ "$debian_version" = "buster"* ]] + then + debian_version=10 + fi + if [[ "$debian_version" = "bullseye"* ]] + then + debian_version=11 + fi + distro_version=${debian_version%%.*} + ;; + esac + fi + case "$distro_id" in 'centos' ) distro_long="${distro_id}${distro_version%%.*}" @@ -117,10 +136,6 @@ main() { distro_long="centos${distro_version}" distro_short="el${distro_version}" ;; - 'amzn' ) - distro_long="ami" - distro_short="ami" - ;; * ) distro_long="${distro_id}${distro_version}" distro_short="${distro_id}${distro_version}"