Skip to content

Commit

Permalink
To properly handle amazon 2023.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvinh-spike committed Nov 7, 2023
1 parent 30088df commit 3295836
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions build/os_version
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ main() {
*'centos'* )
distro_id='centos'
;;
*'redhat'* | *'rhel'* )
*'redhat'* | *'rhel'* | *'red hat'* )
distro_id='rhel'
;;
*'debian'* )
Expand All @@ -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:]')
Expand All @@ -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%%.*}"
Expand All @@ -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}"
Expand Down

0 comments on commit 3295836

Please sign in to comment.