Fix some issues with baseurl checks and overrides.

This commit is contained in:
Peter Ajamian 2022-02-26 19:44:31 +13:00
parent f3fe6d768a
commit d5a6e46df3

View File

@ -44,6 +44,8 @@ if (( BASH_VERSINFO[0]*100 + BASH_VERSINFO[1] < 402 )); then
exit 1 exit 1
fi fi
shopt -s extglob
# Make sure we're root. # Make sure we're root.
if (( EUID != 0 )); then if (( EUID != 0 )); then
printf '%s\n' \ printf '%s\n' \
@ -436,6 +438,7 @@ _repoinfo () {
# We now store the repoinfo results in a cache. # We now store the repoinfo results in a cache.
declare -g -A repoinfo_results_cache=() declare -g -A repoinfo_results_cache=()
repoinfo () { repoinfo () {
local k
if [[ ! ${repoinfo_results_cache[$1]} ]]; then if [[ ! ${repoinfo_results_cache[$1]} ]]; then
_repoinfo "$@" || return _repoinfo "$@" || return
repoinfo_results_cache[$1]=1 repoinfo_results_cache[$1]=1
@ -512,9 +515,13 @@ check_repourl () {
return 1 return 1
fi fi
curl -sfLI "${repoinfo_results[Repo-baseurl]%% *}repodata/repomd.xml" \ local -a urls;
> /dev/null IFS=, read -r -a urls <<<"${repoinfo_results[Repo-baseurl]}"
return local u
for u in "${urls[@]##*( )}"; do
curl -sfLI "${u%% *}repodata/repomd.xml" > /dev/null && return
done
return "$(( $? ? $? : 1 ))"
} }
collect_system_info () { collect_system_info () {
@ -639,6 +646,7 @@ collect_system_info () {
# ...and finally set a number of dnf options to replace the baseurl of these # ...and finally set a number of dnf options to replace the baseurl of these
# repos # repos
local k
for k in "${!dist_repourl_map[@]}"; do for k in "${!dist_repourl_map[@]}"; do
local d=${k%%:*} r=${k#*:} local d=${k%%:*} r=${k#*:}
if [[ $d != "$dist_id" || ! ${enabled_repo_check[$r]} ]] || if [[ $d != "$dist_id" || ! ${enabled_repo_check[$r]} ]] ||