2019-07-13 13:16:01 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
2015-11-03 00:07:17 +01:00
|
|
|
pacman_dir="/etc/pacman.d"
|
2015-11-10 11:10:17 +01:00
|
|
|
mirror_file="${pacman_dir}/mirrorlist"
|
|
|
|
mirror_pacnew="${mirror_file}.pacnew"
|
|
|
|
mirror_orig="${mirror_file}.orig"
|
2015-11-02 23:47:10 +01:00
|
|
|
mirror_tmp="/tmp/mirrorlist.tmp"
|
2018-11-18 12:05:42 +01:00
|
|
|
rank_util="rankmirrors"
|
|
|
|
|
|
|
|
if ! hash "$rank_util" 2>/dev/null; then
|
|
|
|
echo "$rank_util: command not found" >&2
|
|
|
|
echo "You may need to install the 'pacman-contrib' package." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-11-02 23:47:10 +01:00
|
|
|
|
|
|
|
if [ -f "$mirror_pacnew" ]; then
|
2015-11-10 11:10:17 +01:00
|
|
|
echo "Using $mirror_pacnew"
|
2015-11-02 23:47:10 +01:00
|
|
|
mv "$mirror_pacnew" "$mirror_orig"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$mirror_orig" ]; then
|
|
|
|
echo "$mirror_orig: file not found" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-18 12:05:42 +01:00
|
|
|
awk '/^## France$/{f=1}f==0{next}/^$/{exit}{print substr($0, 2)}' "$mirror_orig" >"$mirror_tmp"
|
|
|
|
"$rank_util" -n 6 "$mirror_tmp" >"$mirror_file"
|
2015-11-02 23:47:10 +01:00
|
|
|
rm -f "$mirror_tmp"
|
|
|
|
pacman -Syy
|