fix loop on pacsetup

This commit is contained in:
Tobias Powalowski 2023-11-15 16:52:55 +01:00
parent 2381b42cda
commit 7abe5c0817

View file

@ -31,25 +31,22 @@ _select_mirror() {
# This regex doesn't honor commenting # This regex doesn't honor commenting
_MIRRORS=$(grep -E -o '(https)://[^/]*' "${_PACMAN_MIRROR}" | sed 's|$| _|g') _MIRRORS=$(grep -E -o '(https)://[^/]*' "${_PACMAN_MIRROR}" | sed 's|$| _|g')
[[ -z ${_MIRRORS} ]] && _MIRRORS=$(grep -E -o '(http)://[^/]*' "${_PACMAN_MIRROR}" | sed 's|$| _|g') [[ -z ${_MIRRORS} ]] && _MIRRORS=$(grep -E -o '(http)://[^/]*' "${_PACMAN_MIRROR}" | sed 's|$| _|g')
_SYNC_URL="" #shellcheck disable=SC2086
while [[ -z "${_SYNC_URL}" ]]; do _dialog --cancel-label "${_LABEL}" --title " Package Mirror " --menu "" 13 55 7 \
#shellcheck disable=SC2086 "Custom Mirror" "_" ${_MIRRORS} 2>${_ANSWER} || return 1
_dialog --cancel-label "${_LABEL}" --title " Package Mirror " --menu "" 13 55 7 \ #shellcheck disable=SC2155
"Custom Mirror" "_" ${_MIRRORS} 2>${_ANSWER} || _abort local _SERVER=$(cat "${_ANSWER}")
#shellcheck disable=SC2155 if [[ "${_SERVER}" == "Custom Mirror" ]]; then
local _SERVER=$(cat "${_ANSWER}") _dialog --inputbox "Enter the full URL to repositories." 8 65 \
if [[ "${_SERVER}" == "Custom Mirror" ]]; then "" 2>"${_ANSWER}" || _SYNC_URL=""
_dialog --inputbox "Enter the full URL to repositories." 8 65 \ _SYNC_URL=$(cat "${_ANSWER}")
"" 2>"${_ANSWER}" || _SYNC_URL="" else
_SYNC_URL=$(cat "${_ANSWER}") # Form the full URL for our mirror by grepping for the server name in
else # our mirrorlist and pulling the full URL out. Substitute 'core' in
# Form the full URL for our mirror by grepping for the server name in # for the repository name, and ensure that if it was listed twice we
# our mirrorlist and pulling the full URL out. Substitute 'core' in # only return one line for the mirror.
# for the repository name, and ensure that if it was listed twice we _SYNC_URL=$(grep -E -o "${_SERVER}.*" "${_PACMAN_MIRROR}" | head -n1)
# only return one line for the mirror. fi
_SYNC_URL=$(grep -E -o "${_SERVER}.*" "${_PACMAN_MIRROR}" | head -n1)
fi
done
echo "Using mirror: ${_SYNC_URL}" >"${_LOG}" echo "Using mirror: ${_SYNC_URL}" >"${_LOG}"
# comment already existing entries # comment already existing entries
sed -i -e 's|^Server|#Server|g' /etc/pacman.d/mirrorlist sed -i -e 's|^Server|#Server|g' /etc/pacman.d/mirrorlist
@ -164,7 +161,10 @@ EOF
if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then if [[ "${_RUNNING_ARCH}" == "x86_64" ]]; then
_enable_testing _enable_testing
fi fi
_select_mirror _SYNC_URL=""
while [[ -z "${_SYNC_URL}" ]]; do
_select_mirror || _abort
done
fi fi
if _prepare_pacman | _dialog --title " Pacman Configuration " --no-mouse --gauge "Update Arch Linux keyring..." 6 70 0; then if _prepare_pacman | _dialog --title " Pacman Configuration " --no-mouse --gauge "Update Arch Linux keyring..." 6 70 0; then
break break