From ce5784b1ac602da683e659ba3ec773165d4678c8 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 23 Oct 2008 01:04:07 -0500 Subject: [PATCH] Fix pacman mirror selection at different stages Account for a mirror being listed twice in the mirrorlist. In addition, ensure we translate from server name to full URL correctly when configuring the primary pacman mirror. Signed-off-by: Dan McGee --- setup | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/setup b/setup index c625e26..5c111d5 100755 --- a/setup +++ b/setup @@ -642,7 +642,11 @@ select_mirror() { "ftp://ftp.archlinux.org/core/os/i686" 2>$ANSWER || return 1 SYNC_URL=$(cat $ANSWER) else - SYNC_URL=$(egrep -o "${_server}.*" "${MIRRORLIST}" | sed 's/\$repo/core/g') + # Form the full URL for our mirror by grepping for the server name in + # our mirrorlist and pulling the full URL out. Substitute 'core' in + # for the repository name, and ensure that if it was listed twice we + # only return one line for the mirror. + SYNC_URL=$(egrep -o "${_server}.*" "${MIRRORLIST}" | sed 's/\$repo/core/g' | head -n1) fi } @@ -1275,15 +1279,21 @@ configure_system() if ! [ "$SAMEMIRROR" = "yes" ]; then DIALOG --msgbox "WARNING:\n\n- Please keep in mind ftp.archlinux.org is throttled!\n- Please select another mirror to get full download speed." 18 70 # this will find all mirrors in the mirrorlist, commented out or not - PAC_MIRRORS=$(egrep -o '((ftp)|(http))://[^/]*' "${DESTDIR}/etc/pacman.d/mirrorlist" | sed 's|$| _|g') + PAC_MIRRORS=$(egrep -o '((ftp)|(http))://[^/]*' "$mirrorlist" | sed 's|$| _|g') DIALOG --menu "Select the primary Pacman mirror" 14 55 7 $PAC_MIRRORS "Custom" "_" 2>$ANSWER || return 1 PAC_SYNC_SERVER="$(cat $ANSWER)" if [ "$PAC_SYNC_SERVER" = "Custom" ]; then DIALOG --inputbox "Enter the full URL to packages, for example:\nhttp://server.org/archlinux/\$repo/os/i686" 8 65 "http://" 2>$ANSWER || return 1 PAC_SYNC_SERVER="$(cat $ANSWER)" + else + # Form the full URL for our mirror by grepping for the + # server name in our mirrorlist and pulling the full URL + # out. Ensure that if it was listed twice we only return + # one line for the mirror. + PAC_SYNC_SERVER=$(egrep -o "${PAC_SYNC_SERVER}.*" "$mirrorlist" | head -n1) fi else - PAC_SYNC_SERVER="${SYNC_URL}" + PAC_SYNC_SERVER=$(echo ${SYNC_URL} | sed 's/core/\$repo/g') fi # comment out all existing mirrors sed -i -e 's/^Server/#Server/g' "$mirrorlist" -- 1.6.0.3