1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/roundcube_ynh.git synced 2024-09-03 20:16:28 +02:00
roundcube_ynh/scripts/_common.sh

81 lines
3.2 KiB
Bash
Raw Normal View History

2019-03-03 18:12:41 +01:00
#!/bin/bash
2019-05-18 18:42:54 +02:00
#=================================================
2017-08-26 03:24:41 +02:00
# COMMON VARIABLES
2019-05-18 18:42:54 +02:00
#=================================================
2017-06-18 17:09:53 +02:00
2020-09-27 22:39:12 +02:00
YNH_PHP_VERSION="7.3"
2017-08-26 03:24:41 +02:00
# Package dependencies
2020-11-02 22:52:46 +01:00
extra_php_dependencies="php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-pear php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-curl"
2017-08-26 03:24:41 +02:00
# Plugins version
contextmenu_version=2.3
automatic_addressbook_version=v0.4.3
2019-01-28 04:17:58 +01:00
carddav_version=3.0.3
2019-03-03 18:12:41 +01:00
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
2020-11-02 17:47:49 +01:00
readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17
# Declare the actual composer version to use.
# A packager willing to use another version of composer can override the variable into its _common.sh.
YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
2019-03-03 18:12:41 +01:00
# Execute a command with Composer
#
2020-11-02 17:47:49 +01:00
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -v, --phpversion - PHP version to use with composer
2019-03-03 18:12:41 +01:00
# | 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.
2019-05-18 18:42:54 +02:00
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
2019-03-03 18:12:41 +01:00
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
2020-11-02 17:47:49 +01:00
phpversion="${phpversion:-$YNH_PHP_VERSION}"
2019-03-03 18:12:41 +01:00
COMPOSER_HOME="$workdir/.composer" \
2019-05-18 18:42:54 +02:00
php${phpversion} "$workdir/composer.phar" $commands \
2019-03-03 18:12:41 +01:00
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
2019-03-03 18:12:41 +01:00
#
2020-11-02 17:47:49 +01:00
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
# | arg: -v, --phpversion - PHP version to use with composer
2019-03-03 18:12:41 +01:00
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
2020-11-02 17:47:49 +01:00
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
# | arg: -c, --composerversion - Composer version to install
2019-03-03 18:12:41 +01:00
ynh_install_composer () {
# Declare an array to define the options of this helper.
2020-11-02 17:47:49 +01:00
local legacy_args=vwa
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
2019-05-18 18:42:54 +02:00
local phpversion
2019-03-03 18:12:41 +01:00
local workdir
2020-11-02 17:47:49 +01:00
local install_args
local composerversion
2019-03-03 18:12:41 +01:00
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
2020-11-02 17:47:49 +01:00
phpversion="${phpversion:-$YNH_PHP_VERSION}"
install_args="${install_args:-}"
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
2019-03-03 18:12:41 +01:00
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
2020-11-02 17:47:49 +01:00
php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \
2019-03-03 18:12:41 +01:00
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
2020-11-02 17:47:49 +01:00
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
2019-03-03 18:12:41 +01:00
|| ynh_die "Unable to update core dependencies with Composer."
}
2020-11-02 17:47:49 +01:00