From 69ec605d5aa202d24704655154fbcc287a6f04be Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Sat, 4 Mar 2023 14:03:52 +0100 Subject: [PATCH] script de build rpm - moins de hardcoding --- docker_rebuild_msmtp_rpm.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/docker_rebuild_msmtp_rpm.sh b/docker_rebuild_msmtp_rpm.sh index 25d0c06..febe038 100755 --- a/docker_rebuild_msmtp_rpm.sh +++ b/docker_rebuild_msmtp_rpm.sh @@ -2,8 +2,6 @@ FROMFEDORA='36' PACKAGE='msmtp' -GETTEXT_FC='36' -GETTEXT_VERSION='0.21-9' ABSDIR="$( dirname "$(readlink -f -- "$0")" )" cd ${ABSDIR} @@ -11,13 +9,27 @@ cd ${ABSDIR} type -P docker >/dev/null && DOCKER=$(which docker) type -P podman >/dev/null && DOCKER=$(which podman) -if ! JSONLINE=$(curl -s https://src.fedoraproject.org/_dg/bodhi_updates/rpms/${PACKAGE} | grep -e "fc${FROMFEDORA}\","); then - echo "ERROR : No ${PACKAGE} release available for Fedora ${FROMFEDORA}" - echo "Please check https://src.fedoraproject.org/rpms/${PACKAGE} to choose the right release." +get_src_rpm_url() { + local __package=${1} + local __resultvar=${2} + if ! local __jsonline=$(curl -s https://src.fedoraproject.org/_dg/bodhi_updates/rpms/${1} | grep -e "fc${FROMFEDORA}\","); then + echo "ERROR : No ${1} release available for Fedora ${FROMFEDORA}" + echo "Please check https://src.fedoraproject.org/rpms/${PACKAGE} to choose the right release." + exit 1 + fi + local __version=$(echo "${__jsonline}" | sed -e "s/^\s*\"stable\": \"${1}-\(.*\)\.fc${FROMFEDORA}\",\s*$/\1/") + for repo in releases updates; do + local __url=https://dl.fedoraproject.org/pub/fedora/linux/${repo}/${FROMFEDORA}/Everything/source/tree/Packages/${__package::1}/${__package}-${__version}.fc${FROMFEDORA}.src.rpm + if curl -sSLfI ${__url} 1>/dev/null 2>/dev/null; then + eval $__resultvar="'${__url}'" + return 0 + fi + done exit 1 -fi +} -VERSION=$(echo "${JSONLINE}" | sed -e "s/^\s*\"stable\": \"${PACKAGE}-\(.*\)\.fc${FROMFEDORA}\",\s*$/\1/") +get_src_rpm_url ${PACKAGE} PACKAGE_SRC_RPM_URL +get_src_rpm_url gettext GETTEXT_SRC_RPM_URL ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i) @@ -28,12 +40,9 @@ dnf install -qy epel-release dnf install -qy mock useradd mockbuilder usermod -a -G mock mockbuilder -runuser -l mockbuilder -c 'mock --localrepo=/tmp/ --chain -r rocky+epel-8-x86_64 https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/${GETTEXT_FC}/Everything/source/tree/Packages/g/gettext-${GETTEXT_VERSION}.fc${GETTEXT_FC}.src.rpm https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/${FROMFEDORA}/Everything/source/tree/Packages/m/${PACKAGE}-${VERSION}.fc${FROMFEDORA}.src.rpm' +runuser -l mockbuilder -c 'mock --localrepo=/tmp/ --chain -r rocky+epel-8-${ARCH} ${GETTEXT_SRC_RPM_URL} ${PACKAGE_SRC_RPM_URL}' mv -f /tmp/results/*/${PACKAGE}-*/*.rpm /out/ EOF [[ $? == 0 ]] && mv -i /tmp/dockerrpmbuild-$$/*.rpm ${ABSDIR}/files/ && rm -rf /tmp/dockerrpmbuild-$$ && - -${DOCKER} rmi -f docker-${PACKAGE}-build && -${DOCKER} rmi -f docker-${PACKAGE}-xfer