From 46526422dfa33f17df00b0f4535ed72f4277d0f1 Mon Sep 17 00:00:00 2001 From: bryan Date: Thu, 24 Apr 2025 11:04:42 -0400 Subject: [PATCH] Split MC container creation into function --- installJRMC | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/installJRMC b/installJRMC index 0daeb6b..02b1711 100755 --- a/installJRMC +++ b/installJRMC @@ -418,20 +418,7 @@ get_latest_mc_version() { local cnt mc_version_source # Use generalized containerized package manager to determine latest MC version - if install_package --silent buildah && - cnt=$(sudo buildah from --quiet alpine:edge 2>/dev/null) && - sudo buildah run "$cnt" -- sh -c ' - apk add --no-cache apt curl gnupg &>/dev/null - curl -fsSL https://dist.jriver.com/mediacenter@jriver.com.gpg.key | gpg --dearmor -o /usr/share/keyrings/jriver-com-archive-keyring.gpg - cat <<-EOF > /etc/apt/sources.list.d/jriver.sources - Types: deb - URIs: https://dist.jriver.com/latest/mediacenter/ - Signed-By: /usr/share/keyrings/jriver-com-archive-keyring.gpg - Suites: '"$MC_REPO"' - Components: main - Architectures: '"$MC_ARCH"' - EOF - apt-get update --allow-insecure-repositories &>/dev/null' && + if cnt=$(apt_mc_container) && MC_VERSION=$(sudo buildah run "$cnt" -- apt-cache policy "mediacenter${USER_MC_MVERSION:-${MC_VERSION%%.*}}" | grep Candidate | awk '{print $2}' | sort -V | tail -n1) && [[ $MC_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then mc_version_source="containerized package manager" @@ -799,7 +786,7 @@ acquire_deb_new() { apt-get update --allow-insecure-repositories &>/dev/null cd /download apt-get download --allow-unauthenticated mediacenter'"$MC_MVERSION"'' && - sudo buildah copy "$cnt" /download/MediaCenter-"$MC_VERSION"*.deb "$OUTPUT_DIR/SOURCES/" && + sudo buildah copy "$cnt" "/download/*.deb" "$OUTPUT_DIR/SOURCES/" && sudo buildah rm "$cnt" # Return if the download was successful @@ -1865,6 +1852,24 @@ download() { debug "${cmd[@]}" "$url" "${cmd[@]}" "$url" } +apt_mc_container() { + debug "Running: ${FUNCNAME[0]}" + install_package --silent buildah && + cnt=$(sudo buildah from --quiet alpine:edge 2>/dev/null) && + sudo buildah run "$cnt" -- sh -c ' + apk add --no-cache apt curl gnupg &>/dev/null + curl -fsSL https://dist.jriver.com/mediacenter@jriver.com.gpg.key | gpg --dearmor -o /usr/share/keyrings/jriver-com-archive-keyring.gpg &>/dev/null + cat <<-EOF > /etc/apt/sources.list.d/jriver.sources + Types: deb + URIs: https://dist.jriver.com/latest/mediacenter/ + Signed-By: /usr/share/keyrings/jriver-com-archive-keyring.gpg + Suites: '"$MC_REPO"' + Components: main + Architectures: '"$MC_ARCH"' + EOF + apt-get update --allow-insecure-repositories &>/dev/null' && + echo "$cnt" +} # Roughly turn debugging on for pre-init # Reset and reparse in parse_input() with getopt