From dd8abe1592eb826215fb1bb9fc54615165825900 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Fri, 20 Dec 2019 14:15:56 +0100 Subject: [PATCH] Add getDistroVersion function Test: bcmath --- install-php-extensions | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/install-php-extensions b/install-php-extensions index 82b393d..6edbdb9 100755 --- a/install-php-extensions +++ b/install-php-extensions @@ -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)