|
|
a415a1 |
#!/bin/bash
|
|
|
5f1c70 |
set -e
|
|
|
a415a1 |
rm -f /tmp/pyxis*.json
|
|
|
a415a1 |
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`
|
|
|
a415a1 |
if [ "$TOTAL" == "null" ]; then
|
|
|
a415a1 |
echo "Error comunicating with Pyxis API."
|
|
|
a415a1 |
exit 1
|
|
|
a415a1 |
fi
|
|
|
5f1c70 |
PAGES=$(($TOTAL/250))
|
|
|
a415a1 |
for P in `seq 0 $PAGES`; do
|
|
|
a415a1 |
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
|
|
|
a415a1 |
done
|
|
|
a415a1 |
cat /tmp/pyxis*.json > /tmp/pyx.json
|
|
|
5f1c70 |
rm -f /tmp/pyx_debug
|
|
|
a415a1 |
rm -f /tmp/rhel-shortnames.conf
|
|
|
5f1c70 |
jq '.data[]|.published,.requires_terms,.repository,.registry,.release_categories[0]' < /tmp/pyx.json >/tmp/pyx
|
|
|
5f1c70 |
readarray -t lines < /tmp/pyx
|
|
|
5f1c70 |
IDX=0
|
|
|
5f1c70 |
while [ $IDX -lt ${#lines[@]} ]; do
|
|
|
5f1c70 |
PUBLISHED=${lines[$IDX]}
|
|
|
5f1c70 |
REQ_TERMS=${lines[$IDX+1]}
|
|
|
5f1c70 |
REPOSITORY=`echo ${lines[$IDX+2]} | tr -d '"'`
|
|
|
5f1c70 |
REGISTRY=`echo ${lines[$IDX+3]} | tr -d '"'`
|
|
|
5f1c70 |
RELEASE=`echo ${lines[$IDX+4]} | tr -d '"'`
|
|
|
5f1c70 |
if [ "$PUBLISHED" == "true" ] &&
|
|
|
5f1c70 |
[ "$RELEASE" == "Generally Available" ] &&
|
|
|
5f1c70 |
[ $REPOSITORY != \"\" ] &&
|
|
|
5f1c70 |
[[ $REPOSITORY != *[@:]* ]] &&
|
|
|
5f1c70 |
[[ $REPOSITORY != *[* ]] &&
|
|
|
5f1c70 |
[[ $REGISTRY == *.* ]] &&
|
|
|
5f1c70 |
[ "$REGISTRY" != "non_registry" ]; then
|
|
|
a415a1 |
if [[ $REGISTRY == *quay.io* ]] ||
|
|
|
a415a1 |
[[ $REGISTRY == *redhat.com* ]]; then
|
|
|
5f1c70 |
if [ "$REQ_TERMS" == "true" ]; then
|
|
|
a415a1 |
REGISTRY=registry.redhat.io
|
|
|
a415a1 |
fi
|
|
|
a415a1 |
fi
|
|
|
5f1c70 |
echo "\"$REPOSITORY\" = \"$REGISTRY/$REPOSITORY\""
|
|
|
5f1c70 |
echo $PUBLISHED,$REQ_TERMS,$REPOSITORY,$REGISTRY,$RELEASE >> /tmp/pyx_debug
|
|
|
5f1c70 |
echo "\"$REPOSITORY\" = \"$REGISTRY/$REPOSITORY\"" >> /tmp/rhel-shortnames.conf
|
|
|
a415a1 |
fi
|
|
|
5f1c70 |
IDX=$(($IDX+5))
|
|
|
5f1c70 |
done
|
|
|
a415a1 |
|
|
|
a415a1 |
cp /tmp/rhel-shortnames.conf /tmp/r.conf
|
|
|
a415a1 |
for D in `cut -d\ -f1 /tmp/r.conf | sort | uniq -d`; do
|
|
|
a415a1 |
echo $D
|
|
|
a415a1 |
M=`grep ^$D /tmp/r.conf | grep 'redhat.com' | tail -n1`
|
|
|
a415a1 |
[ -z "$M" ] && M=`grep ^$D /tmp/r.conf | tail -n1`
|
|
|
a415a1 |
echo $M
|
|
|
a415a1 |
if [ ! -z "$M" ]; then
|
|
|
a415a1 |
echo "replacing $D with $M"
|
|
|
a415a1 |
grep -v "^$D.*" /tmp/r.conf > /tmp/r2.conf
|
|
|
a415a1 |
echo "$M" >> /tmp/r2.conf
|
|
|
a415a1 |
mv /tmp/r2.conf /tmp/r.conf
|
|
|
a415a1 |
fi
|
|
|
a415a1 |
done
|
|
|
a415a1 |
|
|
|
893b01 |
sed -i '/.*rhel.*-els\/.*$/d' /tmp/r.conf
|
|
|
a415a1 |
echo "[aliases]" > 001-rhel-shortnames-pyxis.conf
|
|
|
a415a1 |
sort /tmp/r.conf >> 001-rhel-shortnames-pyxis.conf
|