|
|
bb3e91 |
#!/bin/bash
|
|
|
5604c2 |
set -e
|
|
|
bb3e91 |
rm -f /tmp/pyxis*.json
|
|
|
bb3e91 |
TOTAL=`curl -s --negotiate -u: -H 'Content-Type: application/json' -H 'Accept: application/json' -X GET "https://pyxis.engineering.redhat.com/v1/repositories?page_size=1" | jq .total`
|
|
|
bb3e91 |
if [ "$TOTAL" == "null" ]; then
|
|
|
bb3e91 |
echo "Error comunicating with Pyxis API."
|
|
|
bb3e91 |
exit 1
|
|
|
bb3e91 |
fi
|
|
|
eec041 |
PAGES=$(($TOTAL/250))
|
|
|
bb3e91 |
for P in `seq 0 $PAGES`; do
|
|
|
bb3e91 |
curl -s --negotiate -u: -H 'Content-Type: application/json' -H 'Accept: application/json' -X GET "https://pyxis.engineering.redhat.com/v1/repositories?page_size=500&page=$P" > /tmp/pyxis$P.json
|
|
|
bb3e91 |
done
|
|
|
bb3e91 |
cat /tmp/pyxis*.json > /tmp/pyx.json
|
|
|
5604c2 |
rm -f /tmp/pyx_debug
|
|
|
bb3e91 |
rm -f /tmp/rhel-shortnames.conf
|
|
|
5604c2 |
jq '.data[]|.published,.requires_terms,.repository,.registry,.release_categories[0]' < /tmp/pyx.json >/tmp/pyx
|
|
|
5604c2 |
readarray -t lines < /tmp/pyx
|
|
|
5604c2 |
IDX=0
|
|
|
5604c2 |
while [ $IDX -lt ${#lines[@]} ]; do
|
|
|
5604c2 |
PUBLISHED=${lines[$IDX]}
|
|
|
5604c2 |
REQ_TERMS=${lines[$IDX+1]}
|
|
|
5604c2 |
REPOSITORY=`echo ${lines[$IDX+2]} | tr -d '"'`
|
|
|
5604c2 |
REGISTRY=`echo ${lines[$IDX+3]} | tr -d '"'`
|
|
|
5604c2 |
RELEASE=`echo ${lines[$IDX+4]} | tr -d '"'`
|
|
|
5604c2 |
if [ "$PUBLISHED" == "true" ] &&
|
|
|
5604c2 |
[ "$RELEASE" == "Generally Available" ] &&
|
|
|
5604c2 |
[ ! -z "$REPOSITORY" ] &&
|
|
|
5604c2 |
[ "$REPOSITORY" != \"\" ] &&
|
|
|
5604c2 |
[[ $REPOSITORY != *[@:]* ]] &&
|
|
|
5604c2 |
[[ $REPOSITORY != *[* ]] &&
|
|
|
5604c2 |
[[ $REGISTRY == *.* ]] &&
|
|
|
5604c2 |
[ "$REGISTRY" != "non_registry" ]; then
|
|
|
bb3e91 |
if [[ $REGISTRY == *quay.io* ]] ||
|
|
|
bb3e91 |
[[ $REGISTRY == *redhat.com* ]]; then
|
|
|
5604c2 |
if [ "$REQ_TERMS" == "true" ]; then
|
|
|
bb3e91 |
REGISTRY=registry.redhat.io
|
|
|
bb3e91 |
fi
|
|
|
bb3e91 |
fi
|
|
|
5604c2 |
echo "\"$REPOSITORY\" = \"$REGISTRY/$REPOSITORY\""
|
|
|
5604c2 |
echo $PUBLISHED,$REQ_TERMS,$REPOSITORY,$REGISTRY,$RELEASE >> /tmp/pyx_debug
|
|
|
5604c2 |
echo "\"$REPOSITORY\" = \"$REGISTRY/$REPOSITORY\"" >> /tmp/rhel-shortnames.conf
|
|
|
bb3e91 |
fi
|
|
|
5604c2 |
IDX=$(($IDX+5))
|
|
|
5604c2 |
done
|
|
|
bb3e91 |
|
|
|
bb3e91 |
cp /tmp/rhel-shortnames.conf /tmp/r.conf
|
|
|
bb3e91 |
for D in `cut -d\ -f1 /tmp/r.conf | sort | uniq -d`; do
|
|
|
bb3e91 |
echo $D
|
|
|
bb3e91 |
M=`grep ^$D /tmp/r.conf | grep 'redhat.com' | tail -n1`
|
|
|
bb3e91 |
[ -z "$M" ] && M=`grep ^$D /tmp/r.conf | tail -n1`
|
|
|
bb3e91 |
echo $M
|
|
|
bb3e91 |
if [ ! -z "$M" ]; then
|
|
|
bb3e91 |
echo "replacing $D with $M"
|
|
|
bb3e91 |
grep -v "^$D.*" /tmp/r.conf > /tmp/r2.conf
|
|
|
bb3e91 |
echo "$M" >> /tmp/r2.conf
|
|
|
bb3e91 |
mv /tmp/r2.conf /tmp/r.conf
|
|
|
bb3e91 |
fi
|
|
|
bb3e91 |
done
|
|
|
bb3e91 |
|
|
|
947b07 |
sed -i '/.*rhel.*-els\/.*$/d' /tmp/r.conf
|
|
|
bb3e91 |
echo "[aliases]" > 001-rhel-shortnames-pyxis.conf
|
|
|
bb3e91 |
sort /tmp/r.conf >> 001-rhel-shortnames-pyxis.conf
|