diff --git a/mod_php_install.sh b/mod_php_install.sh index b8fbd16..15f2147 100755 --- a/mod_php_install.sh +++ b/mod_php_install.sh @@ -114,33 +114,53 @@ is_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1); } -detect_os_1 () { - - if $(which lsb_release > /dev/null 2>&1) ; then - - os_dist="$(lsb_release -i | awk '{print tolower($3)}')" - os_version="$(lsb_release -r | awk '{print tolower($2)}')" - os_codename="$(lsb_release -c | awk '{print tolower($2)}')" - - if [[ "$os_dist" = "debian" ]]; then - if $(echo "$os_version" | grep -q '\.') ; then - os_version=$(echo "$os_version" | cut --delimiter='.' -f1) - fi - fi - - elif [[ -e "/etc/os-release" ]]; then +detect_os_1() { + if [[ -r /etc/os-release ]]; then . /etc/os-release - os_dist=$ID - os_version=${os_version_ID} + os_dist="$ID" + os_version="$VERSION_ID" + # Familie bestimmen + if [[ "$ID" == "debian" ]] || [[ "$ID_LIKE" == *"debian"* ]]; then + os_family="debian" + elif [[ "$ID" == "rhel" ]] || [[ "$ID_LIKE" == *"rhel"* ]]; then + os_family="rhel" + elif [[ "$ID" == "arch" ]] || [[ "$ID_LIKE" == *"arch"* ]]; then + os_family="arch" + else + os_family="$ID" + fi + + elif which lsb_release > /dev/null 2>&1 ; then + + local dist version + + dist=$(lsb_release -is 2>/dev/null | tr '[:upper:]' '[:lower:]') + version=$(lsb_release -rs 2>/dev/null | cut -d. -f1) # Major Version + + os_dist="$dist" + os_version="$version" + + case "$dist" in + debian|ubuntu|linuxmint) + os_family="debian" + ;; + rhel|centos|rocky|fedora) + os_family="rhel" + ;; + arch) + os_family="arch" + ;; + *) + os_family="$dist" + ;; + esac fi - # remove whitespace from os_dist and os_version - os_dist="${os_dist// /}" - os_version="${os_version// /}" - + # Nur Major-Version extrahieren (z.B. 12 aus 12.5) + os_version=${os_version%%.*} } ## --- ## --- END: functions @@ -258,7 +278,7 @@ fi # - Set variable # - os_dist # - os_version -# - os_codename +# - os_family # - detect_os_1 @@ -367,20 +387,15 @@ _required_base_packages="$_required_base_packages vpx-tools" - # libcroco3-dev - # libc-client-dev is no longer available on debian 13 # -if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 13 ]] ; then - _required_base_packages="$_required_base_packages - libc-client-dev" -fi - +# # Package libpcre3-dev is not availabl at debian 13, but libpcre2-dev is # available there. # -if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 13 ]] ; then +if [[ "$os_dist" == "debian" ]] && (( os_version < 13 )); then _required_base_packages="$_required_base_packages + libc-client-dev libpcre3-dev" else _required_base_packages="$_required_base_packages @@ -395,7 +410,7 @@ if [[ "$os_dist" != "ubuntu" ]] ; then libgraphicsmagick++3" fi -if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 9 ]] ; then +if [[ "$os_dist" == "debian" ]] && (( os_version < 9 )); then _required_base_packages="$_required_base_packages libjasper-dev libpng12-dev" @@ -410,7 +425,8 @@ else fi fi -if [[ "$os_dist" = "debian" ]] && [[ $os_version -eq 7 ]] ; then +if [[ "$os_dist" == "debian" ]] && (( os_version == 7 )); then + _required_base_packages="$_required_base_packages libgd2-xpm-dev libdb5.1 libdb5.1++ libdb5.1++-dev libdb5.1-dev" @@ -509,18 +525,146 @@ PHP_MAIN_VERSION=`echo $VERSION | cut -d '.' -f1,2` declare -i PHP_MAJOR_VERSION=`echo $VERSION | cut -d '.' -f1` declare -i PHP_MINOR_VERSION=`echo $VERSION | cut -d '.' -f2` declare -i PHP_PATCH_LEVEL=`echo $VERSION | cut -d '.' -f3` -declare -i PHP_MAIN_VERSION_NUM=$((PHP_MAJOR_VERSION * 100 + PHP_MINOR_VERSION * 10)) -declare -i PHP_VERSION_NUM=$((PHP_MAJOR_VERSION * 100 + PHP_MINOR_VERSION * 10 + PHP_PATCH_LEVEL)) -#echo "" -#echo "PHP_MAIN_VERSION_NUM: $PHP_MAIN_VERSION_NUM" -#echo "PHP_VERSION_NUM: $PHP_VERSION_NUM" -#echo "" + +# besser so: +# +# declare -i PHP_VERSION_NUM=$((10#$major * 10000 + 10#$minor * 100 + 10#$patch)) +# +# '10#' verhindert Probleme mit führenden Nullen +# +# Bemerkung: +# +# um 2-stellige minor versionen korrekt zu behandeln, nehmen wir die major version * 10000 +# +# versionen: +# 8.10.1 +# 8.9.15 +# +# mit 1000 ergibt sich +# 8.10.1 -> 8*1000 + 10*10 + 1 = 8101 +# 8.9.15 -> 8*1000 + 9*10 + 15 = 8105 +# +# 8101 < 8105 aber tatsächlich ist 8.10.1 > 8.9.15 +# +# mit 10000 ergibt sich: +# 8.10.1 -> 8*10000 + 10*10 + 1 = 81001 +# 8.9.15 -> 8*10000 + 9*10 + 15 = 80915 +# +# 8101 < 8105 aber tatsächlich ist 8.10.1 > 8.9.15 +# und damit (richtigerweise): 81001 > 80915 +# +IFS='.' read -r major minor patch <<< "$VERSION" +declare -i PHP_VERSION_NUM=$((10#$major * 10000 + 10#$minor * 100 + 10#$patch)) +declare -i PHP_MAIN_VERSION_NUM=$((10#$major * 10000 + 10#$minor * 100)) + +# version helper scripts +# +version_to_number() { + local a b c + IFS='.' read -r a b c <<< "$1" + echo $((10#$a * 10000 + 10#$b * 100 + 10#${c:-0})) +} + +version_eq() { + local v1=$(version_to_number "$1") + local v2=$(version_to_number "$2") + (( v1 == v2 )) +} + +version_lt() { + local v1=$(version_to_number "$1") + local v2=$(version_to_number "$2") + (( v1 < v2 )) +} + +version_le() { + local v1=$(version_to_number "$1") + local v2=$(version_to_number "$2") + (( v1 <= v2 )) +} + +version_gt() { + local v1=$(version_to_number "$1") + local v2=$(version_to_number "$2") + (( v1 > v2 )) +} + +version_ge() { + local v1=$(version_to_number "$1") + local v2=$(version_to_number "$2") + (( v1 >= v2 )) +} + +main_version_eq() { + local a b x y + IFS='.' read -r a b _ <<< "$1" + IFS='.' read -r x y _ <<< "$2" + + local v1=$((10#$a * 100 + 10#$b)) + local v2=$((10#$x * 100 + 10#$y)) + + (( v1 == v2 )) +} + +main_version_lt() { + local a b x y + IFS='.' read -r a b _ <<< "$1" + IFS='.' read -r x y _ <<< "$2" + + local v1=$((10#$a * 100 + 10#$b)) + local v2=$((10#$x * 100 + 10#$y)) + (( v1 < v2 )) +} + +main_version_le() { + local a b x y + IFS='.' read -r a b _ <<< "$1" + IFS='.' read -r x y _ <<< "$2" + + local v1=$((10#$a * 100 + 10#$b)) + local v2=$((10#$x * 100 + 10#$y)) + + (( v1 <= v2 )) +} + +main_version_gt() { + local a b x y + IFS='.' read -r a b _ <<< "$1" + IFS='.' read -r x y _ <<< "$2" + + local v1=$((10#$a * 100 + 10#$b)) + local v2=$((10#$x * 100 + 10#$y)) + (( v1 > v2 )) +} + +main_version_ge() { + local a b x y + IFS='.' read -r a b _ <<< "$1" + IFS='.' read -r x y _ <<< "$2" + + local v1=$((10#$a * 100 + 10#$b)) + local v2=$((10#$x * 100 + 10#$y)) + + (( v1 <= v2 )) +} + +# --- Hauptversion in numerischer Form (Major*100 + Minor) +main_version_num() { + local a b + IFS='.' read -r a b _ <<< "$1" + echo $((10#$a * 100 + 10#$b)) +} + +# --- Vollständige Version in numerischer Form (Major*10000 + Minor*100 + Patch) +version_num() { + version_to_number "$1" +} # Since version 7.4 package 'libsqlite3-dev' is needed # Since version 7.4 package 'libonig-dev' is needed # -if ([[ "$PHP_MAJOR_VERSION" -eq 7 ]] && [[ "$PHP_MINOR_VERSION" -gt 3 ]]) \ - || [[ "$PHP_MAJOR_VERSION" -gt 7 ]] ; then +#if (( PHP_MAIN_VERSION_NUM >= 70400 )); then +if version_ge "$VERSION" "7.4.0"; then needed_debian_packages="$needed_debian_packages libsqlite3-dev libonig-dev" @@ -528,19 +672,21 @@ fi # - A hack, because configure don't work with systemd on version 5.4.x ## - -if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then +#if (( PHP_MAIN_VERSION_NUM == 50400 )) ; then +if main_version_eq "${VERSION}" "5.4"; then SYSTEMD_EXISTS=false fi ## - Let make use multiple cores (-j) ## - -if [[ "$PHP_MAIN_VERSION" != "5.4" ]]; then +if ! main_version_eq "$VERSION" "5.4"; then export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) else unset MAKEFLAGS fi - -if [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 12 ]]; then +if main_version_eq "$VERSION" "5.6" && + (( os_version >= 13 )) && + [[ "$os_dist" == "debian" ]] ; then warn "For php version 5.6 at debian 13 and above, you need manual installation of @@ -555,16 +701,20 @@ if [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 12 ]]; then \t cyrus-sasl compiled against openssl 1.1 \t openldap compiled against cyrus-sasl" -elif [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 11 ]]; then +elif main_version_eq "$VERSION" "5.6" && + (( os_version >= 12 )) && + [[ "$os_dist" == "debian" ]] ; then warn "For php version 5.6 at debian 12 and above, you need manual installation of \t freetype (libfreetype6-dev) \t libxml2 \t icu4c (libicu) -\t openssl v 1.1.1 " +\t openssl v 1.1.1" -elif [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 9 ]]; then +elif main_version_eq "$VERSION" "5.6" && + (( os_version >= 10 )) && + [[ "$os_dist" == "debian" ]] ; then warn "For php version 5.6 at debian 10 and above, you need manual installation of @@ -5917,7 +6067,7 @@ fi _patch_file="php-5.6-zlib-1.2.11.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -5958,7 +6108,7 @@ fi _patch_file="php-5.6-libmagic.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -5999,7 +6149,7 @@ fi _patch_file="php-5.6-mbfl_encoding.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6040,7 +6190,7 @@ fi _patch_file="php-5.6-mbfl_put_invalid_char.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6081,7 +6231,7 @@ fi _patch_file="php-5.6-session.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6122,7 +6272,7 @@ fi _patch_file="php-5.6-wddx.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6163,7 +6313,7 @@ fi _patch_file="php-5.6-mkstemp.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6204,7 +6354,7 @@ fi _patch_file="php-5.6-reentrancy.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6245,7 +6395,7 @@ fi _patch_file="php-5.6-cast.patch" echononl "\tApply ${_patch_file}" -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if [[ -f "${_srcdir}/${_patch_file}" ]] ; then patch -d $_builddir -p0 < ${_srcdir}/${_patch_file} > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then @@ -6315,7 +6465,7 @@ echononl "\tGoing to configure.." ## CPP="/usr/bin/cpp-3.4" \ ## CFLAGS="$_cflags" LDFLAGS="-s" \ -#if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +#if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then # export CFLAGS="-O2 -fno-strict-aliasing -Wno-error=incompatible-pointer-types" #fi if $_install_openldap ; then @@ -6356,7 +6506,6 @@ config_params=" --with-xsl --with-mhash --enable-cgi - --with-ldap=shared --with-xmlrpc" @@ -6402,7 +6551,7 @@ else --with-curl" fi -if (( PHP_VERSION_NUM < 704 && os_version >= 13 )); then +if main_version_le "$VERSION" "7.3" && (( os_version >= 13 )); then if $_install_openldap ; then config_params="${config_params} --with-ldap"