Add getDistroVersion function

Test: bcmath
pull/70/head
Michele Locati 2019-12-20 14:15:56 +01:00
parent ece68a1e81
commit dd8abe1592
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
1 changed files with 20 additions and 11 deletions

View File

@ -26,19 +26,28 @@ getDistro () {
getDistro_os_id=''
if test -r /etc/os-release; then
getDistro_os_id="$(cat /etc/os-release | grep -E ^ID= | cut -d = -f 2)"
case "$getDistro_os_id" in
alpine|debian)
;;
*)
getDistro_os_id=''
;;
esac
fi
if test -n "$getDistro_os_id"; then
printf '%s' "$getDistro_os_id"
else
printf '%s' 'debian'
printf '%s' "$getDistro_os_id"
}
# Get the distribution name and the version
#
# Example output:
# alpine@3.10
# debian@9
getDistroVersion () {
getDistroVersion_distro="$(getDistro)"
if test -z "$getDistroVersion_distro"; then
return
fi
getDistroVersion_versionID=''
if test -r /etc/os-release; then
getDistroVersion_versionID="$(cat /etc/os-release | grep -E ^VERSION_ID= | cut -d = -f 2 | cut -d '"' -f 2 | cut -d . -f 1,2)"
fi
if test -z "$getDistroVersion_distro"; then
return
fi
printf '%s@%s' "$getDistroVersion_distro" "$getDistroVersion_versionID"
}
# Get the PHP Major-Minor version as an integer value, in format MMmm (example: 506 for PHP 5.6.15)