From 7d0dc5622a9cf53a588257a4f7eb452744b5fe55 Mon Sep 17 00:00:00 2001 From: apolopena <3060702+apolopena@users.noreply.github.com> Date: Tue, 1 Mar 2022 10:28:40 -0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20REFACTOR:=20https://github?= =?UTF-8?q?.com/apolopena/gitpod-laravel-starter/issues/202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gp/bash/php.sh | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/.gp/bash/php.sh b/.gp/bash/php.sh index f5c118b6..246cd7fa 100644 --- a/.gp/bash/php.sh +++ b/.gp/bash/php.sh @@ -23,7 +23,7 @@ php7_4='php7.4 php7.4-fpm php7.4-dev libapache2-mod-php7.4 php7.4-bcmath php7.4- php8_0='php8.0 php8.0fpm php8.0-dev php8.0-bcmath php8.0-ctype php8.0-curl php8.0-gd php8.0-intl php8.0-mbstring php8.0-mysql php8.0-pgsql php8.0-sqlite3 php8.0-tokenizer php8.0-xml php8.0-zip' latest_php="$(. /tmp/utils.sh php_version)" php_version= -gp_php_url='https://github.com/gitpod-io/workspace-images/blob/master/full/Dockerfile' +gp_php_url='https://github.com/gitpod-io/workspace-images/blob/master/chunks/tool-nginx/Dockerfile' purge_gp_php() { local msg="Purging existing PHP $latest_php installation" @@ -118,7 +118,7 @@ configure_apache() { } keep_existing_php() { - local msg1 msg2= + local msg1 msg2 msg3 msg4 msg5 msg6= [[ $1 == 'fallback' ]] && msg1=" WARNING: unsupported PHP version $php_version found in starter.ini." && @@ -127,11 +127,26 @@ keep_existing_php() { echo "END: php.sh" | tee -a $log && return 0 + # Handle potential Gitpod regressions such as https://github.com/gitpod-io/workspace-images/issues/714 + if [[ $(. /tmp/utils.sh comp_ver_lt "$latest_php" 8.0) == 1 ]]; then + msg1=" WARNING: The PHP version in the Gitpod Image and the target PHP version are the same" + msg2=" This can occur when Gitpod bumps down its version of PHP in workspace-mysql" + msg3=" The existing version of PHP $latest_php will be left as-is" + msg4=" The ppa value in starter.ini will be ignored" + msg5=" NOTE: If you want to use a higher version of PHP than $latest_php, set it in starter.ini" + msg6=" Supported PHP version values for starter.ini are: 7.4 and 8.0" + 2>&1 echo -e "$msg1\n$msg2\n$msg3\n$msg4\n$msg5\n$msg6" | tee -a $log + return 0 + fi + + # Otherwise its business as usual msg1=" Using the existing 'gitpodlatest' version of PHP ($latest_php) as specified in $gp_php_url" && echo "$msg1" | tee -a $log && echo "END: php.sh" | tee -a $log } + + # BEGIN: MAIN echo "BEGIN: php.sh" | tee -a $log php_version=$(. /tmp/utils.sh parse_ini_value /tmp/starter.ini PHP version) @@ -141,26 +156,15 @@ if [[ $ec -ne 0 ]]; then php_version='gitpodlatest' fi -if [[ $php_version != "$latest_php" ]]; then - if [[ $php_version == '7.4' ]]; then - IFS=" " read -r -a all_packages <<< "$php7_4" - elif [[ $php_version == '8.0' ]]; then - IFS=" " read -r -a all_packages <<< "$php8_0" - elif [[ $php_version == 'gitpodlatest' ]]; then - keep_existing_php - exit 0 - else - keep_existing_php 'fallback' - exit 0 - fi +if [[ $php_version == '7.4' ]]; then + IFS=" " read -r -a all_packages <<< "$php7_4" +elif [[ $php_version == '8.0' ]]; then + IFS=" " read -r -a all_packages <<< "$php8_0" +elif [[ $php_version == 'gitpodlatest' ]]; then + keep_existing_php + exit 0 else - msg1=" WARNING: The PHP version in the Gitpod Image and the target PHP version are the same" - msg2=" This can occur when Gitpod bumps down its version of PHP in workspace-mysql" - msg3=" The existing version of PHP $latest_php will be left as-is" - msg4=" The ppa value in starter.ini will be ignored" - msg5=" NOTE: If you want to use a higher version of PHP than $latest_php, set it in starter.ini" - msg6=" Supported PHP version values are: 7.4 and 8.0" - 2>&1 echo -e "$msg1\n$msg2\n$msg3\n$msg4\n$msg5\n$msg6" | tee -a $log + keep_existing_php 'fallback' exit 0 fi