Set MC_VERSION in all cases

This commit is contained in:
2025-10-21 17:23:43 -04:00
parent c9ac0c94b0
commit 29ade7e11c

View File

@@ -392,10 +392,7 @@ init() {
echo "MC source -> target: $MC_REPO $MC_ARCH -> $BUILD_TARGET $ARCH" echo "MC source -> target: $MC_REPO $MC_ARCH -> $BUILD_TARGET $ARCH"
# Retrieve the latest MC version number if we need it set_mc_version
if ((BUILD_SWITCH || LOCAL_INSTALL_SWITCH || CREATEREPO_SWITCH)); then
get_mc_version
fi
echo "Selected MC version $MC_VERSION from the $MC_REPO repo (via $MC_VERSION_SOURCE)" echo "Selected MC version $MC_VERSION from the $MC_REPO repo (via $MC_VERSION_SOURCE)"
@@ -417,16 +414,26 @@ init() {
} }
# @description Determines the latest JRiver MC version using several methods # @description Determines the latest JRiver MC version using several methods
get_mc_version() { set_mc_version() {
debug "${FUNCNAME[0]}()" debug "${FUNCNAME[0]}()"
declare -g MC_VERSION MC_VERSION_SOURCE declare -g MC_VERSION MC_VERSION_SOURCE
# User --mcversion
if [[ -n $MC_VERSION_USER ]]; then if [[ -n $MC_VERSION_USER ]]; then
MC_VERSION="$MC_VERSION_USER" MC_VERSION="$MC_VERSION_USER"
MC_VERSION_SOURCE="user input" MC_VERSION_SOURCE="user input"
return 0
fi
# Package manager will handle updates in other instances
if ! ((BUILD_SWITCH || LOCAL_INSTALL_SWITCH || CREATEREPO_SWITCH)); then
MC_VERSION="$MC_VERSION_HARDCODE"
MC_VERSION_SOURCE="hardcoded"
return 0
fi
# Determine latest version
# Containerized package manager # Containerized package manager
elif create_mc_apt_container && if create_mc_apt_container &&
MC_VERSION=$(sudo buildah run "$CNT" -- apt-cache policy "mediacenter${MC_MVERSION_USER:-${MC_VERSION_HARDCODE%%.*}}" | awk '/Candidate:/ {sub(/-.*/, "", $2); print $2}' | sort -V | tail -n1) && MC_VERSION=$(sudo buildah run "$CNT" -- apt-cache policy "mediacenter${MC_MVERSION_USER:-${MC_VERSION_HARDCODE%%.*}}" | awk '/Candidate:/ {sub(/-.*/, "", $2); print $2}' | sort -V | tail -n1) &&
execute sudo buildah rm -f "$CNT" && execute sudo buildah rm -f "$CNT" &&
[[ $MC_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then [[ $MC_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then