diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..baab404 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# ============================================================================= +# COMPOSER +# ============================================================================= + +# Execute a composer command from a given directory +# usage: composer_exec workdir COMMAND [ARG ...] +exec_composer() { + local workdir=$1 + shift 1 + + COMPOSER_HOME="${workdir}/.composer" \ + php "${workdir}/composer.phar" $@ \ + -d "${workdir}" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# usage: init_composer destdir +init_composer() { + local destdir=$1 + + # install composer + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="${destdir}/.composer" \ + php -- --quiet --install-dir="$destdir" \ + || ynh_die "Unable to install Composer" + + # install composer.json + cp "${destdir}/composer.json-dist" "${destdir}/composer.json" + + # update dependencies to create composer.lock + exec_composer "$destdir" install --no-dev \ + || ynh_die "Unable to update Roundcube core dependencies" +} diff --git a/scripts/install b/scripts/install index 8a0c07b..822a3db 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -114,6 +114,16 @@ cp ../conf/config.inc.php $final_path # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.inc.php" +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# Install composer +init_composer "$final_path" + +# Install dependencies +exec_composer update --no-dev + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5692f63..082d6d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -130,6 +130,16 @@ cp ../conf/config.inc.php $final_path # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.inc.php" +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# Install composer +init_composer "$final_path" + +# Install dependencies +exec_composer update --no-dev + #================================================= # GENERIC FINALIZATION #=================================================