Last active
July 29, 2018 09:51
-
-
Save u8sand/c2ed7dfbf6e4e781f532daf5aab141cb to your computer and use it in GitHub Desktop.
Process the archlinux pacman mirrorlist for US
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trigger] | |
Operation=Install | |
Operation=Upgrade | |
Type=Package | |
Target=pacman-mirrorlist | |
[Action] | |
Depends=pacman | |
When=PostTransaction | |
Exec=/usr/bin/rank-mirror-list.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pkgname=('pacman-mirrorlist-hook') | |
pkgver=1 | |
pkgrel=1 | |
pkgdesc='Pacman mirrorlist hook.' | |
arch=('any') | |
depends=('pacman' 'pacman-mirrorlist') | |
source=('pacman-mirrorlist.hook' 'rank-mirror-list.sh') | |
md5sums=('b51e1a45b23b2831709e7732fe88d4c8' | |
'5cceded6741d705fd09b919de9e1234b') | |
package() { | |
install -Dm600 pacman-mirrorlist.hook ${pkgdir}/etc/pacman.d/hooks/pacman-mirrorlist.hook | |
install -Dm755 rank-mirror-list.sh ${pkgdir}/usr/bin/rank-mirror-list.sh | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $(id -u) != 0 ]; then | |
exec sudo -- "$0" "$@" | |
elif [ -e /etc/pacman.d/mirrorlist.pacnew ]; then | |
cat /etc/pacman.d/mirrorlist.pacnew \ | |
| awk -v RS='\n\n' '/^## United States/{print $0}' \ | |
| awk '/^#Server/{print substr($0, 2)}' \ | |
| rankmirrors - > /etc/pacman.d/mirrorlist | |
rm /etc/pacman.d/mirrorlist.pacnew | |
else | |
echo "Already processed pacnew" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment