Merge pull request #86 from mipimipi/src

Select mirrors by country
This commit is contained in:
MatMoul 2019-12-14 23:56:18 +01:00 committed by GitHub
commit 3c0bffdcd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

26
archfi
View file

@ -725,6 +725,7 @@ installmenu(){
nextitem=${1} nextitem=${1}
fi fi
options=() options=()
options+=("${txtselectmirrorsbycountry}" "(${txtoptional})")
options+=("${txteditmirrorlist}" "(${txtoptional})") options+=("${txteditmirrorlist}" "(${txtoptional})")
options+=("${txtinstallarchlinux}" "pacstrap base kernel") options+=("${txtinstallarchlinux}" "pacstrap base kernel")
options+=("${txtinstallfirmware}" "(${txtoptional}) pacstrap linux-firmware") options+=("${txtinstallfirmware}" "(${txtoptional}) pacstrap linux-firmware")
@ -734,6 +735,10 @@ installmenu(){
3>&1 1>&2 2>&3) 3>&1 1>&2 2>&3)
if [ "$?" = "0" ]; then if [ "$?" = "0" ]; then
case ${sel} in case ${sel} in
"${txtselectmirrorsbycountry}")
selectmirrorsbycountry
nextitem="${txtinstallarchlinux}"
;;
"${txteditmirrorlist}") "${txteditmirrorlist}")
${EDITOR} /etc/pacman.d/mirrorlist ${EDITOR} /etc/pacman.d/mirrorlist
nextitem="${txtinstallarchlinux}" nextitem="${txtinstallarchlinux}"
@ -758,6 +763,25 @@ installmenu(){
fi fi
} }
selectmirrorsbycountry() {
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
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(){ installbase(){
clear clear
pkgs="base" pkgs="base"
@ -1746,6 +1770,8 @@ loadstrings(){
txtarchinstallmenu="Arch Install Menu" txtarchinstallmenu="Arch Install Menu"
txtselectmirrorsbycountry="Select mirrors by country"
txtselectcountry="Select country"
txteditmirrorlist="Edit mirrorlist" txteditmirrorlist="Edit mirrorlist"
txtinstallarchlinux="Install Arch Linux" txtinstallarchlinux="Install Arch Linux"
txtinstallfirmware="Install Firmware" txtinstallfirmware="Install Firmware"