1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Merge pull request #11 from yalh76/fix_ynh_install_php

Define phpversion for composer
This commit is contained in:
yalh76 2019-04-23 15:35:27 +02:00 committed by GitHub
commit 9f73a5996c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View file

@ -21,13 +21,14 @@ extra_pkg_dependencies="php7.2-bcmath php7.2-cli php7.2-curl php7.2-exif php7.2-
# Execute a command with Composer
#
# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands"
# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands"
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute.
ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=wc
declare -Ar args_array=( [w]=workdir= [c]=commands= )
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
@ -35,18 +36,19 @@ ynh_composer_exec () {
workdir="${workdir:-$final_path}"
COMPOSER_HOME="$workdir/.composer" \
php "$workdir/composer.phar" $commands \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer [--workdir=$final_path]
# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path]
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=w
declare -Ar args_array=( [w]=workdir= )
local legacy_args=vw
declare -Ar args_array=( [v]=phpversion= [w]=workdir= )
local phpversion
local workdir
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
@ -54,14 +56,15 @@ ynh_install_composer () {
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php -- --quiet --install-dir="$workdir" \
php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \
|| ynh_die "Unable to update core dependencies with Composer."
}
# Install another version of php.
#
# usage: ynh_install_php --phpversion=phpversion [--package=packages]

View file

@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
read -p "key"
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -120,7 +124,7 @@ ynh_add_fpm_config --phpversion="7.2"
chown -R "$app": "$final_path"
ynh_install_composer --workdir="$final_path"
ynh_install_composer --phpversion="7.2" --workdir="$final_path"
#=================================================
# SPECIFIC SETUP

View file

@ -141,7 +141,7 @@ ynh_add_fpm_config --phpversion="7.2"
chown -R "$app": "$final_path"
ynh_install_composer --workdir="$final_path"
ynh_install_composer --phpversion="7.2" --workdir="$final_path"
#=================================================
# MODIFY A CONFIG FILE