chg: Improved versions management

This commit is contained in:
Sayantan Santra 2023-08-06 15:55:54 -05:00
parent 7ed1bcb557
commit 4f8781aa98
Signed by: SinTan1729
GPG key ID: EB3E68BFBA25C85F

View file

@ -94,8 +94,9 @@ cd "$WDIR"
echo "$(date) | Starting check..." echo "$(date) | Starting check..."
if [[ $2 != buildonly ]]; then if [[ $2 != buildonly ]]; then
# Create a backup of versions # Create a new versions file, if needed
[ -f versions.json ] && cp versions.json versions.json.old || echo "{}" >versions.json [ -f versions.json ] || echo "{}" >versions.json
cp versions.json versions-new.json
# Fetch all the dependencies # Fetch all the dependencies
try=0 try=0
while :; do while :; do
@ -128,7 +129,7 @@ if [[ $2 != buildonly ]]; then
# shellcheck disable=SC2086,SC2046 # shellcheck disable=SC2086,SC2046
[[ $name == microg.apk ]] && download_link="https://github.com/$repo/releases/latest/download/$name" || download_link="$(echo "$data" | jq -r '.browser_download_url')" [[ $name == microg.apk ]] && download_link="https://github.com/$repo/releases/latest/download/$name" || download_link="$(echo "$data" | jq -r '.browser_download_url')"
curl -sLo "$name" "$download_link" curl -sLo "$name" "$download_link"
jq ".\"$basename\" = \"$version\"" versions.json >versions.json.tmp && mv versions.json.tmp versions.json jq ".\"$basename\" = \"$version\"" versions-new.json >versions.json.tmp && mv versions.json.tmp versions-new.json
echo "Upgraded $basename from $version_present to $version" echo "Upgraded $basename from $version_present to $version"
flag=true flag=true
fi fi
@ -268,10 +269,7 @@ if [ $error == 1 ]; then
$GOTIFY_NOTIFICATIONS && gotify_send_msg "$msg" $GOTIFY_NOTIFICATIONS && gotify_send_msg "$msg"
$NTFY_NOTIFICATIONS && ntfy_send_msg "$msg" $NTFY_NOTIFICATIONS && ntfy_send_msg "$msg"
if [[ $2 != buildonly ]]; then [[ $2 != buildonly ]] && mv versions-new.json versions-fail.json || mv versions-new.json versions.json
mv versions.json versions.json.fail
[ -f versions.json.old ] && mv versions.json.old versions.json
fi
exit 4 exit 4
fi fi