Split MC container creation into function

This commit is contained in:
2025-04-24 11:04:42 -04:00
parent 4cdce5c8ae
commit 46526422df

View File

@@ -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