From 4315440f9adbeea71c4ef477945898523b54f898 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 3 Feb 2024 15:01:27 +0200 Subject: [PATCH] [eos-rankmirrors] added config var EOS_OVERWRITE_MIRRORLIST; show more info about outdated mirror; removed duplicates from mirrolist when user preferred some mirrors --- eos-rankmirrors/PKGBUILD | 6 +++--- eos-rankmirrors/eos-rankmirrors | 27 ++++++++++++++++++++++++++- eos-rankmirrors/eos-rankmirrors.conf | 17 +++++++++++------ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/eos-rankmirrors/PKGBUILD b/eos-rankmirrors/PKGBUILD index 2dafdcce..2000c37e 100644 --- a/eos-rankmirrors/PKGBUILD +++ b/eos-rankmirrors/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: EndeavourOS pkgname=eos-rankmirrors -pkgver=2.27 +pkgver=24 pkgrel=1 pkgdesc="EndeavourOS mirror ranking tool" arch=('any') @@ -22,11 +22,11 @@ source=( $url/eos-rankmirrors.conf $url/eos-rankmirrors.disabled ) -sha512sums=('9bbf1c3ef2b560dac30cd00c194376377a7b2130ada51d9c9dc50de63e12fc837bf3be2507781e4a11b7e154c11ddb5453e80a0552314a7917f0baacae6b84ae' +sha512sums=('0edc04542fa95c97c031555a8993dc1be291d4eae38ef19c8a634249870552cff4d62adca843580941ab2d4015f65216d34fa2172ed21fa35e38c1f09f6db550' 'ccfe87b9107618578042dd1379bc080f8df9da85b0a03c0a2b8ddfbd2c2a6a417964b3a83c74a949063aa5c145e8083a69e05bade59cfc938467ea08fb63d945' '580511c676cf56b5b8580d6819e0d1a4c85a40a3cd10f4b4f04fb9c004b14025b56cf4c3048e0fe8f9eef48d924b32b97d1e9669fac39b96f4203e2d68e3bd07' 'f01f6267f624992febfec29c76f2de1c503693086ade5783e2b9cbef359f5155bf6df520ff06299193c842aef2a05cac5078977ee0dabf55cff66f44aec6e44a' - '226111836a42e3540c714105813f64b285b3c48d41ea058e7339ba5b2de530a691d753b8f6d10984d260ed3288b01539715b00ad9bef4d808d21303c936837e7' + 'a95c38c8d359b054a77a11dec6ea774e3e4c62dcb7f667eaf24e62a2066f12e98da43d2dbf622fd0b9efcce15e6a8c1655afd8dc753c0705b527891f74f8b479' '06b77d1109fec45071dd2a3c1be07c225a5735961bd2818d0ccea608fef6e85bf4ae71d821427aa766d5b1934195282c1964965df7bd49602316b3bab6bf9824') package() { diff --git a/eos-rankmirrors/eos-rankmirrors b/eos-rankmirrors/eos-rankmirrors index 90124bca..5743a814 100755 --- a/eos-rankmirrors/eos-rankmirrors +++ b/eos-rankmirrors/eos-rankmirrors @@ -190,7 +190,7 @@ GetUpdateNumberAndTime() { WarningAbout "$mirror" "Update level is $nr/$reference_level, problem with the mirror?" return elif [ $nr -lt $low_limit ] ; then - WarningAbout "$mirror" "Update level is $nr/$reference_level, some packages may be outdated." + WarningAbout "$mirror" "Update level is $nr/$reference_level, some [endeavouros] packages may be outdated if this mirror is in use." fi fi result="$nr $time" @@ -368,6 +368,8 @@ SimpleRank() { # Option --prefer takes precedence over variable ALWAYS_FIRST_EOS_MIRRORS when both are used. + RemoveUserAddedFromList "$pref" + if [ -n "$preferred_mirrors" ] ; then UserAddedMirrors "$preferred_mirrors" fi @@ -382,6 +384,29 @@ SimpleRank() { echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" } +RemoveUserAddedFromList() { + local -r prefs="$1" + local pref + local item + local tmp=() + local found=no + + if [ "$prefs" ] ; then + for item in "${result[@]}" ; do + for pref in $prefs ; do + case "$item" in + *"$pref"*) found=yes + [ "$internal_testing" = yes ] && INFO "Dropping duplicate: $(echo "$item" | awk '{print $1}')" + continue 2 + ;; + esac + done + tmp+=("$item") + done + fi + [ "$found" = "yes" ] && result=("${tmp[@]}") +} + UserAddedMirrors() { local mirrors="$1" # a list of strings separated by '|' (pipe) chars local mirror m diff --git a/eos-rankmirrors/eos-rankmirrors.conf b/eos-rankmirrors/eos-rankmirrors.conf index e5a002dd..36f582e0 100644 --- a/eos-rankmirrors/eos-rankmirrors.conf +++ b/eos-rankmirrors/eos-rankmirrors.conf @@ -5,14 +5,19 @@ # Using bash syntax. ############################################### -# EOS_AUTO_MIRROR_RANKING determines whether the -# ranked EndeavourOS mirror list will overwrite the existing -# mirror list or simply be stored as a .pacnew file. +# EOS_OVERWRITE_MIRRORLIST determines whether the +# new EndeavourOS mirror list will automatically overwrite +# the existing list or simply be stored as a .pacnew file. # Supported values: -# "yes" overwrite the existing EndeavourOS mirror list -# "no" save new mirror list as a .pacnew file +# "yes" Overwrite the existing /etc/endeavouros-mirrorlist. +# "no" Save new mirror list as a .pacnew file (default). # -EOS_AUTO_MIRROR_RANKING=no +EOS_OVERWRITE_MIRRORLIST=no + +# EOS_AUTO_MIRROR_RANKING is an alias to EOS_OVERWRITE_MIRRORLIST +# for backwards compatibility. +# +EOS_AUTO_MIRROR_RANKING=$EOS_OVERWRITE_MIRRORLIST # Don't change this line! # EOS_AUTORANK_TIMEOUT specifies the maximum time (in seconds) # for each mirror to return the full answer.