forked from sig_core/toolkit
70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
###
|
|
# Use RLVER=9 for rocky 9
|
|
|
|
# Source mangle vars
|
|
# shellcheck source=./common disable=SC1091,1090
|
|
source "$(dirname "${BASH_SOURCE[0]}")/common"
|
|
# Source sync / migrate vars for repository information
|
|
# shellcheck source=../sync/common disable=SC1091,1090
|
|
source "$(dirname "${BASH_SOURCE[0]}")/../sync/common"
|
|
|
|
# How many
|
|
ARG1=${1}
|
|
NUM=$(( ${ARG1:-${MIRROR_DISPLAY_COUNT}} + 2))
|
|
|
|
print_result () {
|
|
if [[ "${result}" =~ "invalid repo or arch" ]]; then
|
|
printf "# repo = %s arch = %s\n" "${repo}" "${arch}"
|
|
printf "# FAIL: invalid repo or arch\n\n"
|
|
else
|
|
printf "%s\n# number of mirrors returned: %s\n\n" "$( echo "$result" | head -${NUM})" "$(( $(echo "$result" | wc -l) - 2 ))"
|
|
fi
|
|
}
|
|
|
|
cleanup_repo () {
|
|
# plus is actually 'rockyplus'. Others may as well(?)
|
|
if [[ "${repo}" =~ ^(plus)$ ]]; then
|
|
repo="rocky${repo}"
|
|
|
|
# nfv is actually 'NFV'
|
|
elif [[ "${repo}" =~ ^(nfv)$ ]]; then
|
|
repo="${repo^^}"
|
|
fi
|
|
|
|
# Append the major version from sync/common to support 8 and 9
|
|
repo="${repo}-${MAJOR}"
|
|
return 0
|
|
}
|
|
|
|
# Sort the array
|
|
IFS=$'\n' sorted=($(sort <<<"${ALL_REPOS[*]}"))
|
|
unset IFS
|
|
|
|
for repo in "${sorted[@]}"; do
|
|
|
|
# Business logic must be done, sometimes...
|
|
cleanup_repo "${repo}"
|
|
|
|
# Print a nice header
|
|
printf "================\n%s\n================\n" "${repo}"
|
|
for arch in "${ARCHES[@]}" "source"; do
|
|
# Source is treated as its own architecture
|
|
if [[ "${arch}" == "source" ]]; then
|
|
repo="${repo}-source"
|
|
fi
|
|
|
|
# Get the normal repo/arch combinations
|
|
result=$(curl -s "${MIRRORLIST_BASE}?repo=${repo}&arch=${arch}&time&country=global")
|
|
print_result
|
|
|
|
# x86 and a64 have 'debug' types, as well ("arch" != "source")
|
|
if [[ "${arch}" =~ ^(x86_|aarch)64|(s390x|ppc64le)$ ]]; then
|
|
result=$(curl -s "${MIRRORLIST_BASE}?repo=${repo}-debug&arch=${arch}&time&country=global")
|
|
print_result
|
|
fi
|
|
done
|
|
echo
|
|
done
|