From f2f8b3e31956a2c7f16e3f10cd44faf40a8f251d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 10 Jun 2024 16:30:28 +0200 Subject: [PATCH] helpers2.1: rework ynh_install_composer to wget the actual composer.phar instead of calling the unecessarily complex composer install script --- helpers/helpers.v2.1.d/php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/helpers/helpers.v2.1.d/php b/helpers/helpers.v2.1.d/php index 158302962..378ad2286 100644 --- a/helpers/helpers.v2.1.d/php +++ b/helpers/helpers.v2.1.d/php @@ -320,15 +320,21 @@ ynh_install_composer() { local workdir local install_args ynh_handle_getopts_args "$@" - # =========================================== - workdir="${workdir:-$install_dir}" install_args="${install_args:-}" + # =========================================== - curl -sS https://getcomposer.org/installer \ - | COMPOSER_HOME="$workdir/.composer" \ - php${phpversion} -- --quiet --install-dir="$workdir" --version=$YNH_COMPOSER_VERSION \ - || ynh_die --message="Unable to install Composer." + local composer_url="https://getcomposer.org/download/$YNH_COMPOSER_VERSION/composer.phar" + + [[ ! -e "$workdir/composer.phar" ]] || ynh_safe_rm $workdir/composer.phar + + # NB. we have to declare the var as local first, + # otherwise 'local foo=$(false) || echo 'pwet'" does'nt work + # because local always return 0 ... + local out + # Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget) + out=$(wget --tries 3 --no-dns-cache --timeout 900 --no-verbose --output-document=$workdir $composer_url 2>&1) \ + || ynh_die --message="$out" # install dependencies ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \