Update tools.func

This commit is contained in:
CanbiZ 2025-08-21 09:05:00 +02:00
parent 327d270294
commit ed551624e3

View File

@ -901,68 +901,56 @@ function fetch_and_deploy_gh_release() {
local assets url_match="" local assets url_match=""
assets=$(echo "$json" | jq -r '.assets[].browser_download_url') assets=$(echo "$json" | jq -r '.assets[].browser_download_url')
echo "[DEBUG] Listing all available assets from release:" # If explicit filename pattern is provided (param $6), match that first
for u in $assets; do
echo " -> $u"
done
# 1. Pattern match
if [[ -n "$asset_pattern" ]]; then if [[ -n "$asset_pattern" ]]; then
for u in $assets; do for u in $assets; do
filename_candidate="${u##*/}" case "${u##*/}" in
if [[ "$filename_candidate" == *"$asset_pattern"* ]]; then $asset_pattern)
url_match="$u" url_match="$u"
break break
fi ;;
esac
done done
fi fi
# 2. Arch match (only if no pattern match) # If no match via explicit pattern, fall back to architecture heuristic
if [[ -z "$url_match" ]]; then if [[ -z "$url_match" ]]; then
for u in $assets; do for u in $assets; do
filename_candidate="${u##*/}" if [[ "$u" =~ ($arch|amd64|x86_64|aarch64|arm64).*\.deb$ ]]; then
echo " [DEBUG] Checking asset: $filename_candidate"
if [[ "$filename_candidate" == *"$arch"* && "$filename_candidate" == *.deb ]]; then
url_match="$u" url_match="$u"
break break
fi fi
done done
fi fi
# 3. Fallback # Fallback: any .deb file
if [[ -z "$url_match" ]]; then if [[ -z "$url_match" ]]; then
for u in $assets; do for u in $assets; do
filename_candidate="${u##*/}" [[ "$u" =~ \.deb$ ]] && url_match="$u" && break
if [[ "$filename_candidate" == *.deb ]]; then
url_match="$u"
break
fi
done done
fi fi
if [[ -z "$url_match" ]]; then if [[ -z "$url_match" ]]; then
echo "[DEBUG] ❌ No suitable .deb asset found!" msg_error "No suitable .deb asset found for $app"
rm -rf "$tmpdir" rm -rf "$tmpdir"
return 1 return 1
fi fi
echo "[DEBUG] Final selected asset: $url_match"
filename="${url_match##*/}" filename="${url_match##*/}"
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url_match" || { curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url_match" || {
echo "[DEBUG] ❌ Download failed: $url_match" msg_error "Download failed: $url_match"
rm -rf "$tmpdir" rm -rf "$tmpdir"
return 1 return 1
} }
chmod 644 "$tmpdir/$filename" chmod 644 "$tmpdir/$filename"
if ! $STD apt-get install -y "$tmpdir/$filename"; then $STD apt-get install -y "$tmpdir/$filename" || {
if ! $STD dpkg -i "$tmpdir/$filename"; then $STD dpkg -i "$tmpdir/$filename" || {
echo "[DEBUG] ❌ Both apt and dpkg installation failed" msg_error "Both apt and dpkg installation failed"
rm -rf "$tmpdir" rm -rf "$tmpdir"
return 1 return 1
fi }
fi }
### Prebuild Mode ### ### Prebuild Mode ###
elif [[ "$mode" == "prebuild" ]]; then elif [[ "$mode" == "prebuild" ]]; then