Skip to content

Commit

Permalink
♻️ REFACTOR: #202
Browse files Browse the repository at this point in the history
  • Loading branch information
apolopena committed Mar 1, 2022
1 parent 70e6bd5 commit 7d0dc56
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions .gp/bash/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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." &&
Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 7d0dc56

Please sign in to comment.