mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
Merge pull request #1971 from nextcloud/devel
[hotfix] library.sh: Fix resolution of target nextcloud version if requesting older version than current
This commit is contained in:
commit
63b6aca7bb
@ -24,7 +24,7 @@ ncc status &>/dev/null || { [[ "$DBG" == x ]] && ncc status; echo "Next
|
||||
CURRENT="$(nc_version)"
|
||||
if [[ "$VER" == "0" ]] || [[ "$VER" == "" ]]
|
||||
then
|
||||
REQUESTED_VERSION="${NCLATESTVER?}"
|
||||
REQUESTED_VERSION="latest"
|
||||
else
|
||||
REQUESTED_VERSION="$VER"
|
||||
fi
|
||||
@ -57,10 +57,11 @@ grep -qP "\d+\.\d+\.\d+" <<<"$CURRENT" || { echo "Malformed version $CURRENT"; e
|
||||
grep -qP "\d+\.\d+\.\d+" <<<"$TARGET_VERSION" || { echo "Malformed version $TARGET_VERSION" ; exit 1; }
|
||||
|
||||
echo "Current Nextcloud version $CURRENT"
|
||||
echo "Available Nextcloud version $TARGET_VERSION"
|
||||
echo "Requested Nextcloud version $REQUESTED_VERSION"
|
||||
echo "Selected Nextcloud version $TARGET_VERSION"
|
||||
if [[ "$TARGET_VERSION" != "$REQUESTED_VERSION" ]]
|
||||
then
|
||||
echo "INFO: You have requested an update to '${REQUESTED_VERSION}', but a direct update to '${REQUESTED_VERSION}' cannot be performed, so the latest available version that can be updated to has been selected automatically."
|
||||
echo "INFO: You have requested an update to '${REQUESTED_VERSION}', but a direct update to '${REQUESTED_VERSION}' cannot be performed, so the latest available version that can be updated to (${TARGET_VERSION}) has been selected automatically."
|
||||
fi
|
||||
|
||||
# make sure that cron.php is not running and there are no pending jobs
|
||||
|
||||
@ -531,11 +531,18 @@ function determine_nc_update_version() {
|
||||
supported_maj="${supported%%.*}"
|
||||
|
||||
# If valid version is requested -> direct update, don't consider anything else
|
||||
if [[ "$requested" =~ ^[0-9.]*$ ]] && [[ "$requested_maj" -le "$((current_maj + 1))" ]]
|
||||
if [[ "$requested" =~ ^[0-9]*.[0-9]*.[0-9]*$ ]]
|
||||
then
|
||||
if ! is_more_recent_than "${requested}" "${current}"
|
||||
then
|
||||
echo "$current"
|
||||
return 0
|
||||
elif [[ "$requested_maj" -le "$((current_maj + 1))" ]]
|
||||
then
|
||||
echo "$requested"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
versions="$(curl -q -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/nextcloud/server/releases?per_page=100 | jq -r '.[].tag_name' | grep -v -e 'rc.$' -e 'beta.$' | sort -V)"
|
||||
next_version="$(grep "v${current_maj}." <<<"${versions}" | tail -n 1 | tr -d 'v')"
|
||||
|
||||
76
etc/library.test
Normal file
76
etc/library.test
Normal file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
fail() {
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#shellcheck source=./library.sh
|
||||
. "$(dirname "$0")/library.sh" ||:
|
||||
|
||||
|
||||
case=1
|
||||
|
||||
current=27.0.1
|
||||
supported=27.0.8
|
||||
requested=""
|
||||
|
||||
expected=27.1.11
|
||||
|
||||
actual="$(determine_nc_update_version "$current" "$supported" "$requested")"
|
||||
|
||||
[[ "$expected" == "$actual" ]] || fail "C$case: unexpected nc target version: $actual (expected: $expected)"
|
||||
|
||||
|
||||
case=2
|
||||
|
||||
# TODO: Set to 26.0.1
|
||||
current=26.0.13
|
||||
supported=27.0.8
|
||||
requested=""
|
||||
|
||||
expected=27.1.11
|
||||
|
||||
actual="$(determine_nc_update_version "$current" "$supported" "$requested")"
|
||||
|
||||
[[ "$expected" == "$actual" ]] || fail "C$case: unexpected nc target version: $actual (expected: $expected)"
|
||||
|
||||
|
||||
case=3
|
||||
|
||||
current=26.0.1
|
||||
supported=27.0.8
|
||||
requested="27.1.3"
|
||||
|
||||
expected=27.1.3
|
||||
|
||||
actual="$(determine_nc_update_version "$current" "$supported" "$requested")"
|
||||
|
||||
[[ "$expected" == "$actual" ]] || fail "C$case: unexpected nc target version: $actual (expected: $expected)"
|
||||
|
||||
|
||||
case=4
|
||||
|
||||
current=29.0.5
|
||||
supported=27.0.8
|
||||
requested=""
|
||||
|
||||
expected=29.0.6
|
||||
|
||||
actual="$(determine_nc_update_version "$current" "$supported" "$requested")"
|
||||
|
||||
[[ "$expected" == "$actual" ]] || fail "C$case: unexpected nc target version: $actual (expected: $expected)"
|
||||
|
||||
|
||||
case=5
|
||||
|
||||
current=29.0.5
|
||||
supported=27.0.8
|
||||
requested="27.0.8"
|
||||
|
||||
expected="29.0.5"
|
||||
|
||||
actual="$(determine_nc_update_version "$current" "$supported" "$requested")"
|
||||
|
||||
[[ "$expected" == "$actual" ]] || fail "C$case: unexpected nc target version: $actual (expected: $expected)"
|
||||
Loading…
x
Reference in New Issue
Block a user