ansible-msmtp-mailer/docker_rpmbuild-rebuild_msmtp.sh

53 lines
1.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
FROMFEDORA='34'
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
cd ${ABSDIR}
type -P docker >/dev/null && DOCKER=$(which docker)
type -P podman >/dev/null && DOCKER=$(which podman)
if ! type -P jq >/dev/null ; then
echo "Error : please install jq"
exit 1
fi
TMPFILE=/tmp/fedoraproject_msmtp_$$
curl -s https://src.fedoraproject.org/_dg/bodhi_updates/rpms/msmtp -o ${TMPFILE}
if ! jq -e .releases.F${FROMFEDORA} ${TMPFILE} >&/dev/null; then
echo "ERROR : No msmtp release available for Fedora ${FROMFEDORA}"
echo "Please check https://src.fedoraproject.org/rpms/msmtp to choose the right release."
exit 2
fi
if MSMTP=$(jq -re .updates.F${FROMFEDORA}.stable ${TMPFILE}); then
echo "Found ${MSMTP} for Fedora ${FROMFEDORA}"
else
echo "ERROR : No stable msmtp release available for Fedora ${FROMFEDORA}."
echo "Please check https://src.fedoraproject.org/rpms/msmtp to choose the right release."
exit 3
fi
rm ${TMPFILE}
MSMTP_VERSION=$(echo "${MSMTP}" | sed -e "s/msmtp-\(.*\)\.fc${FROMFEDORA}$/\1/")
ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i)
${DOCKER} build -t docker-msmtp-build -f- . <<EOF
FROM docker.io/library/rockylinux:8
RUN dnf install -y epel-release dnf-plugins-core && \
dnf config-manager --set-enabled powertools && \
dnf install -y rpm-build gcc make gettext gnutls-devel libgsasl-devel libidn-devel libsecret-devel && \
useradd -m dontbuildasroot -s /bin/bash
USER dontbuildasroot
RUN curl https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/${FROMFEDORA}/Everything/SRPMS/Packages/m/msmtp-${MSMTP_VERSION}.fc${FROMFEDORA}.src.rpm -o /tmp/msmtp.src.rpm && \
rpmbuild --rebuild /tmp/msmtp.src.rpm
EOF
${DOCKER} create -ti --name docker-msmtp-xfer docker-msmtp-build bash
${DOCKER} cp docker-msmtp-xfer:/home/dontbuildasroot/rpmbuild/RPMS/${ARCH}/msmtp-${MSMTP_VERSION}.el8.${ARCH}.rpm ./files/
${DOCKER} rm -fv docker-msmtp-xfer
${DOCKER} rmi -f docker-msmtp-build