|
Thomas Oulevey |
1c7045 |
#!/bin/bash
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
1c7045 |
REPOMD="repodata/repomd.xml"
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
defde5 |
KOJI_CACHE="/var/cache/cbs-monitorexternalrepos"
|
|
Thomas Oulevey |
1c7045 |
UPDATED_REPOS=""
|
|
Thomas Oulevey |
1c7045 |
UPDATED_BUILDROOTS=`mktemp`
|
|
Thomas Oulevey |
5081f5 |
SUPPORTED_ARCHES="x86_64 i386 ppc64le aarch64"
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
5081f5 |
# Ensure the cache directory is available
|
|
Thomas Oulevey |
5081f5 |
[ ! -d $KOJI_CACHE ] && mkdir -p $KOJI_CACHE
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
1c7045 |
OLDIFS="$IFS"
|
|
Thomas Oulevey |
1c7045 |
IFS=$'\n'
|
|
Thomas Oulevey |
1c7045 |
for REPO in `koji list-external-repos --quiet`
|
|
Thomas Oulevey |
1c7045 |
do
|
|
Thomas Oulevey |
5081f5 |
IFS="$OLDIFS"
|
|
Thomas Oulevey |
5081f5 |
for ARCH in $SUPPORTED_ARCHES
|
|
Thomas Oulevey |
5081f5 |
do
|
|
Thomas Oulevey |
5081f5 |
httpcode=""
|
|
Thomas Oulevey |
5081f5 |
sha=""
|
|
Thomas Oulevey |
5081f5 |
oldsha=""
|
|
Thomas Oulevey |
5081f5 |
eval repourl=`echo $REPO | rev| cut -d ' ' -f 1| rev | sed 's#\$arch#$ARCH#g'`
|
|
Thomas Oulevey |
5081f5 |
reponame=`echo $REPO | cut -d ' ' -f 1`
|
|
Thomas Oulevey |
5081f5 |
if [ "x$reponame" == "x" ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "Repository $REPO is malformed."
|
|
Thomas Oulevey |
5081f5 |
break
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
httpcode=$(curl -s --head -w %{http_code} $repourl -o /dev/null)
|
|
Thomas Oulevey |
5081f5 |
if [ $? -gt 0 ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "[WARN] Couldn't retrieve $repourl . Skipping $reponame regeneration."
|
|
Thomas Oulevey |
5081f5 |
continue
|
|
Thomas Oulevey |
5081f5 |
else
|
|
Thomas Oulevey |
5081f5 |
httpcode=$(( httpcode + 0 ))
|
|
Thomas Oulevey |
5081f5 |
if [ $httpcode -gt 400 ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "[INFO] Skipping $reponame.$ARCH ; $ARCH not available."
|
|
Thomas Oulevey |
5081f5 |
continue
|
|
Thomas Oulevey |
5081f5 |
else
|
|
Thomas Oulevey |
5081f5 |
sha=`curl --silent $repourl/$REPOMD | sha256sum`
|
|
Thomas Oulevey |
5081f5 |
if [ $? -gt 0 ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "Couldn't retrieve $repourl/$REPOMD. Skipping $reponame regeneration."
|
|
Thomas Oulevey |
5081f5 |
continue
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
if [ ! -f $KOJI_CACHE/$reponame.$ARCH.sha256sum ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "$sha" > $KOJI_CACHE/$reponame.$ARCH.sha256sum
|
|
Thomas Oulevey |
5081f5 |
UPDATED_REPOS="$UPDATED_REPOS $reponame"
|
|
Thomas Oulevey |
5081f5 |
else
|
|
Thomas Oulevey |
5081f5 |
oldsha=`cat $KOJI_CACHE/$reponame.$ARCH.sha256sum`
|
|
Thomas Oulevey |
5081f5 |
diff <(echo "$sha") <(echo "$oldsha") &> /dev/null
|
|
Thomas Oulevey |
5081f5 |
if [ $? -gt 0 ]
|
|
Thomas Oulevey |
5081f5 |
then
|
|
Thomas Oulevey |
5081f5 |
echo "in"
|
|
Thomas Oulevey |
5081f5 |
UPDATED_REPOS="$UPDATED_REPOS $reponame"
|
|
Thomas Oulevey |
5081f5 |
echo "$sha" > $KOJI_CACHE/$reponame.$ARCH.sha256sum
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
fi
|
|
Thomas Oulevey |
5081f5 |
done
|
|
Thomas Oulevey |
1c7045 |
done
|
|
Thomas Oulevey |
1c7045 |
IFS="$OLDIFS"
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
1c7045 |
for REPO in $UPDATED_REPOS
|
|
Thomas Oulevey |
1c7045 |
do
|
|
Thomas Oulevey |
1c7045 |
buildroots=`koji list-external-repos --name=$REPO --quiet --used | cut -d ' ' -f 1`
|
|
Thomas Oulevey |
1c7045 |
printf "$buildroots\n" >> $UPDATED_BUILDROOTS
|
|
Thomas Oulevey |
1c7045 |
done
|
|
Thomas Oulevey |
1c7045 |
|
|
Thomas Oulevey |
1c7045 |
for BR in `cat $UPDATED_BUILDROOTS | sort | uniq`
|
|
Thomas Oulevey |
1c7045 |
do
|
|
Thomas Oulevey |
1c7045 |
echo koji regen-repo --nowait $BR
|
|
Thomas Oulevey |
1c7045 |
done
|
|
Thomas Oulevey |
1c7045 |
|