Skip to content

Commit 5bcdd2a

Browse files
committed
fix(scripts): resolve the mesa release without the GitHub API
install-mesa asked api.github.com for the latest release. Unauthenticated calls share one rate limit per IP and GitHub-hosted runners exhaust it, so the Kali XFCE build died with "403 rate limit exceeded", and every template that installs mesa was one unlucky runner away from the same. Follow the releases/latest redirect for the tag and build the download URL from it; neither needs the API. Signed-off-by: ravindu644 <droidcasts@protonmail.com>
1 parent ae202dc commit 5bcdd2a

1 file changed

Lines changed: 13 additions & 28 deletions

File tree

‎scripts/install-mesa‎

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
set -e
44

55
REPO="lfdevs/mesa-for-android-container"
6-
API_URL="https://api.github.com/repos/${REPO}/releases/latest"
76

87
# Must run as root
98
if [ "$(id -u)" -ne 0 ]; then
@@ -67,33 +66,19 @@ else
6766
apt-get install -y --no-install-recommends python3 $MESA_PACKAGES
6867
fi
6968

70-
echo "Fetching latest release info from ${REPO}..."
71-
72-
# Fetch and parse the download URL using python3
73-
DOWNLOAD_URL=$(python3 - <<EOF
74-
import urllib.request, json, sys
75-
76-
try:
77-
with urllib.request.urlopen("${API_URL}") as r:
78-
data = json.load(r)
79-
except Exception as e:
80-
print(f"Error fetching release info: {e}", file=sys.stderr)
81-
sys.exit(1)
82-
83-
tag = data.get("tag_name", "unknown")
84-
print(f"Latest release: {tag}", file=sys.stderr)
85-
86-
pattern = "${DISTRO_TAG}_${ARCH_TAG}"
87-
for asset in data.get("assets", []):
88-
name = asset.get("name", "")
89-
if pattern in name and name.endswith((".tar.gz", ".tar")):
90-
print(asset["browser_download_url"])
91-
sys.exit(0)
92-
93-
print(f"Error: No asset found matching '{pattern}'", file=sys.stderr)
94-
sys.exit(1)
95-
EOF
96-
)
69+
# No GitHub API here: unauthenticated calls to it share one rate limit per IP,
70+
# and GitHub-hosted runners burn through it, so CI died with "403 rate limit
71+
# exceeded". The releases/latest redirect and the download URL need no API.
72+
# Assets are named mesa-for-android-container_<version>_<distro>_<arch>, where
73+
# <version> is the tag without its "mesa-" prefix; Arch's is a plain .tar.
74+
echo "Resolving the latest release of ${REPO}..."
75+
TAG=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/${REPO}/releases/latest")
76+
TAG=${TAG##*/}
77+
[ -n "$TAG" ] || { echo "Error: could not resolve the latest release"; exit 1; }
78+
echo "Latest release: ${TAG}"
79+
EXT=.tar.gz
80+
[ "$DISTRO_TAG" = archlinux ] && EXT=.tar
81+
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/mesa-for-android-container_${TAG#mesa-}_${DISTRO_TAG}_${ARCH_TAG}${EXT}"
9782

9883
FILENAME=$(basename "$DOWNLOAD_URL")
9984
echo "Found: ${FILENAME}"

0 commit comments

Comments
 (0)