~ubuntu-branches/debian/sid/netselect/sid

« back to all changes in this revision

Viewing changes to netselect-apt

  • Committer: Bazaar Package Importer
  • Author(s): Javier Fernandez-Sanguino Pen~a
  • Date: 2010-12-01 01:43:12 UTC
  • Revision ID: james.westby@ubuntu.com-20101201014312-mqb1bh22dfagzqsg
Tags: 0.3.ds1-15
* Take over this package's maintenance, with maintainer's approval.
* netselect:
    - Implement a -I option to make netselect use ICMP probes instead of UDP.
      This option is useful to test servers when there is some element
      that does not allow traceroute tests in the intermediate path 
      (including the local computer, through it's firewall).  
      (Closes: 601227, 217256, 384218)
    - Do not printout verbose messages detailing hosts to stdout but
      to stderr
* netselect.1:
   - Document the new -I option
   - Add more examples, specifically describing the issues with multiple
     DNS names in hosts.
* netselect-apt:
   - Introduce a way to provide options to netselect through -O
   - Check if netselect exists 
   - Abort if not being run as root and netselect is not setuid
   - Use -I per default as many debian mirrors do not actually allow
     traceroute tests
   - Only use standard output when parsing netselect's output, stderr
     gets thrown out as we do not need it (but the user might have
     set it with -v calls in -O)
   - Stricter filtering of netselect output to prevent picking up
     wrong data by mistake 
* debian/netselect.README.Debian: More information on why netselect
  needs to be run as ROOT.
* debian/control: 
    - Update Homepage to github
    - Update SVN-Browse to github, keep the URL of collab-main
      in debian/README.source
* debian/EXTRA: include modified version of netselect-apt by
  Manuel Estrada Sainz a long time ago (2002) which provides additional
  features such as testing for other protocols (rsync, ftp, http)
  and checking that the mirrors actually work. This code needs to
  be forward ported to netselect-apt in order to close 135558. But having
  it in the package at least ensures it is not forgotten.
* debian/TODO: review all pending work to be done and include it in the
  file, reference bug reports when appropriate.
* debian/netselect-apt.NEWS and debian/netselect.NEWS: Fix version
  numbers as they pointed to inexistent versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# please do.  Then tell me, so I can remove it from the netselect package.
14
14
#
15
15
# TO DO:
16
 
#   - have some way to pass options (especially -t) to netselect.
17
16
#   - test the generated files automatically.  Some mirrors in the list
18
17
#       are broken.  We should at least verify that the Packages and Sources
19
18
#       files exist and aren't ancient.
35
34
url="http://www.debian.org/mirror/mirrors_full"
36
35
arch=$(/usr/bin/dpkg-architecture -qDEB_HOST_ARCH)
37
36
 
38
 
options="-o a:si:o:nfhu -l arch:,sources,infile:,outfile:,nonfree,ftp,help"
 
37
options="-o a:si:o:O:nfhu -l arch:,sources,infile:,outfile:,nonfree,ftp,help"
39
38
 
40
39
trap '[ "$tmpinfile" = "1" ] && rm -f "$infile"' TERM INT EXIT
41
40
 
49
48
{
50
49
        SEARCH="$1"
51
50
        PROTO="$2"
52
 
        out=$(netselect -v -s 1 $(cat "$infile" \
 
51
#        log "DEBUG: Running netselect with $netselect_options"
 
52
        hosts=$(cat "$infile" \
53
53
                | perl -n -e '
54
54
                        $/="<br><br>";
55
55
                        while(<>){
59
59
                                                m@<br>'"$SEARCH"':.*<a href="('"$PROTO"'://.*?)">@i
60
60
                                        ){
61
61
                                        print("$1\n");
62
 
                                }
63
 
                        }'))
 
62
                                }}')
 
63
        out=`netselect $netselect_options  $hosts`
64
64
        rv=$?
65
 
        echo $out | awk '{print $2}'
 
65
        echo $out | perl -n -e 'print $1 if /\d+\s+([^\s]*?)$/'
66
66
        return $rv
67
67
}
68
68
 
69
69
netselect_generic_error()
70
70
{
71
71
        log "netselect was unable to find a mirror, this probably means that"
72
 
        log "you are behind a firewall and it is blocking traceroute."
 
72
        log "you are behind a firewall and it is blocking ICMP and/or"
 
73
        log "UDP traceroute. Or the servers test are actively blocking"
 
74
        log "ICMP and/or UDP traceroute probes."
73
75
}
74
76
 
75
77
netselect_permission_error()
92
94
        log "   -f, --ftp              Use FTP as the protocol for OUTFILE (HTTP)"
93
95
}
94
96
 
 
97
# Sanity tests
 
98
NETSELECT=`which netselect`
 
99
# Does netselect exist?
 
100
if [ -z "$NETSELECT" ] ; then
 
101
    log "Sorry, I cannot find the 'netselect' binary in my PATH"
 
102
    exit 1
 
103
fi
 
104
# Are we root?
 
105
if [ "`id -u`" -gt 0 ] ; then
 
106
# If we are not, is netselect setuid?
 
107
    if [ ! -u "$NETSELECT" ] ; then
 
108
        log "Sorry, you need to be root to run $0 since the netselect"
 
109
        log "binary we will use ($NETSELECT) is not setuid."
 
110
        exit 1
 
111
    fi
 
112
fi
 
113
 
 
114
# Default netselect options
 
115
netselect_options="-I -v -s 1"
95
116
 
96
117
# commandline parsing
97
118
temp=$(getopt $options -n 'netselect-apt' -- "$@")
103
124
                -s|--sources) want_sources=1; shift ;;
104
125
                -i|--infile) infile="$2"; tmpinfile="0"; shift 2 ;;
105
126
                -o|--outfile) outfile="$2"; shift 2 ;;
 
127
                -O) netselect_options="$netselect_options $2"; shift 2 ;;
106
128
                -n|--nonfree) want_nonfree=1; shift ;;
107
129
                -f|--ftp) protocol="FTP"; shift ;;
108
130
                -h|--help) usage; exit 0;;
157
179
log "Choosing a main Debian mirror using netselect."
158
180
main=$(run_netselect "Packages over $protocol" $protocol)
159
181
netselect_rv=$?
160
 
if [ $netselect_rv -eq 0 ]; then
 
182
if [ $netselect_rv -eq 0 ] || [ ! -z "$main" ] ; then
161
183
        log "The fastest server seems to be:"
162
184
        log "        $main"
163
185
        log