Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependencies and reinstall them when changing php version #130

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ ram.runtime = "50M"
[resources.apt]
packages = "nginx" # Kind of "dummy" value to be sure to have a non-empty dep list
packages_from_raw_bash = """
if [[ "$database" == "mysql" ]]; then
if [[ "$database" == "mysql" ]]; then
echo "mariadb-server"

if [[ "$phpversion" != none ]]; then
echo "php${phpversion}-mysql"
fi
elif [[ "$database" == "postgresql" ]]; then
echo "postgresql postgresql-contrib"

if [[ "$phpversion" != none ]]; then
echo "php${phpversion}-pgsql"
fi
Expand Down
7 changes: 5 additions & 2 deletions scripts/config
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ynh_app_config_apply() {
then
ynh_app_setting_set --app=$app --key=phpversion --value="${old[phpversion]}"
ynh_remove_fpm_config
# ^ the helper includes ynh_remove_app_dependencies
ynh_remove_app_dependencies
YNH_PHP_VERSION=$phpversion
# ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__...
ynh_app_setting_set --app=$app --key=phpversion --value="$phpversion"
Expand All @@ -127,7 +127,10 @@ ynh_app_config_apply() {
ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf"
else
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
ynh_install_app_dependencies "php${phpversion}-fpm"
database=$(ynh_app_setting_get --app=$app --key=database)
dependencies="$(ynh_read_manifest -k "resources.apt.packages")"
dependencies_from_raw_bash=$(eval "$(ynh_read_manifest -k "resources.apt.packages_from_raw_bash")" | tr "\n" " ")
ynh_install_app_dependencies "$dependencies $dependencies_from_raw_bash"
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
# ^ the helper takes care of ynh_app_setting_set the phpversion
fi
Expand Down