From 77544174348f30fe0dd7cf71865f082cd959ee7a Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Fri, 19 Jan 2024 20:33:08 +0100 Subject: [PATCH] support deb-archive.kamailio.org allows to rebuild images (cherry picked from commit 8fb563547274aa7107e73d4600586465369a9dc0) --- create_dockerfile.sh | 93 ++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 64 deletions(-) diff --git a/create_dockerfile.sh b/create_dockerfile.sh index 87796ed..ebfaac9 100755 --- a/create_dockerfile.sh +++ b/create_dockerfile.sh @@ -1,6 +1,27 @@ #!/bin/bash +dist=${1:-bookworm} +version=${2:-5.7.4} +DATE=$(date +"%Y-%m-%d") + +KAM_ARCHIVE_REPO="http://deb-archive.kamailio.org/repos/kamailio-${version}" +KAM_REPO="${KAM_ARCHIVE_REPO}" + +get_kam_version() { + if [[ ${version} =~ 4\.4\.[0-9] ]] ; then + kam_version="44" + elif [[ ${version} =~ 5\.([0-9])\.[0-9] ]] ; then + kam_version="5${BASH_REMATCH[1]}" + else + echo "unknown kamailio version '${version}'" >&2 + fi +} + kam_packages() { - wget -q -O /tmp/Packages "http://deb.kamailio.org/kamailio${kam_version}/dists/${dist}/main/binary-amd64/Packages" + if ! wget -q -O /tmp/Packages "${KAM_ARCHIVE_REPO}/dists/${dist}/main/binary-amd64/Packages" ; then + get_kam_version + KAM_REPO="http://deb.kamailio.org/kamailio${kam_version}" + wget -q -O /tmp/Packages "${KAM_REPO}/dists/${dist}/main/binary-amd64/Packages" + fi repo_version=$(awk '/Version:/ { print $2 }' /tmp/Packages| head -1) awk -vver="${repo_version}" '/Package:/ { print $2"="ver}' /tmp/Packages | xargs } @@ -9,7 +30,7 @@ create_dockerfile() { cat >"${DOCKERFILE}" < # Important! Update this no-op ENV variable when this Dockerfile # is updated with the current date. It will force refresh of all @@ -17,17 +38,10 @@ LABEL maintainer="Victor Seva " # old cached versions when the Dockerfile is built. ENV REFRESHED_AT ${DATE} -EOF - -if ! wget -O /dev/null -q "http://deb.kamailio.org/kamailio${kam_version}/dists/${dist}" ; then - echo "*** ERROR kamailio${kam_version} for ${dist} repository not found ***" -fi - -cat >>"${DOCKERFILE}" < \ +RUN echo "deb ${KAM_REPO} ${dist} main" > \ /etc/apt/sources.list.d/kamailio.list EOF @@ -42,25 +56,18 @@ fi cat >>"${DOCKERFILE}" <