From fc132433d4da89c6ebbfd67c7798cae33acf8fd8 Mon Sep 17 00:00:00 2001 From: Michael Picht Date: Sat, 7 Dec 2019 08:30:45 +0100 Subject: [PATCH 1/4] added selection of mirrors by country Signed-off-by: Michael Picht --- archfi | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/archfi b/archfi index 26c0cc0..d65cfc3 100644 --- a/archfi +++ b/archfi @@ -725,6 +725,7 @@ installmenu(){ nextitem=${1} fi options=() + options+=("${txtselectmirrorsbycountry}" "(${txtoptional})") options+=("${txteditmirrorlist}" "(${txtoptional})") options+=("${txtinstallarchlinux}" "pacstrap base linux") options+=("${txtconfigarchlinux}" "") @@ -733,6 +734,10 @@ installmenu(){ 3>&1 1>&2 2>&3) if [ "$?" = "0" ]; then case ${sel} in + "${txtselectmirrorsbycountry}") + selectmirrorsbycountry + nextitem="${txtinstallarchlinux}" + ;; "${txteditmirrorlist}") ${EDITOR} /etc/pacman.d/mirrorlist nextitem="${txtinstallarchlinux}" @@ -752,6 +757,23 @@ installmenu(){ fi } +selectmirrorsbycountry() { + cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup + items=$( sed -n "/^##.*/N; {s/^## \(.*\)\nServer.*/\1/p}" < /etc/pacman.d/mirrorlist.backup | sort -u ) + options=() + IFS_ORIG=$IFS + IFS=$'\n' + for item in ${items}; do + options+=("${item}" "") + done + IFS=$IFS_ORIG + country=$(whiptail --backtitle "${APPTITLE}" --title "${txtselectcountry}" --menu "" 0 0 0 "${options[@]}" 3>&1 1>&2 2>&3) + if [ "$?" != "0" ]; then + return 1 + fi + sed "s/^\(Server .*\)/\#\1/;/^## $country/N; {s/^\(## .*\n\)\#Server \(.*\)/\1Server \2/}" < /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist +} + installbase(){ clear echo "pacstrap /mnt base linux" @@ -1719,6 +1741,7 @@ loadstrings(){ txtarchinstallmenu="Arch Install Menu" + txtselectmirrorsbycountry="Select mirrors by country" txteditmirrorlist="Edit mirrorlist" txtinstallarchlinux="Install Arch Linux" txtconfigarchlinux="Config Arch Linux" From 08f81dfcd0bc4bc018af3681e8e0df089c843e86 Mon Sep 17 00:00:00 2001 From: Michael Picht Date: Sat, 7 Dec 2019 08:32:37 +0100 Subject: [PATCH 2/4] corrected selection of mirrors by country Signed-off-by: Michael Picht --- archfi | 1 + 1 file changed, 1 insertion(+) diff --git a/archfi b/archfi index d65cfc3..69e61a0 100644 --- a/archfi +++ b/archfi @@ -1742,6 +1742,7 @@ loadstrings(){ txtarchinstallmenu="Arch Install Menu" txtselectmirrorsbycountry="Select mirrors by country" + txtselectcountry="Select country" txteditmirrorlist="Edit mirrorlist" txtinstallarchlinux="Install Arch Linux" txtconfigarchlinux="Config Arch Linux" From 870666d3558751bb5d56e7b5ef70655c5dee05fd Mon Sep 17 00:00:00 2001 From: Michael Picht Date: Sun, 8 Dec 2019 06:30:24 +0100 Subject: [PATCH 3/4] corrected selection of mirrors by country Signed-off-by: Michael Picht --- archfi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/archfi b/archfi index 69e61a0..c8a894e 100644 --- a/archfi +++ b/archfi @@ -758,7 +758,9 @@ installmenu(){ } selectmirrorsbycountry() { - cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup + if [[ -f /etc/pacman.d/mirrorlist.backup ]]; then + cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup + fi items=$( sed -n "/^##.*/N; {s/^## \(.*\)\nServer.*/\1/p}" < /etc/pacman.d/mirrorlist.backup | sort -u ) options=() IFS_ORIG=$IFS From 47a734cb2facb7949e70b789efe28bf9adbd3c09 Mon Sep 17 00:00:00 2001 From: Michael Picht Date: Sun, 8 Dec 2019 06:41:04 +0100 Subject: [PATCH 4/4] corrected selection of mirrors by country Signed-off-by: Michael Picht --- archfi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/archfi b/archfi index c8a894e..001fa2b 100644 --- a/archfi +++ b/archfi @@ -758,7 +758,7 @@ installmenu(){ } selectmirrorsbycountry() { - if [[ -f /etc/pacman.d/mirrorlist.backup ]]; then + if [[ ! -f /etc/pacman.d/mirrorlist.backup ]]; then cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup fi items=$( sed -n "/^##.*/N; {s/^## \(.*\)\nServer.*/\1/p}" < /etc/pacman.d/mirrorlist.backup | sort -u )