From bf7ffa001c4bae190a496b6a792ea1cb9b90580b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 18 Apr 2020 17:59:42 +0200 Subject: [PATCH] Moving to git release --- conf/app.src | 8 +++---- scripts/_common.sh | 3 ++- scripts/install | 11 ++++++++++ scripts/restore | 8 +++++++ scripts/upgrade | 11 ++++++++++ scripts/ynh_composer__2 | 48 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 scripts/ynh_composer__2 diff --git a/conf/app.src b/conf/app.src index 5d4b0d5..3e65fcd 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/kevinpapst/kimai2/releases/download/1.8/kimai-release-1.8.zip -SOURCE_SUM=c4de84b78102d30e858746f107839fe4144c80a31bbfb84e8476f95258be1c0c +SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/1.8.tar.gz +SOURCE_SUM=b5133d4dc98a360042fdbd9ac054b72ad9db3ce274ee733981375610ab7f46ef SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=false +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true SOURCE_FILENAME= diff --git a/scripts/_common.sh b/scripts/_common.sh index 2ba000d..dee186b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,8 @@ # dependencies used by the app pkg_dependencies="" -extra_pkg_dependencies="php7.3-mbstring php7.3-gd php7.3-intl php7.3-pdo php7.3-xml php7.3-zip php7.3-xsl php7.3-ldap php7.3-mysql php7.3-sqlite3 php7.3-ctype php7.3-iconv php7.3-json php7.3-cli php7.3-simplexml php7.3-tokenizer" +extra_pkg_dependencies="php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-pdo php7.3-zip php7.3-xml php7.3-xsl php7.3-ldap php7.3-mysql php7.3-sqlite3" +# php7.3-ctype php7.3-iconv php7.3-cli php7.3-simplexml php7.3-tokenizer php7.3-common php7.3-curl #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 2ee5d02..fe33533 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,7 @@ source _common.sh source ynh_add_extra_apt_repos__3 source ynh_install_php__3 +source ynh_composer__2 source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers @@ -77,6 +78,13 @@ else ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" fi +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Installing dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -144,6 +152,9 @@ fi #================================================= ynh_print_info --message="Building Kimai 2..." +ynh_install_composer --phpversion="7.3" --workdir="$final_path" +ynh_composer_exec --phpversion="7.3" --workdir="$final_path" --commands="install --no-dev --optimize-autoloader" + pushd "$final_path" php7.3 bin/console kimai:install -n popd diff --git a/scripts/restore b/scripts/restore index 46c3219..77406ab 100755 --- a/scripts/restore +++ b/scripts/restore @@ -90,6 +90,14 @@ else ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" fi +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5c4b983..a8f0ec0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,6 +9,7 @@ source _common.sh source ynh_add_extra_apt_repos__3 source ynh_install_php__3 +source ynh_composer__2 source /usr/share/yunohost/helpers #================================================= @@ -134,6 +135,13 @@ ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info --message="Upgrading dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= @@ -187,6 +195,9 @@ fi #================================================= ynh_print_info --message="Upgrading Kimai 2..." +ynh_install_composer --phpversion="7.3" --workdir="$final_path" +ynh_composer_exec --phpversion="7.3" --workdir="$final_path" --commands="install --no-dev --optimize-autoloader" + pushd "$final_path" php7.3 bin/console kimai:update popd diff --git a/scripts/ynh_composer__2 b/scripts/ynh_composer__2 new file mode 100644 index 0000000..1b6aa80 --- /dev/null +++ b/scripts/ynh_composer__2 @@ -0,0 +1,48 @@ +#!/bin/bash + +# Execute a command with Composer +# +# 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=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion + local workdir + local commands + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} "$workdir/composer.phar" $commands \ + -d "$workdir" --quiet --no-interaction +} + +# Install and initialize Composer in the given directory +# +# 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=vw + declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local phpversion + local workdir + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + workdir="${workdir:-$final_path}" + phpversion="${phpversion:-7.0}" + + curl -sS https://getcomposer.org/installer \ + | COMPOSER_HOME="$workdir/.composer" \ + php${phpversion} -- --quiet --install-dir="$workdir" \ + || ynh_die "Unable to install Composer." + + # update dependencies to create composer.lock + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + || ynh_die "Unable to update core dependencies with Composer." +}