From 5081f5e12c740f49e4986ec95f52bdd606927275 Mon Sep 17 00:00:00 2001 From: Thomas Oulevey Date: Oct 26 2016 16:16:21 +0000 Subject: Brute forcing supported ARCHES --- diff --git a/scripts/external_repos_updates.sh b/scripts/external_repos_updates.sh index 2b2d99b..a18a0cd 100755 --- a/scripts/external_repos_updates.sh +++ b/scripts/external_repos_updates.sh @@ -2,44 +2,66 @@ REPOMD="repodata/repomd.xml" -KOJI_CACHE="/var/cache/cbs-monitorexternalrepos" +KOJI_CACHE="/tmp/cache/cbs-monitorexternalrepos" UPDATED_REPOS="" UPDATED_BUILDROOTS=`mktemp` +SUPPORTED_ARCHES="x86_64 i386 ppc64le aarch64" -# Ensure the cache directory is available -[ ! -d $KOJI_CACHE ] && mkdir -p $KOJI_CACHE +# 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 + IFS="$OLDIFS" + for ARCH in $SUPPORTED_ARCHES + do + httpcode="" + sha="" + oldsha="" + eval repourl=`echo $REPO | rev| cut -d ' ' -f 1| rev | sed 's#\$arch#$ARCH#g'` + reponame=`echo $REPO | cut -d ' ' -f 1` + if [ "x$reponame" == "x" ] + then + echo "Repository $REPO is malformed." + break + fi + httpcode=$(curl -s --head -w %{http_code} $repourl -o /dev/null) + if [ $? -gt 0 ] + then + echo "[WARN] Couldn't retrieve $repourl . Skipping $reponame regeneration." + continue + else + httpcode=$(( httpcode + 0 )) + if [ $httpcode -gt 400 ] + then + echo "[INFO] Skipping $reponame.$ARCH ; $ARCH not available." + continue + else + 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.$ARCH.sha256sum ] + then + echo "$sha" > $KOJI_CACHE/$reponame.$ARCH.sha256sum + UPDATED_REPOS="$UPDATED_REPOS $reponame" + else + oldsha=`cat $KOJI_CACHE/$reponame.$ARCH.sha256sum` + diff <(echo "$sha") <(echo "$oldsha") &> /dev/null + if [ $? -gt 0 ] + then + echo "in" + UPDATED_REPOS="$UPDATED_REPOS $reponame" + echo "$sha" > $KOJI_CACHE/$reponame.$ARCH.sha256sum + fi + fi + fi + fi + done done IFS="$OLDIFS"