From f888df6083627e84e3764762aa235b367120fb56 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 7 Jun 2020 19:24:38 +0200 Subject: [PATCH] Upgrade to upstream version 5.0.2 / Use PHP 7.3 --- conf/app.src | 4 ++-- conf/nginx.conf | 2 +- conf/php-fpm.conf | 2 +- manifest.json | 4 ++-- scripts/_common.sh | 31 ++++++++++++++++++++++--------- scripts/backup | 4 ++-- scripts/install | 2 +- scripts/restore | 13 +++++++++---- scripts/upgrade | 34 +++++++++++++++++----------------- 9 files changed, 57 insertions(+), 39 deletions(-) diff --git a/conf/app.src b/conf/app.src index f46f64f..d7cd70d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/4.9.5/phpMyAdmin-4.9.5-all-languages.tar.gz -SOURCE_SUM=d1ab98cde370c39dafdaa13ce02fa35cecaaa6d33553fde092604b99660e8835 +SOURCE_URL=https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.tar.gz +SOURCE_SUM=8d5cb67de154262b6e51e6ac6967d0931d28ef39cdc7fbec44011d374eb432ae SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 4796506..303eb96 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 88b5479..e871971 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/manifest.json b/manifest.json index 2c9feac..d835e35 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Manage MySQL databases over the web", "fr": "Application web de gestion des bases de données MySQL" }, - "version": "4.9.5~ynh1", + "version": "5.0.2~ynh1", "url": "http://www.phpmyadmin.net", "license": "GPL-2.0-only", "maintainer": { @@ -14,7 +14,7 @@ "email": "julien.malik@paraiso.me" }, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.8.1" }, "multi_instance": false, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 0f122b9..46ce7fb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,12 +1,20 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +YNH_PHP_VERSION="7.3" +extra_php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-mbstring" + + #================================================= # EXPERIMENTAL HELPERS #================================================= # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] -exec_as() { +ynh_exec_as() { local USER=$1 shift 1 @@ -19,7 +27,8 @@ exec_as() { # Execute a command with Composer # -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -32,7 +41,7 @@ ynh_composer_exec () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" COMPOSER_HOME="$workdir/.composer" \ php${phpversion} "$workdir/composer.phar" $commands \ @@ -41,18 +50,22 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vw - declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local legacy_args=vwa + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) local phpversion local workdir + local install_args # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + install_args="${install_args:-}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ @@ -60,6 +73,6 @@ ynh_install_composer () { || ynh_die "Unable to install Composer." # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ || ynh_die "Unable to update core dependencies with Composer." -} +} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index fa7b254..5a32a67 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source ../settings/scripts/_common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -48,7 +48,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index 5ea0771..5e88457 100644 --- a/scripts/install +++ b/scripts/install @@ -101,7 +101,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" #================================================= # SPECIFIC SETUP diff --git a/scripts/restore b/scripts/restore index 3e2fccb..e9e5d20 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source ../settings/scripts/_common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -95,16 +95,21 @@ chown $app: $final_path/tmp # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_script_progression --message="Reconfiguring php-fpm..." --weight=6 + +# Restore the file first, so it can have a backup if different +ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" + +# Recreate a dedicated php-fpm config +ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading nginx web server..." -ynh_systemd_action --service_name=php7.0-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 7bcb21a..7353cec 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,7 +128,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=4 # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies" #================================================= # SPECIFIC UPGRADE @@ -176,22 +176,6 @@ cp ../conf/config.inc.php $final_path # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/config.inc.php" -#================================================= -# INSTALL DEPENDENCIES -#================================================= - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - - ynh_script_progression --message="Upgrading dependencies with Composer..." --weight=19 - - # Install composer - ynh_install_composer - - # Install dependencies - ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev\" -fi - #================================================= # GENERIC FINALIZATION #================================================= @@ -207,6 +191,22 @@ chmod 640 $final_path/config.inc.php mkdir -p $final_path/tmp chown -R $app: $final_path/tmp + +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + + ynh_script_progression --message="Upgrading dependencies with Composer..." --weight=19 + + # Force dependency to the used PHP version + ynh_exec_warn_less ynh_composer_exec --commands=\"config -g platform.php $YNH_PHP_VERSION\" + # Install dependencies + ynh_exec_warn_less ynh_composer_exec --commands=\"update --no-dev\" +fi + #================================================= # SETUP SSOWAT #=================================================