From 1c7045d0e95807c53d37cb679642d00084ec951b Mon Sep 17 00:00:00 2001 From: Thomas Oulevey Date: Oct 13 2016 15:09:43 +0000 Subject: - external_repos_updates.sh: Regenerate buildroot tag if external repo changes - First version --- diff --git a/scripts/external_repos_updates.sh b/scripts/external_repos_updates.sh new file mode 100755 index 0000000..2b2d99b --- /dev/null +++ b/scripts/external_repos_updates.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +REPOMD="repodata/repomd.xml" + +KOJI_CACHE="/var/cache/cbs-monitorexternalrepos" +UPDATED_REPOS="" +UPDATED_BUILDROOTS=`mktemp` + +# Ensure the cache directory is available +[ ! -d $KOJI_CACHE ] && mkdir -p $KOJI_CACHE + +OLDIFS="$IFS" +IFS=$'\n' +for REPO in `koji list-external-repos --quiet` +do + sha="" + oldsha="" + repourl=`echo $REPO | rev| cut -d ' ' -f 1| rev | sed 's/\$arch/x86_64/g'` + reponame=`echo $REPO | cut -d ' ' -f 1` + if [ "x$reponame" == "x" ] + then + echo "Repository $REPO is malformed." + break + fi + sha=`curl --silent $repourl/$REPOMD | sha256sum` + if [ $? -gt 0 ] + then + echo "Couldn't retrieve $repourl/$REPOMD. Skipping $reponame regeneration." + continue + fi + if [ ! -f $KOJI_CACHE/$reponame.sha256sum ] + then + echo "$sha" > $KOJI_CACHE/$reponame.sha256sum + else + oldsha=`cat $KOJI_CACHE/$reponame.sha256sum` + diff <(echo "$sha") <(echo "$oldsha") &> /dev/null + if [ $? -gt 0 ] + then + UPDATED_REPOS="$UPDATED_REPOS $reponame" + echo "$sha" > $KOJI_CACHE/$reponame.sha256sum + fi + fi +done +IFS="$OLDIFS" + +for REPO in $UPDATED_REPOS +do + buildroots=`koji list-external-repos --name=$REPO --quiet --used | cut -d ' ' -f 1` + printf "$buildroots\n" >> $UPDATED_BUILDROOTS +done + +for BR in `cat $UPDATED_BUILDROOTS | sort | uniq` +do + echo koji regen-repo --nowait $BR +done +