Test containerized apt download

This commit is contained in:
2025-04-24 09:38:12 -04:00
parent 1d59a923f6
commit 5770c407a0

View File

@@ -636,6 +636,7 @@ install_mc_repo() {
repo_file="/etc/apt/sources.list.d/jriver.sources" repo_file="/etc/apt/sources.list.d/jriver.sources"
fi fi
# Remove old repo
old_repo_files=( old_repo_files=(
"/etc/apt/sources.list.d/jriver.list" "/etc/apt/sources.list.d/jriver.list"
"/etc/apt/sources.list.d/jriver-beta.list" "/etc/apt/sources.list.d/jriver-beta.list"
@@ -748,6 +749,59 @@ acquire_deb() {
((found)) && [[ -f $MC_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 # @description Creates a SPEC file and builds the RPM from the source DEB using rpmbuild
build_rpm() { build_rpm() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
@@ -1720,7 +1774,7 @@ main() {
fi fi
if ((BUILD_SWITCH)) && [[ $ID != "arch" ]]; then 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 if [[ $BUILD_TARGET =~ centos|fedora|suse || $CREATEREPO_TARGET =~ centos|fedora|suse ]]; then
install_package dpkg rpm-build install_package dpkg rpm-build