[core]: feature - check_for_gh_release - version pinning (#7279)
* [core]: feature - check_for_gh_release - version pinning * Modify usage comments for check_for_gh_release Updated usage example for check_for_gh_release function. * Refactor jq installation command with STD variable * remove unneeded dev/null
This commit is contained in:
parent
b73bfdf7fd
commit
ede5f35f39
@ -1930,7 +1930,7 @@ function setup_ffmpeg() {
|
||||
# - If newer, sets global CHECK_UPDATE_RELEASE and returns 0
|
||||
#
|
||||
# Usage:
|
||||
# if check_for_gh_release "flaresolverr" "FlareSolverr/FlareSolverr"; then
|
||||
# if check_for_gh_release "flaresolverr" "FlareSolverr/FlareSolverr" [optional] "v1.1.1"; then
|
||||
# # trigger update...
|
||||
# fi
|
||||
# exit 0
|
||||
@ -1944,6 +1944,7 @@ function setup_ffmpeg() {
|
||||
check_for_gh_release() {
|
||||
local app="$1"
|
||||
local source="$2"
|
||||
local pinned_version="${3:-}" # optional
|
||||
local current_file="$HOME/.${app,,}"
|
||||
|
||||
msg_info "Check for update: ${app}"
|
||||
@ -1956,7 +1957,7 @@ check_for_gh_release() {
|
||||
|
||||
# jq check
|
||||
if ! command -v jq &>/dev/null; then
|
||||
$STD apt-get update
|
||||
$STD apt-get update -qq
|
||||
$STD apt-get install -y jq || {
|
||||
msg_error "Failed to install jq"
|
||||
return 1
|
||||
@ -1974,12 +1975,27 @@ check_for_gh_release() {
|
||||
fi
|
||||
|
||||
local current=""
|
||||
if [[ -f "$current_file" ]]; then
|
||||
current=$(<"$current_file")
|
||||
[[ -f "$current_file" ]] && current=$(<"$current_file")
|
||||
|
||||
# PINNED Releases
|
||||
if [[ -n "$pinned_version" ]]; then
|
||||
if [[ "$pinned_version" == "$release" ]]; then
|
||||
msg_ok "${app} pinned to v${pinned_version} (no update needed)"
|
||||
return 1
|
||||
else
|
||||
if [[ "$current" == "$pinned_version" ]]; then
|
||||
msg_ok "${app} pinned to v${pinned_version} (already installed, upstream v${release})"
|
||||
return 1
|
||||
fi
|
||||
msg_info "${app} pinned to v${pinned_version} (upstream v${release}) → update/downgrade required"
|
||||
CHECK_UPDATE_RELEASE="$pinned_version"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$release" != "$current" ]] || [[ ! -f "$current_file" ]]; then
|
||||
CHECK_UPDATE_RELEASE="$release"
|
||||
msg_info "New release available: v${release} (current: v${current:-none})"
|
||||
return 0
|
||||
else
|
||||
msg_ok "${app} is up to date (v${release})"
|
||||
|
Loading…
x
Reference in New Issue
Block a user