helpers2.1: replace ynh_check_app_version_changed with a much simpler ynh_app_upstream_version_changed that can directly be used with 'if ynh_app_upstream_version_changed' instead of the current mess

This commit is contained in:
Alexandre Aubin 2024-06-11 19:27:33 +02:00
parent 66508d5fd6
commit 47b2a5695f

View file

@ -476,23 +476,12 @@ ynh_app_upstream_version() {
echo "${$YNH_APP_MANIFEST_VERSION/~ynh*/}" echo "${$YNH_APP_MANIFEST_VERSION/~ynh*/}"
} }
# Checks the app version to upgrade with the existing app version and returns: # Return 0 if the "upstream" part of the version changed, or 1 otherwise (ie only the ~ynh suffix changed)
# #
# usage: ynh_check_app_version_changed # usage: if ynh_app_upstream_version_changed; then ...
# | ret: `UPGRADE_APP` if the upstream version changed, `UPGRADE_PACKAGE` otherwise. ynh_app_upstream_version_changed() {
# # "UPGRADE_PACKAGE" means only the ~ynh prefix changed
# This helper should be used to avoid an upgrade of an app, or the upstream part [[ "$YNH_APP_UPGRADE_TYPE" == "UPGRADE_PACKAGE" ]] && return 1 || return 0
# of it, when it's not needed
#
# Requires YunoHost version 3.5.0 or higher.
ynh_check_app_version_changed() {
local return_value=${YNH_APP_UPGRADE_TYPE}
if [ "$return_value" == "UPGRADE_SAME" ] || [ "$return_value" == "DOWNGRADE" ]; then
return_value="UPGRADE_APP"
fi
echo $return_value
} }
# Compare the current package version is strictly lower than another version given as an argument # Compare the current package version is strictly lower than another version given as an argument