diff --git a/helpers/helpers.v2.1.d/apps b/helpers/helpers.v2.1.d/apps index 474f5e45f..a3ee183a9 100644 --- a/helpers/helpers.v2.1.d/apps +++ b/helpers/helpers.v2.1.d/apps @@ -173,11 +173,11 @@ ynh_spawn_app_shell() { # Force `php` to its intended version # We use `eval`+`export` since `alias` is not propagated to subshells, even with `export` - local phpversion=$(ynh_app_setting_get --key=phpversion) + local php_version=$(ynh_app_setting_get --key=php_version) local phpflags=$(ynh_app_setting_get --key=phpflags) - if [ -n "$phpversion" ] + if [ -n "$php_version" ] then - eval "php() { php${phpversion} ${phpflags} \"\$@\"; }" + eval "php() { php${php_version} ${phpflags} \"\$@\"; }" export -f php fi diff --git a/helpers/helpers.v2.1.d/apt b/helpers/helpers.v2.1.d/apt index fcd01b5be..3b8666078 100644 --- a/helpers/helpers.v2.1.d/apt +++ b/helpers/helpers.v2.1.d/apt @@ -266,10 +266,10 @@ ynh_install_app_dependencies() { dependencies+=", php${specific_php_version}, php${specific_php_version}-fpm, php${specific_php_version}-common" - local old_phpversion=$(ynh_app_setting_get --key=phpversion) + local old_php_version=$(ynh_app_setting_get --key=php_version) # If the PHP version changed, remove the old fpm conf - if [ -n "$old_phpversion" ] && [ "$old_phpversion" != "$specific_php_version" ]; then + if [ -n "$old_php_version" ] && [ "$old_php_version" != "$specific_php_version" ]; then local old_php_fpm_config_dir=$(ynh_app_setting_get --key=fpm_config_dir) local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf" @@ -279,8 +279,8 @@ ynh_install_app_dependencies() { ynh_remove_fpm_config fi fi - # Store phpversion into the config of this app - ynh_app_setting_set --key=phpversion --value=$specific_php_version + # Store php_version into the config of this app + ynh_app_setting_set --key=php_version --value=$specific_php_version # Set the default php version back as the default version for php-cli. if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION @@ -288,7 +288,7 @@ ynh_install_app_dependencies() { update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION fi elif grep --quiet 'php' <<< "$dependencies"; then - ynh_app_setting_set --key=phpversion --value=$YNH_DEFAULT_PHP_VERSION + ynh_app_setting_set --key=php_version --value=$YNH_DEFAULT_PHP_VERSION fi local psql_installed="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)" @@ -339,7 +339,7 @@ EOF # # [packagingv1] # -# usage: ynh_add_app_dependencies --package=phpversion +# usage: ynh_add_app_dependencies --package=packagename # | arg: -p, --package= - Packages to add as dependencies for the app. # # Requires YunoHost version 3.8.1 or higher. diff --git a/helpers/helpers.v2.1.d/php b/helpers/helpers.v2.1.d/php index 65278dfa2..2c0500eb5 100644 --- a/helpers/helpers.v2.1.d/php +++ b/helpers/helpers.v2.1.d/php @@ -1,9 +1,19 @@ #!/bin/bash +# (this is used in the apt helpers, big meh ...) readonly YNH_DEFAULT_PHP_VERSION=7.4 -# Declare the actual PHP version to use. -# A packager willing to use another version of PHP can override the variable into its _common.sh. -YNH_PHP_VERSION=${YNH_PHP_VERSION:-$YNH_DEFAULT_PHP_VERSION} + +# Legacy: auto-convert phpversion to php_version (for consistency with nodejs_version, ruby_version, ...) +if [[ -n "${app:-}" ]] && [[ -n "${phpversion:-}" ]] +then + if [[ -z "${php_version:-}" ]] + then + php_version=$phpversion + ynh_app_setting_set --key=php_version --value=$php_version + fi + ynh_app_setting_delete --key=phpversion + unset phpversion +fi # Create a dedicated PHP-FPM config # @@ -14,7 +24,7 @@ YNH_PHP_VERSION=${YNH_PHP_VERSION:-$YNH_DEFAULT_PHP_VERSION} # The actual PHP configuration will be automatically generated, # and your extra_php-fpm.conf will be appended (typically contains PHP upload limits) # -# The resulting configuration will be deployed to the appropriate place, /etc/php/$phpversion/fpm/pool.d/$app.conf +# The resulting configuration will be deployed to the appropriate place, /etc/php/$php_version/fpm/pool.d/$app.conf # # Performance-related options in the PHP conf, such as : # pm.max_children, pm.start_servers, pm.min_spare_servers pm.max_spare_servers @@ -58,8 +68,8 @@ ynh_add_fpm_config() { # If the PHP version changed, remove the old fpm conf # (NB: This stuff is also handled by the apt helper, which is usually triggered before this helper) - local old_phpversion=$(ynh_app_setting_get --key=phpversion) - if [ -n "$old_phpversion" ] && [ "$old_phpversion" != "$phpversion" ]; then + local old_php_version=$(ynh_app_setting_get --key=php_version) + if [ -n "$old_php_version" ] && [ "$old_php_version" != "$php_version" ]; then local old_php_fpm_config_dir=$(ynh_app_setting_get --key=fpm_config_dir) local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf" @@ -70,15 +80,15 @@ ynh_add_fpm_config() { fi fi - local fpm_service="php${phpversion}-fpm" - local fpm_config_dir="/etc/php/$phpversion/fpm" + local fpm_service="php${php_version}-fpm" + local fpm_config_dir="/etc/php/$php_version/fpm" # Create the directory for FPM pools mkdir --parents "$fpm_config_dir/pool.d" ynh_app_setting_set --key=fpm_config_dir --value="$fpm_config_dir" ynh_app_setting_set --key=fpm_service --value="$fpm_service" - ynh_app_setting_set --key=phpversion --value=$phpversion + ynh_app_setting_set --key=php_version --value=$php_version # Define the values to use for the configuration of PHP. ynh_get_scalable_phpfpm @@ -93,7 +103,7 @@ group = __PHPFPM_GROUP__ chdir = __INSTALL_DIR__ -listen = /var/run/php/php__PHPVERSION__-fpm-__APP__.sock +listen = /var/run/php/php__PHP_VERSION__-fpm-__APP__.sock listen.owner = www-data listen.group = www-data @@ -125,8 +135,8 @@ pm.process_idle_timeout = 10s ynh_add_config --template="$phpfpm_path" --destination="$finalphpconf" # Validate that the new php conf doesn't break php-fpm entirely - if ! php-fpm${phpversion} --test 2>/dev/null; then - php-fpm${phpversion} --test || true + if ! php-fpm${php_version} --test 2>/dev/null; then + php-fpm${php_version} --test || true ynh_safe_rm "$finalphpconf" ynh_die --message="The new configuration broke php-fpm?" fi @@ -298,7 +308,7 @@ ynh_composer_exec() { # =========================================== COMPOSER_HOME="$workdir/.composer" COMPOSER_MEMORY_LIMIT=-1 \ - php${phpversion} "$workdir/composer.phar" $commands \ + php${php_version} "$workdir/composer.phar" $commands \ -d "$workdir" --no-interaction --no-ansi 2>&1 }