[tools] refactor: reorganize, commonalities, moar tags, posix compat
all scripts are fully posix compliant Signed-off-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
parent
dbc89d2f20
commit
240c2d14d4
18 changed files with 458 additions and 375 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
@ -10,42 +10,26 @@
|
|||
# - UPDATE: update if available
|
||||
# - FORCE: forcefully update
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
# shellcheck disable=SC2038
|
||||
[ -z "$PACKAGES" ] && PACKAGES=$(find . src -maxdepth 3 -name cpmfile.json | xargs jq -s 'reduce .[] as $item ({}; . * $item)')
|
||||
# shellcheck disable=SC1091
|
||||
. tools/cpm/common.sh
|
||||
|
||||
for package in "$@"
|
||||
do
|
||||
JSON=$(echo "$PACKAGES" | jq -r ".\"$package\" | select( . != null )")
|
||||
export package
|
||||
# shellcheck disable=SC1091
|
||||
. tools/cpm/package.sh
|
||||
|
||||
[ -z "$JSON" ] && echo "!! No cpmfile definition for $package" && continue
|
||||
|
||||
GIT_HOST=$(jq -r ".git_host" <<< "$JSON")
|
||||
[ "$GIT_HOST" = null ] && GIT_HOST=github.com
|
||||
|
||||
REPO=$(jq -r ".repo" <<< "$JSON")
|
||||
TAG=$(jq -r ".tag" <<< "$JSON")
|
||||
SKIP=$(jq -r ".skip_updates" <<< "$JSON")
|
||||
SKIP=$(value "skip_updates")
|
||||
|
||||
[ "$SKIP" = "true" ] && continue
|
||||
|
||||
[ "$REPO" = null ] && continue # echo "No repo defined for $package, skipping" && continue
|
||||
[ "$GIT_HOST" != "github.com" ] && continue # echo "Unsupported host $GIT_HOST for $package, skipping" && continue
|
||||
[ "$TAG" = null ] && continue # echo "No tag defined for $package, skipping" && continue
|
||||
[ "$REPO" = null ] && continue
|
||||
[ "$GIT_HOST" != "github.com" ] && continue # TODO
|
||||
[ "$TAG" = null ] && continue
|
||||
|
||||
echo "-- Package $package"
|
||||
|
||||
GIT_VERSION=$(jq -r ".git_version" <<< "$JSON")
|
||||
|
||||
echo "$TAG" | grep -e "%VERSION%" > /dev/null && HAS_REPLACE=true || HAS_REPLACE=false
|
||||
ORIGINAL_TAG="$TAG"
|
||||
|
||||
TAG=${TAG//%VERSION%/$GIT_VERSION}
|
||||
|
||||
ARTIFACT=$(jq -r ".artifact" <<< "$JSON")
|
||||
ARTIFACT=${ARTIFACT//%VERSION%/$GIT_VERSION}
|
||||
ARTIFACT=${ARTIFACT//%TAG%/$TAG}
|
||||
|
||||
# TODO(crueter): Support for Forgejo updates w/ forgejo_token
|
||||
# Use gh-cli to avoid ratelimits lmao
|
||||
TAGS=$(gh api --method GET "/repos/$REPO/tags")
|
||||
|
||||
|
@ -58,14 +42,6 @@ do
|
|||
TAGS=$(echo "$TAGS" | jq '[.[] | select(.name | test("beta"; "i") | not)]')
|
||||
TAGS=$(echo "$TAGS" | jq '[.[] | select(.name | test("rc"; "i") | not)]')
|
||||
|
||||
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=${LATEST//$VERSION_PREFIX/}
|
||||
fi
|
||||
|
||||
# thanks fmt
|
||||
[ "$package" = fmt ] && TAGS=$(echo "$TAGS" | jq '[.[] | select(.name | test("v0.11"; "i") | not)]')
|
||||
|
||||
|
@ -73,6 +49,14 @@ do
|
|||
|
||||
[ "$LATEST" = "$TAG" ] && [ "$FORCE" != "true" ] && echo "-- * Up-to-date" && continue
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue