docker_rpmbuild-rebuild_msmtp.sh : more variables - can be used to rebuild other packages

This commit is contained in:
Gitouche 2022-02-06 22:00:45 +01:00
parent 5ce09eabba
commit c47b00b961

View file

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