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