-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eos-rankmirrors] added options --list-only and --mirror-add
- Loading branch information
1 parent
785ea23
commit 4b69d04
Showing
3 changed files
with
65 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Maintainer: EndeavourOS <[email protected]> | ||
|
||
pkgname=eos-rankmirrors | ||
pkgver=2.23 | ||
pkgver=2.24 | ||
pkgrel=1 | ||
pkgdesc="EndeavourOS mirror ranking tool" | ||
arch=('any') | ||
|
@@ -22,8 +22,8 @@ source=( | |
$url/eos-rankmirrors.conf | ||
$url/eos-rankmirrors.disabled | ||
) | ||
sha512sums=('2f75eb0367350ae9392907964ee8b2795c38b36e0815e882fb22cd471c1642294b633ce779e15a44d2215004ea4a5c4d691333a7f6c610cc6a9c800154b789cd' | ||
'476c232dcabdd55f9fd0200e3a428aeb99a867f3b5c475711bd4e0e553c3a4149daa90436f0aaf397c1865888f8746b82deb1d70dff4cfde2b55776359f95c3a' | ||
sha512sums=('bdf831bc647980beb10b5363661554e22936ace76c5df53d3b8371ace1f5d6fc89e117ab8eadd2cce7849a5d3592cb84f628afd8895373e264a296dbdcaebc77' | ||
'07c4be1c228840104d3a8b3324a3a248ec82ad0204cb93b7d86ebb2768cd71a047e7e0204da10b1102bc13dfe26b7050a4257ed7e51dfac6bb499b46f5f406f7' | ||
'580511c676cf56b5b8580d6819e0d1a4c85a40a3cd10f4b4f04fb9c004b14025b56cf4c3048e0fe8f9eef48d924b32b97d1e9669fac39b96f4203e2d68e3bd07' | ||
'f01f6267f624992febfec29c76f2de1c503693086ade5783e2b9cbef359f5155bf6df520ff06299193c842aef2a05cac5078977ee0dabf55cff66f44aec6e44a' | ||
'226111836a42e3540c714105813f64b285b3c48d41ea058e7339ba5b2de530a691d753b8f6d10984d260ed3288b01539715b00ad9bef4d808d21303c936837e7' | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,64 @@ | ||
# bash completion for eos-rankmirrors -*- shell-script -*- | ||
|
||
FilterMirrorUrls() { grep -E "^[ \t]*Server[ \t]+=[ \t]+" | awk '{print $3}' | sed -E "s|^(.*)$|'\1'|" ; } | ||
_eos-rankmirrors_FilterMirrorUrls() { | ||
grep -E "^[ \t]*Server[ \t]+=[ \t]+" | awk '{print $3}' | sed -E "s|^(.*)$|'\1'|" | ||
} | ||
|
||
GetMirrors() { | ||
_eos-rankmirrors_GetMirrors() { | ||
# Grab endeavouros-mirrorlist from the latest package. | ||
# First try the package cache. If no luck, fetch it from github/gitlab. | ||
|
||
local tmp_mirrorlist=/tmp/tmp.ml172549udf8 # save the list here for performance | ||
|
||
if [ -r $tmp_mirrorlist ] ; then | ||
cat $tmp_mirrorlist | ||
return 0 | ||
fi | ||
|
||
local -r pkgname=endeavouros-mirrorlist | ||
local -r pkg=$(ls -1 /var/cache/pacman/pkg/${pkgname}-*.zst 2>/dev/null | tail -n1) | ||
|
||
if [ -n "$pkg" ] ; then | ||
# The package exists in the cache. | ||
# Check if the installed version is the same as in the cache. | ||
# | ||
# local cachev=$(echo "$pkg" | sed 's|.*list-\(.*\)-any.*|\1|') | ||
# local installedv=$(expac -Q %v $pkgname) | ||
# if [ $(vercmp "$installedv" "$cachev") -ge 0 ] ; then | ||
tar --extract -O -f "$pkg" etc/pacman.d/endeavouros-mirrorlist | FilterMirrorUrls | ||
return 0 | ||
# fi | ||
tar --extract -O -f "$pkg" etc/pacman.d/endeavouros-mirrorlist | _eos-rankmirrors_FilterMirrorUrls > $tmp_mirrorlist | ||
_eos-rankmirrors_GetMirrors | ||
return 0 | ||
fi | ||
|
||
# Package not in cache # or installed package version is not the same as in cache. | ||
# Package not in cache, or installed package version is not the same as in cache. | ||
# Fetch it. | ||
local -r url="$(eos-github2gitlab --keep-master "https://raw.githubusercontent.com/endeavouros-team/PKGBUILDS/master/$pkgname/$pkgname")" | ||
local -r timeout=5 # not too long... | ||
curl --fail -Lsm $timeout -o- "$url" | FilterMirrorUrls | ||
curl --fail -Lsm $timeout -o- "$url" | _eos-rankmirrors_FilterMirrorUrls > $tmp_mirrorlist | ||
_eos-rankmirrors_GetMirrors | ||
} | ||
|
||
_eos-rankmirrors_() { | ||
local cur prev #words cword split | ||
_init_completion -s || return | ||
|
||
local -r opts="$(eos-rankmirrors --dump-options)" # alternative, slower | ||
local -r opts="$(eos-rankmirrors --dump-options=all)" | ||
local -r verbosities=( all code show none ) | ||
|
||
# Handle options that need sub-options. | ||
# Each option "case" should return immediately. | ||
|
||
case "$prev" in | ||
--sort) | ||
COMPREPLY=($(compgen -W "age rate" -- "$cur")) | ||
;; | ||
--timeout | -t) | ||
COMPREPLY=($(compgen -P "$cur" -W "{1..60}")) | ||
compopt -o nospace | ||
compopt -o nosort | ||
;; | ||
--ignore | --prefer) | ||
COMPREPLY=($(compgen -P "'" -S "'" -W "$(GetMirrors)" -- "$cur")) | ||
;; | ||
--mirror-verbosity) | ||
COMPREPLY=($(compgen -W "${verbosities[*]}" -- "$cur")) | ||
;; | ||
--sort) COMPREPLY=($(compgen -W "age rate" -- "$cur")) ;; | ||
--timeout | -t) COMPREPLY=($(compgen -P "$cur" -W "{0..9}")); compopt -o nospace; compopt -o nosort ;; | ||
--ignore | --prefer) COMPREPLY=($(compgen -P "'" -S "'" -W "$(_eos-rankmirrors_GetMirrors)" -- "$cur")) ;; | ||
--mirror-verbosity) COMPREPLY=($(compgen -W "${verbosities[*]}" -- "$cur")) ;; | ||
*) | ||
# Handle all top-level parameters. | ||
case "$cur" in | ||
-* | "") | ||
# Any option or nothing yet. | ||
COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) | ||
;; | ||
*) | ||
# Non-option parameters. | ||
;; | ||
esac | ||
;; | ||
case "$cur" in # Handle all top-level parameters. | ||
-* | "") | ||
# Any option or nothing yet. | ||
COMPREPLY=($(compgen -W "${opts[*]}" -- "$cur")) | ||
;; | ||
*) | ||
# Non-option parameters. | ||
;; | ||
esac | ||
;; | ||
esac | ||
} && | ||
complete -F _eos-rankmirrors_ eos-rankmirrors |