Add a script to update pacman's mirror list.
This commit is contained in:
parent
c90e95f787
commit
1a26a0a2b1
1 changed files with 26 additions and 0 deletions
26
.zshrc
26
.zshrc
|
@ -106,3 +106,29 @@ clean()
|
||||||
|
|
||||||
unfunction clean_dir
|
unfunction clean_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hash rankmirrors 2>/dev/null; then
|
||||||
|
update_mirrorlist()
|
||||||
|
{
|
||||||
|
local pacman_dir="/etc/pacman.d"
|
||||||
|
local mirror_file="$pacman_dir/mirrorlist"
|
||||||
|
local mirror_pacnew="$mirror_file.pacnew"
|
||||||
|
local mirror_orig="$mirror_file.orig"
|
||||||
|
local mirror_tmp="/tmp/mirrorlist.tmp"
|
||||||
|
|
||||||
|
if [ -f "$mirror_pacnew" ]; then
|
||||||
|
echo "Using $mirror_file"
|
||||||
|
mv "$mirror_pacnew" "$mirror_orig"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$mirror_orig" ]; then
|
||||||
|
echo "$mirror_orig: file not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
/usr/bin/grep 'Server' "$mirror_orig" | tr -d "#" > "$mirror_tmp"
|
||||||
|
rankmirrors -n 6 "$mirror_tmp" > "$mirror_file"
|
||||||
|
rm -f "$mirror_tmp"
|
||||||
|
pacman -Syy
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue