From 6e9e4d680e9b33ec19dffe6b9af6b59f434c9c64 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Fri, 12 Jan 2024 20:47:14 +0100 Subject: [PATCH 1/7] Upgrade script: check that installed apps are compatible with the future version before actually starting the upgrade --- scripts/upgrade | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 715c330c..aaa265a3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,16 +74,45 @@ local mount_id=$(exec_occ files_external:create --output=json \ || exec_occ files_external:option "$mount_id" enable_sharing true } +function list_installed_apps_not_compatible_with_future_version() +{ + local nextcloud_destination_version="$1" + local nextcloud_current_version="$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)" + local installed_apps=$(mktemp) + local core_apps_in_current_version=$(mktemp) + local nextcloud_destination_appcatalog=$(mktemp) + + # List installed apps + exec_occ app:list --output json | jq -r ".enabled | keys[]" | sort > $installed_apps + # Fetch Nextcloud list of core apps from their github repo for the current version + curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version.0.0/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version + # Fetch Nextcloud app catalog (doesnt contain core app) for the future version + curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_appcatalog.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog + + # Compute set complement, cf https://catonmat.net/set-operations-in-unix-shell + # We want to list the installed apps which are neither core apps nor in the destination catalog + comm -23 <(comm -23 $installed_apps $core_apps_in_current_version) $nextcloud_destination_appcatalog +} + +# Load the last available version +source upgrade.d/upgrade.last.sh +last_version=$next_version + +last_major_version=${last_version%%.*} + +if [[ "$last_major_version" != "$current_major_version" ]] +then + installed_apps_not_compatible_with_future_version="$(list_installed_apps_not_compatible_with_future_version $last_major_version)" + if [[ -n "$installed_apps_not_compatible_with_future_version" ]] + then + ynh_die --message="The following apps are not (yet?) compatible with Nextcloud $last_major_version. You should make sure to upgrade the app, or disable it, or wait for it to become compatible before running this upgrade : $installed_apps_not_compatible_with_future_version" + fi +fi + if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading Nextcloud..." --weight=3 - # Load the last available version - source upgrade.d/upgrade.last.sh - last_version=$next_version - - last_major_version=${last_version%%.*} - # Set write access for the following commands chown -R $app: "$install_dir" "$data_dir" From ab32f35ce999067ef767eb2f11e1d6d5914e0f35 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Fri, 12 Jan 2024 20:55:24 +0100 Subject: [PATCH 2/7] Create PRE_UPGRADE.md to encourage people to check their apps are up to date before running the upgrade --- doc/PRE_UPGRADE.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/PRE_UPGRADE.md diff --git a/doc/PRE_UPGRADE.md b/doc/PRE_UPGRADE.md new file mode 100644 index 00000000..58e7dc24 --- /dev/null +++ b/doc/PRE_UPGRADE.md @@ -0,0 +1 @@ +If you are upgrading to a new major version of Nextcloud, please make sure that your Nextcloud apps are up to date from Nextcloud's administration panel beforehand. From 53eaa33618267ecb2c91761d72bb992f3eb8afa5 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Wed, 17 Jan 2024 02:02:57 +0100 Subject: [PATCH 3/7] Update scripts/upgrade: fix fetching of shipped app for current version --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index aaa265a3..eaf6a365 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -85,7 +85,7 @@ function list_installed_apps_not_compatible_with_future_version() # List installed apps exec_occ app:list --output json | jq -r ".enabled | keys[]" | sort > $installed_apps # Fetch Nextcloud list of core apps from their github repo for the current version - curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version.0.0/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version + curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version # Fetch Nextcloud app catalog (doesnt contain core app) for the future version curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_appcatalog.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog From d7e05b002216f8df2b867766520dda6b7bd99548 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Wed, 17 Jan 2024 02:04:44 +0100 Subject: [PATCH 4/7] Update scripts/upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index eaf6a365..87f124a2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,7 +87,7 @@ function list_installed_apps_not_compatible_with_future_version() # Fetch Nextcloud list of core apps from their github repo for the current version curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version # Fetch Nextcloud app catalog (doesnt contain core app) for the future version - curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_appcatalog.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog + curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_version.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog # Compute set complement, cf https://catonmat.net/set-operations-in-unix-shell # We want to list the installed apps which are neither core apps nor in the destination catalog From fc131c1b3b8d97981a02397c961dd68bd5cdb390 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:24:15 +0100 Subject: [PATCH 5/7] Update upgrade: fix boring bug because of apt install piped into jq --- scripts/upgrade | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index fc5495f3..ab3ab3a8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -89,6 +89,9 @@ function list_installed_apps_not_compatible_with_future_version() local core_apps_in_current_version=$(mktemp) local nextcloud_destination_appcatalog=$(mktemp) + # Run a first "dummy" command just to make sure we have the appropriate php dependencies installed, + # otherwise this creates funky stuff when tweaking the apt deps because the next command is piped into jq ... + exec_occ -V # List installed apps exec_occ app:list --output json | jq -r ".enabled | keys[]" | sort > $installed_apps # Fetch Nextcloud list of core apps from their github repo for the current version From 12b88c27480f2f0cf7501de7491c36e5483b25ed Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 25 Jan 2024 19:12:47 +0100 Subject: [PATCH 6/7] Update upgrade: zgrompf --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index ab3ab3a8..0329abfa 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,7 +91,7 @@ function list_installed_apps_not_compatible_with_future_version() # Run a first "dummy" command just to make sure we have the appropriate php dependencies installed, # otherwise this creates funky stuff when tweaking the apt deps because the next command is piped into jq ... - exec_occ -V + exec_occ -V >/dev/null # List installed apps exec_occ app:list --output json | jq -r ".enabled | keys[]" | sort > $installed_apps # Fetch Nextcloud list of core apps from their github repo for the current version From 2891edce520075266b9ff401ca3829cac8c18a17 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Thu, 25 Jan 2024 19:22:25 +0100 Subject: [PATCH 7/7] Update PRE_UPGRADE.md --- doc/PRE_UPGRADE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/PRE_UPGRADE.md b/doc/PRE_UPGRADE.md index 58e7dc24..663bc771 100644 --- a/doc/PRE_UPGRADE.md +++ b/doc/PRE_UPGRADE.md @@ -1 +1,3 @@ If you are upgrading to a new major version of Nextcloud, please make sure that your Nextcloud apps are up to date from Nextcloud's administration panel beforehand. + +Additionally, if you installed specific Nextcloud apps, we recommend making sure that they are compatible with the new major version. YunoHost will attempt to check this automatically at the very beginning of the upgrade, but a manual check doesn't hurt either. For Nextcloud 28, this forum thread might be helpful : .