diff --git a/config_panel.toml b/config_panel.toml index e5e88ae..00e0377 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -16,6 +16,14 @@ name = "Nextcloud configuration" type = "button" style = "success" + [main.version] + [main.version.version_to_follow] + ask.en = "Upgrade channel to use" + type = "select" + choices = ["stable", "oldstable"] + default = "stable" + help.en = "Recent major releases contains sometimes some annoying bugs or regressions. Using the oldstable channel during this period can be useful if you need high stability." + [main.addressbook] name = "Address book configuration" diff --git a/manifest.toml b/manifest.toml index 8102692..0076409 100644 --- a/manifest.toml +++ b/manifest.toml @@ -60,6 +60,13 @@ ram.runtime = "512M" type = "boolean" default = true + [install.version_to_follow] + ask.en = "Upgrade channel to use" + help.en = "Recent major releases contains sometimes some annoying bugs or regressions. Using the oldstable channel during this period can be useful if you need high stability." + type = "select" + choices = ["stable", "oldstable"] + default = "stable" + [resources] [resources.sources] diff --git a/scripts/install b/scripts/install index 0987b84..b3c27f7 100755 --- a/scripts/install +++ b/scripts/install @@ -23,8 +23,15 @@ ynh_script_progression --message="Setting up source files..." --weight=5 # Enable YunoHost patches on Nextcloud sources cp -a ../sources/patches_last_version/* ../sources/patches + +source_id="main" +if [ "$version_to_follow" == "oldstable" ]; then + last_version=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]') + last_major_version=${last_version%%.*} + last_major_version=$(( $last_major_version - 1 )) +fi # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir" --source_id="$source_id" #================================================= # PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index c4b764c..ea3970b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,6 +35,13 @@ then ynh_die --message="Upgrading from Nextcloud < 22.2 is not supported anymore. You should first upgrade to 22.2 using: yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/41f5f902e7c7cd3c30a6793020562ba98b9bf3e9" fi +if [ -z "${version_to_follow:-}" ] +then + version_to_follow=stable + ynh_app_setting_set --app=$app --key=version_to_follow --value="$version_to_follow" +fi + + #================================================= # SPECIFIC UPGRADE #================================================= @@ -123,6 +130,11 @@ current_major_version=${current_version%%.*} last_version=$(ynh_read_manifest --manifest_key="resources.sources.main.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]') last_major_version=${last_version%%.*} +if [[ "$version_to_follow" == "oldstable" ]] +then + last_major_version=$(( $last_major_version - 1 )) + last_version=$(ynh_read_manifest --manifest_key="resources.sources.${last_major_version}.url" | grep -o '[0-9][0-9]\.[0-9]\.[0-9]') +fi if [[ "$last_major_version" != "$current_major_version" ]] then @@ -164,17 +176,19 @@ then fi # While the current version is not the last version, do an upgrade - while [ "$last_version" != "$current_version" ] + while [[ "$last_version" > "$current_version" ]] do - next_major_version="$(( $current_major_version + 1 ))" + source_id="$next_major_version" if [[ "$next_major_version" -ge "$last_major_version" ]]; then ynh_print_info --message="Upgrading to Nextcloud $last_version" cp -a ../sources/patches_last_version/* ../sources/patches - source_id="main" + if [[ "$version_to_follow" != "oldstable" ]] + then + source_id="main" + fi else ynh_print_info --message="Upgrading to Nextcloud $next_major_version" - source_id="$next_major_version" fi # Create a temporary directory diff --git a/tests.toml b/tests.toml index cdd5e77..2685512 100644 --- a/tests.toml +++ b/tests.toml @@ -2,6 +2,8 @@ test_format = 1.0 [default] + args.version_to_follow = "stable" + # ------------------------------- # Commits to test upgrade from # ------------------------------- @@ -11,3 +13,9 @@ test_format = 1.0 test_upgrade_from.9c6d1eea.name = "Upgrade from 27.1.4" test_upgrade_from.e9f82ab7.name = "Upgrade from 28.0.6" test_upgrade_from.e9f82ab7.args.system_addressbook_exposed = "yes" + +[oldstable] + + args.version_to_follow = "oldstable" + test_upgrade_from.e9f82ab7.name = "Upgrade from 28.0.6" + test_upgrade_from.e9f82ab7.args.system_addressbook_exposed = "yes" \ No newline at end of file