Download and use packwiz from Maven repository (#1725)

Also
* Added github actions debug support
* added use of fileNotExists
This commit is contained in:
Geoff Bourne
2022-09-10 12:58:32 -05:00
committed by GitHub
parent 4d3464f3f1
commit fabe14db49
12 changed files with 98 additions and 74 deletions

View File

@@ -22,39 +22,26 @@ if isTrue "${REMOVE_OLD_MODS}" && [ -z "${MODS_FILE}" ]; then
rm -f "$sum_file"
fi
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
# Ensure we have the latest packwiz bootstrap installer
latestPackwiz=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest")
if [[ -z "${latestPackwiz}" ]]; then
log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
else
isDebugging && log "Latest packwiz ${latestPackwiz}"
latestPackwizVer=$(echo "${latestPackwiz}" | jq --raw-output '.tag_name')
latestPackwizUrl=$(echo "${latestPackwiz}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer-bootstrap.jar")) | .url')
: "${PACKWIZ_BOOTSTRAP_JAR:=packwiz-installer-bootstrap_${latestPackwizVer}.jar}"
if [[ ! -e $PACKWIZ_BOOTSTRAP_JAR ]]; then
log "Downloading Packwiz ${latestPackwizVer}"
if ! curl -H "Accept:application/octet-stream" -o "$PACKWIZ_BOOTSTRAP_JAR" -fsSL ${latestPackwizUrl}; then
log "ERROR: failed to download Packwiz bootstrap installer"
exit 1
fi
function handlePackwiz() {
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
if [[ "${PACKWIZ_URL:-}" ]]; then
if ! packwizInstaller=$(mc-image-helper maven-download \
--maven-repo=https://maven.packwiz.infra.link/repository/release/ \
--group=link.infra.packwiz --artifact=packwiz-installer --classifier=dist \
--skip-existing); then
log "ERROR: failed to get packwiz installer"
exit 1
fi
log "Running packwiz installer against URL: ${PACKWIZ_URL}"
if ! java -cp "${packwizInstaller}" link.infra.packwiz.installer.Main "${PACKWIZ_URL}"; then
log "ERROR failed to run packwiz installer"
exit 1
fi
fi
log "Running packwiz installer against URL: ${PACKWIZ_URL}"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -s server "${PACKWIZ_URL}"
#if bootstrap download fails, download installer manually - then run without updating
returnVal=$?
if [[ $returnVal ]]; then
latestPackwizInstaller=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer/releases/latest")
latestPackwizInstallerVer=$(echo "${latestPackwizInstaller}" | jq --raw-output '.tag_name')
latestPackwizInstallerUrl=$(echo "${latestPackwizInstaller}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer.jar")) | .url')
log "Packwiz couldn't update - Downloading Packwiz Installer ${latestPackwizInstallerVer}"
get_from_gh "${latestPackwizInstallerUrl}" -H "Accept:application/octet-stream" -o "packwiz-installer.jar"
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
fi
fi
}
function handleModpackListOrFile() {
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
if [[ "$MODPACK" ]]; then
if isURL "${MODPACK}"; then
@@ -149,7 +136,9 @@ elif [[ "$MODS_FILE" ]]; then
exit 1
fi
fi
}
function handleCurseForgeManifest() {
if [[ "$MANIFEST" ]]; then
if [[ -e "$MANIFEST" ]]; then
EFFECTIVE_MANIFEST_FILE=$MANIFEST
@@ -192,6 +181,7 @@ case "X$EFFECTIVE_MANIFEST_FILE" in
;;
esac
fi
}
function genericPacks() {
: "${GENERIC_PACKS:=${GENERIC_PACK}}"
@@ -291,6 +281,12 @@ function modrinthProjects() {
fi
}
handlePackwiz
handleModpackListOrFile
handleCurseForgeManifest
genericPacks
modrinthProjects