diff options
| author | crueter <crueter@eden-emu.dev> | 2025-10-05 03:04:53 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-10-05 03:04:53 +0200 |
| commit | 9f385bf627e40e2b7d5b06cd83cab0a4e9f98f99 (patch) | |
| tree | a9146b701ca51c941197fe60f90b691ecf60506c /tools/cpm/check-updates.sh | |
| parent | 1a13e79c3d8619ff302d9c77eacf1a35c2210b66 (diff) | |
[tools, cmake] refactor: update/hash check scripts, use tags for some more deps, proper CPMUtil separation (#2666)
Uses tags for a bunch of deps that can use them
Also adds a bunmch of scripts to tools/cpm, notably for checking hashes
and checking for updates.
TODO for the future:
- CI target to check hashes
- Weekly CI to check for updates
Need to get that other CI runner up
additional stuff
- Ports gentoo fixes
- makes solaris work (TODO: sdl2)
- way better docs
- properly separates CPMUtil as a standalone project
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2666
Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'tools/cpm/check-updates.sh')
| -rwxr-xr-x | tools/cpm/check-updates.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tools/cpm/check-updates.sh b/tools/cpm/check-updates.sh new file mode 100755 index 0000000000..bdccf96ca2 --- /dev/null +++ b/tools/cpm/check-updates.sh @@ -0,0 +1,90 @@ +#!/bin/sh -e + +# SPDX-FileCopyrightText: 2025 crueter +# SPDX-License-Identifier: GPL-3.0-or-later + +# env vars: +# - UPDATE: update if available +# - FORCE: forcefully update + +# shellcheck disable=SC1091 +. tools/cpm/common.sh + +RETURN=0 + +filter() { + TAGS=$(echo "$TAGS" | jq "[.[] | select(.name | test(\"$1\"; \"i\") | not)]") # vulkan +} + +for PACKAGE in "$@" +do + export PACKAGE + # shellcheck disable=SC1091 + . tools/cpm/package.sh + + SKIP=$(value "skip_updates") + + [ "$SKIP" = "true" ] && continue + + [ "$REPO" = null ] && continue + [ "$GIT_HOST" != "github.com" ] && continue # TODO + # shellcheck disable=SC2153 + [ "$TAG" = null ] && continue + + echo "-- Package $PACKAGE" + + # TODO(crueter): Support for Forgejo updates w/ forgejo_token + # Use gh-cli to avoid ratelimits lmao + TAGS=$(gh api --method GET "/repos/$REPO/tags") + + # filter out some commonly known annoyances + # TODO add more + + filter vulkan-sdk # vulkan + filter yotta # mbedtls + + # ignore betas/alphas (remove if needed) + filter alpha + filter beta + filter rc + + # Add package-specific overrides here, e.g. here for fmt: + [ "$PACKAGE" = fmt ] && filter v0.11 + + LATEST=$(echo "$TAGS" | jq -r '.[0].name') + + [ "$LATEST" = "$TAG" ] && [ "$FORCE" != "true" ] && echo "-- * Up-to-date" && continue + + RETURN=1 + + if [ "$HAS_REPLACE" = "true" ]; then + # this just extracts the tag prefix + VERSION_PREFIX=$(echo "$ORIGINAL_TAG" | cut -d"%" -f1) + + # then we strip out the prefix from the new tag, and make that our new git_version + NEW_GIT_VERSION=$(echo "$LATEST" | sed "s/$VERSION_PREFIX//g") + fi + + echo "-- * Version $LATEST available, current is $TAG" + + export USE_TAG=true + HASH=$(tools/cpm/hash.sh "$REPO" "$LATEST") + + echo "-- * New hash: $HASH" + + if [ "$UPDATE" = "true" ]; then + RETURN=0 + + if [ "$HAS_REPLACE" = "true" ]; then + NEW_JSON=$(echo "$JSON" | jq ".hash = \"$HASH\" | .git_version = \"$NEW_GIT_VERSION\"") + else + NEW_JSON=$(echo "$JSON" | jq ".hash = \"$HASH\" | .tag = \"$LATEST\"") + fi + + export NEW_JSON + + tools/cpm/replace.sh + fi +done + +exit $RETURN
\ No newline at end of file |
