summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Guertin <gerk@gentoo.org>2003-02-27 09:11:45 +0000
committerMark Guertin <gerk@gentoo.org>2003-02-27 09:11:45 +0000
commit56896541a30da0fc52a4deaff146f2432d4672bc (patch)
tree6b19d956b71417d7b218e22fa483665c4942f5c0 /app-admin
parentfix for #16403 (diff)
downloadgentoo-2-56896541a30da0fc52a4deaff146f2432d4672bc.tar.gz
gentoo-2-56896541a30da0fc52a4deaff146f2432d4672bc.tar.bz2
gentoo-2-56896541a30da0fc52a4deaff146f2432d4672bc.zip
new version, now has auto mode
Diffstat (limited to 'app-admin')
-rw-r--r--app-admin/mirrorselect/ChangeLog9
-rw-r--r--app-admin/mirrorselect/files/digest-mirrorselect-0.20
-rw-r--r--app-admin/mirrorselect/files/mirrorselect105
-rw-r--r--app-admin/mirrorselect/mirrorselect-0.2.ebuild20
4 files changed, 105 insertions, 29 deletions
diff --git a/app-admin/mirrorselect/ChangeLog b/app-admin/mirrorselect/ChangeLog
index 090d20cb278a..4bcf804aa0a5 100644
--- a/app-admin/mirrorselect/ChangeLog
+++ b/app-admin/mirrorselect/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for app-admin/mirrorselect
# Copyright 2002-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-admin/mirrorselect/ChangeLog,v 1.7 2003/02/24 19:22:12 weeve Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-admin/mirrorselect/ChangeLog,v 1.8 2003/02/27 09:11:45 gerk Exp $
+
+*mirrorselect-0.2 (27 Feb 2003)
+
+ 27 Feb 2003; Mark Guertin <gerk@gentoo.org> mirrorselect-0.2.ebuild
+ files/digest-mirrorselect-0.2 files/mirrorselect :
+ new version, now has auto mode, just for spanky :), run with -a for
+ automode or with no options to show usage
22 Feb 2003; Guy Martin <gmsoft@gentoo.org> mirrorselect-0.1-r2.ebuild :
Added hppa to keywords.
diff --git a/app-admin/mirrorselect/files/digest-mirrorselect-0.2 b/app-admin/mirrorselect/files/digest-mirrorselect-0.2
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/app-admin/mirrorselect/files/digest-mirrorselect-0.2
diff --git a/app-admin/mirrorselect/files/mirrorselect b/app-admin/mirrorselect/files/mirrorselect
index b3ca69c1c721..752ec1d20b28 100644
--- a/app-admin/mirrorselect/files/mirrorselect
+++ b/app-admin/mirrorselect/files/mirrorselect
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Gentoo Mirror Selection tool
# Copyright 2003 Mark Guertin <gerk@gentoo.org>
# Distributed under the GPL v2
@@ -7,6 +7,7 @@
# for now it has a static list of mirrors, but will move to a more
# dynamic setup once the lists are in place to pull from
+if [ -z "${MIRROR_LIST}" ] ; then
MIRROR_LIST='
ftp://ftp.ibiblio.org/pub/linux/distributions/gentoo (USA)
ftp://ftp.gtlib.cc.gatech.edu/pub/gentoo (USA)
@@ -26,37 +27,84 @@ ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo/ (Netherlands/ftp)
ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/gentoo/ (France/ftp)
http://distro.ibiblio.org/gentoo (USA)
'
+fi
+
+# if auto mode is set run netselect
+if [ "${1}" = "-a" ] ; then
+ echo "Fetching server list from web"
+ # nastiness, but it should work for now
+ MIRROR_LIST=$((echo -e "GET /main/en/mirrors.xml HTTP/0.9\r\n\r\n" 1>&3 & cat 0<&3) 3<> /dev/tcp/gentoo.org/80 | \
+ (read i; while [ "$(echo $i | tr -d '\r')" != "" ]; do read i; echo "." > 2; done; cat) | \
+ perl -nle'print $1 if /\s{5}<a href="((htt|ft)p[^"]+)/' | grep -v "MIRRORS")
-# change "mirror (loc)" to "mirror(loc)" for bash loop below
-MIRROR_LOCS=`echo $MIRROR_LIST | sed -e "s/ (/(/g"`
-# grab the current GENTOO_MIRRORS from /etc/make.conf and remove "'s
-DEF_MIRROR_LOCS=`egrep -e "^[ \t]*GENTOO_MIRRORS=[^ \t\n]" /etc/make.conf | sed -e "s/.*GENTOO_MIRRORS=\"//" | sed -e "s/[\" ]/\n/g"`
-
-MIRROR_LIST=""
-for entry in `echo $MIRROR_LOCS`
-do
- found="0"
- for defentry in `echo $DEF_MIRROR_LOCS`
- do
- if [ `echo $entry | egrep $defentry` ]
- then
- found="1"
+ for i in $MIRROR_LIST
+ do
+ CHECKLIST="${CHECKLIST} `echo $i | grep -v "("`"
+ done
+
+ if [ "`echo ${2} | grep -e "^-s[01234567890]"`" ] ; then
+ SERVERS="${2}"
+ else
+ if [ "${2}" ] ; then
+ echo "${2} is an invalid option"
+ exit
+ fi
fi
- done
- # split entries back into "mirror (loc)"
- entry=`echo $entry | sed -e "s/(/ (/"`
- if [ "${found}" = "1" ]
- then
- MIRROR_LIST="${MIRROR_LIST} $entry ON"
- else
- MIRROR_LIST="${MIRROR_LIST} $entry OFF"
- fi
-done
+ #pick the mirror from list
+ echo "Running netselect on serverlist, this may take a moment"
+ CHOSEN=`netselect $SERVERS ${CHECKLIST} | awk -F" " '{ print $2 }'`
+ for i in $CHOSEN
+ do
+ MIRRORS="${MIRRORS} $i"
+ done
-MIRRORS=`dialog --title "GENTOO MIRRORS LIST" \
- --checklist "Please select your desired mirror(s):" 20 80 12 \
-$MIRROR_LIST 2>&1 | sed "s:\"::g"`
+elif [ "${1}" = "-i" ] ; then
+ # not auto mode, we'll run dialog based selection tool
+ # change "mirror (loc)" to "mirror(loc)" for bash loop below
+ MIRROR_LOCS=`echo $MIRROR_LIST | sed -e "s/ (/(/g"`
+ # grab the current GENTOO_MIRRORS from /etc/make.conf and remove "'s
+ DEF_MIRROR_LOCS=`egrep -e "^[ \t]*GENTOO_MIRRORS=[^ \t\n]" /etc/make.conf | sed -e "s/.*GENTOO_MIRRORS=\"//" | sed -e "s/[\" ]/\n/g"`
+
+ MIRROR_LIST=""
+ for entry in `echo $MIRROR_LOCS`
+ do
+ found="0"
+ for defentry in `echo $DEF_MIRROR_LOCS`
+ do
+ if [ `echo $entry | egrep $defentry` ]
+ then
+ found="1"
+ fi
+ done
+
+ # split entries back into "mirror (loc)"
+ entry=`echo $entry | sed -e "s/(/ (/"`
+ if [ "${found}" = "1" ]
+ then
+ MIRROR_LIST="${MIRROR_LIST} $entry ON"
+ else
+ MIRROR_LIST="${MIRROR_LIST} $entry OFF"
+ fi
+ done
+
+ MIRRORS=`dialog --title "GENTOO MIRRORS LIST" \
+ --checklist "Please select your desired mirror(s):" 20 80 12 \
+ $MIRROR_LIST 2>&1 | sed "s:\"::g"`
+
+else
+echo "mirrorselect usage (updated):"
+echo "-i : interactive mode, dialog based and static mirrorlist"
+echo "-a (-s<num>) : auto mode, will retrieve live mirror list from web,"
+echo " run netselect and choose the server(s) with best response times."
+echo " You can optionally add -s<num> where <num> = number of server choices "
+echo " you want, i.e. mirrorselect -a -s3 will select top 3 netselect choices "
+echo " and set them in make.conf. Note: -s only works with -a option"
+echo
+
+exit
+
+fi
if [ ! "`echo $MIRRORS`" ] ; then
@@ -93,3 +141,4 @@ else
fi
fi
+
diff --git a/app-admin/mirrorselect/mirrorselect-0.2.ebuild b/app-admin/mirrorselect/mirrorselect-0.2.ebuild
new file mode 100644
index 000000000000..53a7058a4eec
--- /dev/null
+++ b/app-admin/mirrorselect/mirrorselect-0.2.ebuild
@@ -0,0 +1,20 @@
+# Copyright 1999-2003 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/mirrorselect/mirrorselect-0.2.ebuild,v 1.1 2003/02/27 09:11:45 gerk Exp $
+
+DESCRIPTION="Tool to help select distfiles mirrors for Gentoo"
+SRC_URI=""
+HOMEPAGE=""
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="x86 ppc sparc ~alpha ~mips hppa"
+
+DEPEND=">=dev-util/dialog-0.7
+ sys-apps/grep
+ sys-apps/sed"
+
+src_install() {
+ dosbin ${FILESDIR}/mirrorselect
+}
+