[pacman-dev] [PATCH] rankmirrors: Add a --repo option to target a specific repo
--- scripts/rankmirrors.sh.in | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index d5cbadd..54b04e0 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -35,6 +35,7 @@ usage() { echo " -t, --times only output mirrors and their response times" echo " -u, --url test a specific url" echo " -v, --verbose be verbose in ouptut" + echo " -r, --repo specify a specific repo name instead of guessing" exit 0 } @@ -69,13 +70,18 @@ ARCH="$(uname -m)" getfetchurl() { local strippedurl="${1%/}" - local replacedurl="${strippedurl//'$repo'/core}" - replacedurl="${replacedurl//'$arch'/$ARCH}" + local replacedurl="${replacedurl//'$arch'/$ARCH}" + if [[ $TARGETREPO ]]; then + replacedurl="${strippedurl//'$repo'/core}" + local tmp="${replacedurl%/*}" + tmp="${tmp%/*}" - local tmp="${replacedurl%/*}" - tmp="${tmp%/*}" + local reponame="${tmp##*/}" + else + replacedurl="${strippedurl//'$repo'/$TARGETREPO}" + local reponame="$TARGETREPO" + fi - local reponame="${tmp##*/}" if [[ -z $reponame || $reponame = $replacedurl ]]; then echo "fail" else @@ -119,6 +125,7 @@ while [[ $1 ]]; do times) TIMESONLY=1 ; shift ;; verbose) VERBOSE=1 ; shift ;; url) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; shift 2;; + repo) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; shift 2;; *) err "\`$1' is an invalid argument." esac elif [[ ${1:0:1} = - ]]; then @@ -136,6 +143,7 @@ while [[ $1 ]]; do t) TIMESONLY=1 ;; v) VERBOSE=1 ;; u) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; snum=2;; + r) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; snum=2;; n) [[ $2 ]] || err "Must specify number." ; NUM="$2" ; snum=2;; *) err "\`-$1' is an invald argument." ;; esac @@ -182,6 +190,7 @@ for line in "${linearray[@]}"; do # Getting values and times and such server="${line#*= }" + server="${server%%#*}" url="$(getfetchurl "$server")" [[ $url = fail ]] && err "url \`$URL' is malformed." time=$(gettime "$url") -- 1.7.0
I can't get this to apply. Can you try resending and making sure spaces don't get eaten and it isn't base64 encoded? -Dan On Wed, Mar 31, 2010 at 12:51 PM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
--- scripts/rankmirrors.sh.in | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index d5cbadd..54b04e0 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -35,6 +35,7 @@ usage() { echo " -t, --times only output mirrors and their response times" echo " -u, --url test a specific url" echo " -v, --verbose be verbose in ouptut" + echo " -r, --repo specify a specific repo name instead of guessing" exit 0 }
@@ -69,13 +70,18 @@ ARCH="$(uname -m)" getfetchurl() { local strippedurl="${1%/}"
- local replacedurl="${strippedurl//'$repo'/core}" - replacedurl="${replacedurl//'$arch'/$ARCH}" + local replacedurl="${replacedurl//'$arch'/$ARCH}" + if [[ $TARGETREPO ]]; then + replacedurl="${strippedurl//'$repo'/core}" + local tmp="${replacedurl%/*}" + tmp="${tmp%/*}"
- local tmp="${replacedurl%/*}" - tmp="${tmp%/*}" + local reponame="${tmp##*/}" + else + replacedurl="${strippedurl//'$repo'/$TARGETREPO}" + local reponame="$TARGETREPO" + fi
- local reponame="${tmp##*/}" if [[ -z $reponame || $reponame = $replacedurl ]]; then echo "fail" else @@ -119,6 +125,7 @@ while [[ $1 ]]; do times) TIMESONLY=1 ; shift ;; verbose) VERBOSE=1 ; shift ;; url) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; shift 2;; + repo) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; shift 2;; *) err "\`$1' is an invalid argument." esac elif [[ ${1:0:1} = - ]]; then @@ -136,6 +143,7 @@ while [[ $1 ]]; do t) TIMESONLY=1 ;; v) VERBOSE=1 ;; u) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; snum=2;; + r) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; snum=2;; n) [[ $2 ]] || err "Must specify number." ; NUM="$2" ; snum=2;; *) err "\`-$1' is an invald argument." ;; esac @@ -182,6 +190,7 @@ for line in "${linearray[@]}"; do
# Getting values and times and such server="${line#*= }" + server="${server%%#*}" url="$(getfetchurl "$server")" [[ $url = fail ]] && err "url \`$URL' is malformed." time=$(gettime "$url") -- 1.7.0
On Thu, May 6, 2010 at 12:49, Dan McGee <dpmcgee@gmail.com> wrote:
I can't get this to apply. Can you try resending and making sure spaces don't get eaten and it isn't base64 encoded?
-Dan
I suspect it was because of the gmail hoops I had to jump through... git send-email failed because it can only send from my daenyth@ address rather than daenyth+arch@ (my subscribed name), so I had to send it to myself and forward it... Adding as an attachment which should hopefully keep it intact. I've rebased it against master as well.
On Thu, May 6, 2010 at 10:45 PM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
On Thu, May 6, 2010 at 12:49, Dan McGee <dpmcgee@gmail.com> wrote:
I can't get this to apply. Can you try resending and making sure spaces don't get eaten and it isn't base64 encoded?
-Dan
I suspect it was because of the gmail hoops I had to jump through... git send-email failed because it can only send from my daenyth@ address rather than daenyth+arch@ (my subscribed name), so I had to send it to myself and forward it...
Adding as an attachment which should hopefully keep it intact. I've rebased it against master as well.
Fail. $ ./scripts/rankmirrors /etc/pacman.d/mirrorlist # Server list generated by rankmirrors on 2010-05-07 # Server list generated by rankmirrors on 2009-01-04 # # Arch Linux repository mirrorlist # #Server = http://localhost:8954/search/$repo/os/x86_64 url `' is malformed. Why doesn't this default to anything? I think your logic in there might be backwards. Can you add a Signed-off-by: line as well when you fix it? Thanks! -Dan
On Fr> On Thu, May 6, 2010 at 10:45 PM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
Fail. Could have sworn I tested it and it worked during initial dev... I'll go over it soon when I have some time and resubmit.
Why doesn't this default to anything? I think your logic in there might be backwards. I thought I had made it default to the old detection method (3rd token from the end). I haven't looked at it in a while, I'll check that.
Can you add a Signed-off-by: line as well when you fix it? Thanks! Sure
On Fri 07 May 2010 09:42 -0400, Daenyth Blank wrote:
On Fr> On Thu, May 6, 2010 at 10:45 PM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
Fail.
Could have sworn I tested it and it worked during initial dev... I'll go over it soon when I have some time and resubmit.
I think your email client is causing a problem. It's attaching patches as application/octet-stream base64 encoded. But the patch seems to work fine for me. Here I re-attach inline as text/plain.
From 3aa3f9ce824bb0797ffe13d2b2e6eb82049b19a1 Mon Sep 17 00:00:00 2001 From: Daenyth <Daenyth+Arch@gmail.com> Date: Sat, 20 Mar 2010 15:03:45 -0400 Subject: [PATCH] rankmirrors: Add a --repo option to target a specific repo
--- scripts/rankmirrors.sh.in | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index d5cbadd..54b04e0 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -35,6 +35,7 @@ usage() { echo " -t, --times only output mirrors and their response times" echo " -u, --url test a specific url" echo " -v, --verbose be verbose in ouptut" + echo " -r, --repo specify a specific repo name instead of guessing" exit 0 } @@ -69,13 +70,18 @@ ARCH="$(uname -m)" getfetchurl() { local strippedurl="${1%/}" - local replacedurl="${strippedurl//'$repo'/core}" - replacedurl="${replacedurl//'$arch'/$ARCH}" + local replacedurl="${replacedurl//'$arch'/$ARCH}" + if [[ $TARGETREPO ]]; then + replacedurl="${strippedurl//'$repo'/core}" + local tmp="${replacedurl%/*}" + tmp="${tmp%/*}" - local tmp="${replacedurl%/*}" - tmp="${tmp%/*}" + local reponame="${tmp##*/}" + else + replacedurl="${strippedurl//'$repo'/$TARGETREPO}" + local reponame="$TARGETREPO" + fi - local reponame="${tmp##*/}" if [[ -z $reponame || $reponame = $replacedurl ]]; then echo "fail" else @@ -119,6 +125,7 @@ while [[ $1 ]]; do times) TIMESONLY=1 ; shift ;; verbose) VERBOSE=1 ; shift ;; url) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; shift 2;; + repo) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; shift 2;; *) err "\`$1' is an invalid argument." esac elif [[ ${1:0:1} = - ]]; then @@ -136,6 +143,7 @@ while [[ $1 ]]; do t) TIMESONLY=1 ;; v) VERBOSE=1 ;; u) CHECKURL=1; [[ $2 ]] || err "Must specify url."; URL="$2"; snum=2;; + r) [[ $2 ]] || err "Must specify repo name."; TARGETREPO="$2"; snum=2;; n) [[ $2 ]] || err "Must specify number." ; NUM="$2" ; snum=2;; *) err "\`-$1' is an invald argument." ;; esac @@ -182,6 +190,7 @@ for line in "${linearray[@]}"; do # Getting values and times and such server="${line#*= }" + server="${server%%#*}" url="$(getfetchurl "$server")" [[ $url = fail ]] && err "url \`$URL' is malformed." time=$(gettime "$url") -- 1.7.1
On Fri, May 7, 2010 at 10:17, Loui Chang <louipc.ist@gmail.com> wrote:
I think your email client is causing a problem. It's attaching patches as application/octet-stream base64 encoded. Just using gmail... Dunno what's wrong.
But the patch seems to work fine for me. Here I re-attach inline as text/plain.
From 3aa3f9ce824bb0797ffe13d2b2e6eb82049b19a1 Mon Sep 17 00:00:00 2001 From: Daenyth <Daenyth+Arch@gmail.com> Date: Sat, 20 Mar 2010 15:03:45 -0400 Subject: [PATCH] rankmirrors: Add a --repo option to target a specific repo
@@ -69,13 +70,18 @@ ARCH="$(uname -m)" getfetchurl() { local strippedurl="${1%/}"
- local replacedurl="${strippedurl//'$repo'/core}" - replacedurl="${replacedurl//'$arch'/$ARCH}" + local replacedurl="${replacedurl//'$arch'/$ARCH}" + if [[ $TARGETREPO ]]; then I think this is wrong now that I look at it. Should be [[ ! $TARGETREPO ]]. I'll fix and re-send later today.
+ replacedurl="${strippedurl//'$repo'/core}" + local tmp="${replacedurl%/*}" + tmp="${tmp%/*}"
- local tmp="${replacedurl%/*}" - tmp="${tmp%/*}" + local reponame="${tmp##*/}" + else + replacedurl="${strippedurl//'$repo'/$TARGETREPO}" + local reponame="$TARGETREPO" + fi
- local reponame="${tmp##*/}" if [[ -z $reponame || $reponame = $replacedurl ]]; then echo "fail" else
On Fri, May 7, 2010 at 9:42 AM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
+ if [[ $TARGETREPO ]]; then I think this is wrong now that I look at it. Should be [[ ! $TARGETREPO ]]. I'll fix and re-send later today.
Ping?
On Thu, May 13, 2010 at 19:17, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, May 7, 2010 at 9:42 AM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
+ if [[ $TARGETREPO ]]; then I think this is wrong now that I look at it. Should be [[ ! $TARGETREPO ]]. I'll fix and re-send later today.
Ping?
Sorry, lost track of it. Been busy with work this week. Fixing it up now.
On Thu, May 13, 2010 at 6:21 PM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
On Thu, May 13, 2010 at 19:17, Dan McGee <dpmcgee@gmail.com> wrote:
On Fri, May 7, 2010 at 9:42 AM, Daenyth Blank <daenyth+arch@gmail.com> wrote:
+ if [[ $TARGETREPO ]]; then I think this is wrong now that I look at it. Should be [[ ! $TARGETREPO ]]. I'll fix and re-send later today.
Ping?
Sorry, lost track of it. Been busy with work this week. Fixing it up now.
No problem, just wanted to make sure it didn't get forgotten. :) -Dan
participants (3)
-
Daenyth Blank
-
Dan McGee
-
Loui Chang