summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Sneed <gary@getcobalt.org>2024-10-25 23:00:16 -0700
committerGary Sneed <gary@getcobalt.org>2024-10-25 23:00:16 -0700
commit078338201ed6579dbc7ed68ad6f4e4ceff8e717f (patch)
tree73d6fe6c99105629f7b6e0857ceb14c749e57b94
parenta799b160834d9278735abe0fc6679bfaf2e9f695 (diff)
jq check+POSIX fixesHEADv1.3master
-rwxr-xr-xlaunch.sh43
1 files changed, 31 insertions, 12 deletions
diff --git a/launch.sh b/launch.sh
index 1b3421b..d1274a9 100755
--- a/launch.sh
+++ b/launch.sh
@@ -1,5 +1,24 @@
#!/usr/bin/env sh
+JQ=${JQ:=jq}
+
+# Check for packages
+JQ_VERSION=$("${JQ}" --version 2>/dev/null)
+if [ "${JQ_VERSION}" = 'jq-1.3' ] || [ "${JQ_VERSION}" = 'jq-1.4' ] || [ "${JQ_VERSION}" = 'jq-1.5' ] || [ "${JQ_VERSION}" = 'jq-1.6' ]; then
+ echo 'ERROR: installed jq version is too old; must be at least 1.7'
+ exit 1
+elif [ -z ${JQ_VERSION} ]; then
+ echo 'ERROR: please install jq 1.7+'
+ exit 1
+fi
+
+NICKLE_LOCATION=$(which nickle)
+
+if [ ! -f "${NICKLE_LOCATION}" ]; then
+ echo "ERROR: please install Nickle"
+ exit 1
+fi
+
PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
# Only accepts 1 argument: the Minecraft profile to launch
@@ -55,10 +74,10 @@ VERSION_MANIFEST=$(cat "manifests/${VERSION}.json")
# Some libraries included in the manifests are known to cause issues, so we blacklist them here
# 1.12 and earlier, natives and regular libraries are contained in different elements. For 1.13 and later, an element may contain both.
CLASSPATH=
-for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do
- if [ "$(echo "${I}" | jq .downloads.artifact)" != 'null' ]; then
+for I in $(echo "${VERSION_MANIFEST}" | "${JQ}" -c .libraries.[]); do
+ if [ "$(echo "${I}" | "${JQ}" .downloads.artifact)" != 'null' ]; then
for J in ${BLACKLISTED_LIBRARIES}; do
- if [ ${J} == $(basename $(echo ${I} | jq -r .downloads.artifact.path)) ]; then
+ if [ "${J}" = "$(basename $(echo ${I} | "${JQ}" -r .downloads.artifact.path))" ]; then
SKIP=1
fi
done
@@ -66,14 +85,14 @@ for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do
SKIP=
continue
fi
- JAR=$(echo ${I} | jq -r .downloads.artifact.path)
+ JAR=$(echo ${I} | "${JQ}" -r .downloads.artifact.path)
if [ "${JAR}" != 'null' ]; then
CLASSPATH="${PWD}/libraries/${JAR}:${CLASSPATH}"
fi
fi
- if [ "$(echo "${I}" | jq .natives)" != 'null' ]; then
+ if [ "$(echo "${I}" | "${JQ}" .natives)" != 'null' ]; then
for J in ${BLACKLISTED_NATIVES}; do
- if [ ${J} == $(basename $(echo ${I} | jq ".downloads.classifiers.\"natives-${PLATFORM}\".path")) ]; then
+ if [ "${J}" = "$(basename $(echo ${I} | "${JQ}" ".downloads.classifiers.\"natives-${PLATFORM}\".path"))" ]; then
SKIP=1
fi
done
@@ -81,7 +100,7 @@ for I in $(echo "${VERSION_MANIFEST}" | jq -c .libraries.[]); do
SKIP=
continue
fi
- JAR=$(echo ${I} | jq -r ".downloads.classifiers.\"natives-${PLATFORM}\".path")
+ JAR=$(echo ${I} | "${JQ}" -r ".downloads.classifiers.\"natives-${PLATFORM}\".path")
if [ "${JAR}" != 'null' ]; then
CLASSPATH="${PWD}/libraries/${JAR}:${CLASSPATH}"
fi
@@ -94,17 +113,17 @@ done
CLASSPATH="${CLASSPATH}:${PWD}/${MINECRAFT_JAR}"
-if [ "$(echo "${VERSION_MANIFEST}" | jq -r .minecraftArguments)" != 'null' ]; then
- ARGUMENT_LIST=$(echo ${VERSION_MANIFEST} | jq -r .minecraftArguments)
+if [ "$(echo "${VERSION_MANIFEST}" | "${JQ}" -r .minecraftArguments)" != 'null' ]; then
+ ARGUMENT_LIST=$(echo ${VERSION_MANIFEST} | "${JQ}" -r .minecraftArguments)
else
- for I in $(echo ${VERSION_MANIFEST} | jq -r '.arguments.game[] | select(type=="string")'); do
+ for I in $(echo ${VERSION_MANIFEST} | "${JQ}" -r '.arguments.game[] | select(type=="string")'); do
ARGUMENT_LIST="${ARGUMENT_LIST} ${I}"
done
fi
-ARGUMENTS="$(echo ${ARGUMENT_LIST} | sed -e "s/\${auth_player_name}/${MCUSER}/" -e "s/\${version_name}/${VERSION}/" -e "s@\${game_directory}@\"${PWD}/instances/${INAME}\"@" -e "s@\${assets_root}@${PWD}/assets@" -e "s/\${assets_index_name}/$(echo ${VERSION_MANIFEST} | jq -r .assetIndex.id)/" -e 's/${auth_uuid}/00000000-0000-0000-0000-000000000000/' -e 's/${auth_access_token}/0/' -e 's/${user_type}/mojang/' -e "s/\${version_type}/$(echo ${VERSION_MANIFEST} | jq -r .type)/" -e 's/${user_properties}/{}/' -e "s@\${game_assets}@${PWD}/assets/virtual/legacy@" -e 's/${auth_session}/0/')"
+ARGUMENTS="$(echo ${ARGUMENT_LIST} | sed -e "s/\${auth_player_name}/${MCUSER}/" -e "s/\${version_name}/${VERSION}/" -e "s@\${game_directory}@\"${PWD}/instances/${INAME}\"@" -e "s@\${assets_root}@${PWD}/assets@" -e "s/\${assets_index_name}/$(echo ${VERSION_MANIFEST} | "${JQ}" -r .assetIndex.id)/" -e 's/${auth_uuid}/00000000-0000-0000-0000-000000000000/' -e 's/${auth_access_token}/0/' -e 's/${user_type}/mojang/' -e "s/\${version_type}/$(echo ${VERSION_MANIFEST} | "${JQ}" -r .type)/" -e 's/${user_properties}/{}/' -e "s@\${game_assets}@${PWD}/assets/virtual/legacy@" -e 's/${auth_session}/0/')"
-MAINCLASS=${MAINCLASS:=$(echo ${VERSION_MANIFEST} | jq -r .mainClass)}
+MAINCLASS=${MAINCLASS:=$(echo ${VERSION_MANIFEST} | "${JQ}" -r .mainClass)}
INSTANCES="${PWD}/instances"
if [ -f "playtime/${INAME}" ]; then