Restored error handling when missing vanilla version (#1389)

This commit is contained in:
Geoff Bourne 2022-02-26 21:28:30 -06:00 committed by GitHub
parent 1f8a3d85d1
commit 2e24bdfff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 13 deletions

View File

@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \ --var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz --from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
ARG MC_HELPER_VERSION=1.16.6 ARG MC_HELPER_VERSION=1.16.8
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION} ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \ RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
| tar -C /usr/share -zxf - \ | tar -C /usr/share -zxf - \

View File

@ -99,7 +99,7 @@ resolve_versions() {
log "Checking Forge version information." log "Checking Forge version information."
case $FORGEVERSION in case $FORGEVERSION in
LATEST) LATEST)
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" "$promosUrl"); then if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" --json-value-when-missing "" "$promosUrl"); then
log "ERROR: Version $VANILLA_VERSION is not supported by Forge" log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
log " Refer to http://files.minecraftforge.net/ for supported versions" log " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2 exit 2
@ -107,8 +107,8 @@ resolve_versions() {
;; ;;
RECOMMENDED) RECOMMENDED)
if ! FORGE_VERSION=$(get -s --json-path ".promos['$VANILLA_VERSION-recommended']" "$promosUrl"); then if ! FORGE_VERSION=$(get -s --json-path ".promos['$VANILLA_VERSION-recommended']" --json-value-when-missing "" "$promosUrl"); then
if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" "$promosUrl"); then if ! FORGE_VERSION=$(get --json-path ".promos['$VANILLA_VERSION-latest']" --json-value-when-missing "" "$promosUrl"); then
log "ERROR: Version $VANILLA_VERSION is not supported by Forge" log "ERROR: Version $VANILLA_VERSION is not supported by Forge"
log " Refer to http://files.minecraftforge.net/ for supported versions" log " Refer to http://files.minecraftforge.net/ for supported versions"
exit 2 exit 2

View File

@ -8,27 +8,25 @@ set -o pipefail
export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar" export SERVER="minecraft_server.${VANILLA_VERSION// /_}.jar"
if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
log "Downloading $SERVER ..." log "Locating download for $SERVER ..."
debug "Finding version manifest for $VANILLA_VERSION" debug "Finding version manifest for $VANILLA_VERSION"
versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url') versionManifestUrl=$(get 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | jq --arg VANILLA_VERSION "$VANILLA_VERSION" --raw-output '[.versions[]|select(.id == $VANILLA_VERSION)][0].url')
result=$? result=$?
if [ $result != 0 ]; then if [ $result != 0 ]; then
log "ERROR failed to obtain version manifest URL ($result)" log "ERROR: failed to obtain version manifest URL ($result)"
exit 1 exit 1
fi fi
if [ "$versionManifestUrl" = "null" ]; then if [ "$versionManifestUrl" = "null" ]; then
log "ERROR couldn't find a matching manifest entry for $VANILLA_VERSION" log "ERROR: couldn't find a matching manifest entry for $VANILLA_VERSION"
exit 1 exit 1
fi fi
debug "Found version manifest at $versionManifestUrl" debug "Found version manifest at $versionManifestUrl"
serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}") if ! serverDownloadUrl=$(get --json-path '$.downloads.server.url' "${versionManifestUrl}"); then
result=$? log "ERROR: failed to obtain version manifest from $versionManifestUrl ($result)"
if [ $result != 0 ]; then
log "ERROR failed to obtain version manifest from $versionManifestUrl ($result)"
exit 1 exit 1
elif [ "$serverDownloadUrl" = "null" ]; then elif [ "$serverDownloadUrl" = "null" ]; then
log "ERROR version $VANILLA_VERSION does not provide a server download" log "ERROR: there is not a server download for version $VANILLA_VERSION"
exit 1 exit 1
fi fi
@ -36,7 +34,7 @@ if [ ! -e "$SERVER" ] || [ -n "$FORCE_REDOWNLOAD" ]; then
get -o "$SERVER" "$serverDownloadUrl" get -o "$SERVER" "$serverDownloadUrl"
result=$? result=$?
if [ $result != 0 ]; then if [ $result != 0 ]; then
log "ERROR failed to download server from $serverDownloadUrl ($result)" log "ERROR: failed to download server from $serverDownloadUrl ($result)"
exit 1 exit 1
fi fi
fi fi