From 5770c407a0fdd6f139a2fd08d999f71e13b98103 Mon Sep 17 00:00:00 2001 From: bryan Date: Thu, 24 Apr 2025 09:38:12 -0400 Subject: [PATCH] Test containerized apt download --- installJRMC | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/installJRMC b/installJRMC index a68ddbf..b811e44 100755 --- a/installJRMC +++ b/installJRMC @@ -636,6 +636,7 @@ install_mc_repo() { repo_file="/etc/apt/sources.list.d/jriver.sources" fi + # Remove old repo old_repo_files=( "/etc/apt/sources.list.d/jriver.list" "/etc/apt/sources.list.d/jriver-beta.list" @@ -748,6 +749,59 @@ acquire_deb() { ((found)) && [[ -f $MC_DEB ]] } +acquire_deb_new() { + debug "Running: ${FUNCNAME[0]}" + declare -g MC_SOURCE + local fname + + [[ -d $OUTPUT_DIR/SOURCES ]] || execute mkdir -p "$OUTPUT_DIR/SOURCES" + + # Usually JRiver excludes the release number from the filename + # but in some cases (test builds) it may be included + if [[ $MC_RELEASE -gt 1 ]]; then + fname="MediaCenter-$MC_VERSION-$MC_RELEASE-$MC_ARCH.deb" + else + fname="MediaCenter-$MC_VERSION-$MC_ARCH.deb" + fi + + declare -g MC_DEB="$OUTPUT_DIR/SOURCES/$fname" + + # If deb file already exists, skip download + if [[ -f $MC_DEB ]]; then + if [[ $(stat -c%s "$MC_DEB") -lt 10000000 ]]; then + echo "Removing existing DEB under 10MB: $MC_DEB" + execute rm "$MC_DEB" + else + echo "Using existing DEB: $MC_DEB" + # Use dummy source since we don't know where it came from + # TODO could attach source tag to filename + MC_SOURCE="https://files.jriver-cdn.com/mediacenter/channels/v$MC_MVERSION/latest/$fname" + return 0 + fi + fi + + # Define the repositories to search + cnt=$(buildah from --quiet alpine:edge) && + buildah run "$cnt" -- sh -c ' + apk add apt &>/dev/null + mkdir -p /download + cat <<-EOF > /etc/apt/sources.list.d/jriver.sources + Types: deb + URIs: https://dist.jriver.com/latest/mediacenter/ + Suites: '"$MC_REPO"' + Components: main + Architectures: amd64 armhf arm64 + EOF + apt update --allow-insecure-repositories &>/dev/null + cd /download + apt download "mediacenter'"$MC_MVERSION"'"' && + buildah copy "$cnt" /download/MediaCenter-"$MC_VERSION"*.deb "$OUTPUT_DIR/SOURCES/" && + buildah rm "$cnt" + + # Return if the download was successful + ((found)) && [[ -f $MC_DEB ]] +} + # @description Creates a SPEC file and builds the RPM from the source DEB using rpmbuild build_rpm() { debug "Running: ${FUNCNAME[0]}" @@ -1720,7 +1774,7 @@ main() { fi if ((BUILD_SWITCH)) && [[ $ID != "arch" ]]; then - acquire_deb || { err "Could not download Media Center DEB package"; return 1; } + acquire_deb_new || { err "Could not download Media Center DEB package"; return 1; } if [[ $BUILD_TARGET =~ centos|fedora|suse || $CREATEREPO_TARGET =~ centos|fedora|suse ]]; then install_package dpkg rpm-build