source: rtems-source-builder/source-builder/sb/download.py

Last change on this file was c109b53, checked in by Chris Johns <chrisj@…>, on 04/03/24 at 04:20:11

sb: Add sb-rtems-pkg to update the RTEMS package hashes and checksums

  • Property mode set to 100644
File size: 24.7 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# Permission to use, copy, modify, and/or distribute this software for any
9# purpose with or without fee is hereby granted, provided that the above
10# copyright notice and this permission notice appear in all copies.
11#
12# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
20#
21# This code builds a package given a config file. It only builds to be
22# installed not to be package unless you run a packager around this.
23#
24
25from __future__ import print_function
26
27import base64
28import hashlib
29import os
30import re
31import stat
32import sys
33try:
34    import urllib.request as urllib_request
35    import urllib.parse as urllib_parse
36except ImportError:
37    import urllib2 as urllib_request
38    import urlparse as urllib_parse
39
40from . import cvs
41from . import error
42from . import git
43from . import log
44from . import path
45from . import sources
46from . import version
47
48def _do_download(opts):
49    download = True
50    if opts.dry_run():
51        download = False
52        wa = opts.with_arg('download')
53        if wa is not None:
54            if wa[0] == 'with_download' and wa[1] == 'yes':
55                download = True
56    return download
57
58def _humanize_bytes(bytes, precision = 1):
59    abbrevs = (
60        (1 << 50, 'PB'),
61        (1 << 40, 'TB'),
62        (1 << 30, 'GB'),
63        (1 << 20, 'MB'),
64        (1 << 10, 'kB'),
65        (1, ' bytes')
66    )
67    if bytes == 1:
68        return '1 byte'
69    for factor, suffix in abbrevs:
70        if bytes >= factor:
71            break
72    return '%.*f%s' % (precision, float(bytes) / factor, suffix)
73
74def _sensible_url(url, used = 0):
75    space = 100
76    if len(url) > space:
77        size = int(space - 14)
78        url = url[:size] + '...<see log>'
79    return url
80
81def _hash_check(file_, absfile, macros, remove = True):
82    failed = False
83    hash = sources.get_hash(file_.lower(), macros)
84    if hash is not None:
85        hash = hash.split()
86        if len(hash) != 2:
87            raise error.internal('invalid hash format: %s' % (file_))
88        if hash[0] == 'NO-HASH':
89            return not failed
90        try:
91            hashlib_algorithms = hashlib.algorithms
92        except:
93            hashlib_algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
94        if hash[0] not in hashlib_algorithms:
95            raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0]))
96        if hash[0] in ['md5', 'sha1']:
97            raise error.general('hash: %s: insecure: %s' % (file_, hash[0]))
98        hasher = None
99        _in = None
100        try:
101            hasher = hashlib.new(hash[0])
102            _in = open(path.host(absfile), 'rb')
103            hasher.update(_in.read())
104        except IOError as err:
105            log.notice('hash: %s: read error: %s' % (file_, str(err)))
106            failed = True
107        except:
108            msg = 'hash: %s: error' % (file_)
109            log.stderr(msg)
110            log.notice(msg)
111            if _in is not None:
112                _in.close()
113            raise
114        if _in is not None:
115            _in.close()
116        hash_hex = hasher.hexdigest()
117        hash_base64 = base64.b64encode(hasher.digest()).decode('utf-8')
118        log.output('checksums: %s: (hex: %s) (b64: %s) => %s' % (file_,
119                                                                 hash_hex,
120                                                                 hash_base64,
121                                                                 hash[1]))
122        if hash_hex != hash[1] and hash_base64 != hash[1]:
123            log.warning('checksum error: %s' % (file_))
124            failed = True
125        if failed and remove:
126            log.warning('removing: %s' % (file_))
127            if path.exists(absfile):
128                try:
129                    os.remove(path.host(absfile))
130                except IOError as err:
131                    raise error.general('hash: %s: remove: %s' % (absfile, str(err)))
132                except:
133                    raise error.general('hash: %s: remove error' % (file_))
134        if hasher is not None:
135            del hasher
136    else:
137        raise error.general('%s: no hash found' % (file_))
138    return not failed
139
140def _local_path(source, pathkey, config):
141    for p in config.define(pathkey).split(':'):
142        local_prefix = path.abspath(p)
143        local = path.join(local_prefix, source['file'])
144        if source['local'] is None:
145            source['local_prefix'] = local_prefix
146            source['local'] = local
147        if path.exists(local):
148            source['local_prefix'] = local_prefix
149            source['local'] = local
150            _hash_check(source['file'], local, config.macros)
151            break
152
153def _http_parser(source, pathkey, config, opts):
154    #
155    # If the file has not been overrided attempt to recover a possible file name.
156    #
157    if 'file-override' not in source['options']:
158        #
159        # Hack for gitweb.cgi patch downloads. We rewrite the various fields.
160        #
161        if 'gitweb.cgi' in source['url']:
162            url = source['url']
163            if '?' not in url:
164                raise error.general('invalid gitweb.cgi request: %s' % (url))
165            req = url.split('?')[1]
166            if len(req) == 0:
167                raise error.general('invalid gitweb.cgi request: %s' % (url))
168            #
169            # The gitweb.cgi request should have:
170            #    p=<what>
171            #    a=patch
172            #    h=<hash>
173            # so extract the p and h parts to make the local name.
174            #
175            p = None
176            a = None
177            h = None
178            for r in req.split(';'):
179                if '=' not in r:
180                    raise error.general('invalid gitweb.cgi path: %s' % (url))
181                rs = r.split('=')
182                if rs[0] == 'p':
183                    p = rs[1].replace('.', '-')
184                elif rs[0] == 'a':
185                    a = rs[1]
186                elif rs[0] == 'h':
187                    h = rs[1]
188            if p is None or h is None:
189                raise error.general('gitweb.cgi path missing p or h: %s' % (url))
190            source['file'] = '%s-%s.patch' % (p, h)
191        #
192        # Wipe out everything special in the file name.
193        #
194        source['file'] = re.sub(r'[^a-zA-Z0-9.\-_]+', '-', source['file'])
195        max_file_len = 127
196        if len(source['file']) > max_file_len:
197            raise error.general('file name length is greater than %i (maybe use --rsb-file=FILE option): %s' % \
198                                (max_file_len, source['file']))
199    #
200    # Check local path
201    #
202    _local_path(source, pathkey, config)
203    #
204    # Is the file compressed ?
205    #
206    esl = source['ext'].split('.')
207    if esl[-1:][0] == 'gz':
208        source['compressed-type'] = 'gzip'
209        source['compressed'] = '%{__gzip} -dc'
210    elif esl[-1:][0] == 'bz2':
211        source['compressed-type'] = 'bzip2'
212        source['compressed'] = '%{__bzip2} -dc'
213    elif esl[-1:][0] == 'zip':
214        source['compressed-type'] = 'zip'
215        source['compressed'] = '%{__unzip} -u'
216    elif esl[-1:][0] == 'xz':
217        source['compressed-type'] = 'xz'
218        source['compressed'] = '%{__xz} -dc'
219
220def _patchworks_parser(source, pathkey, config, opts):
221    #
222    # Check local path
223    #
224    _local_path(source, pathkey, config)
225    source['url'] = 'http%s' % (source['path'][2:])
226
227def _git_parser(source, pathkey, config, opts):
228    #
229    # Check local path
230    #
231    _local_path(source, pathkey, config)
232    #
233    # Symlink.
234    #
235    us = source['url'].split('?')
236    source['path'] = path.dirname(us[0])
237    source['file'] = path.basename(us[0])
238    source['name'], source['ext'] = path.splitext(source['file'])
239    if len(us) > 1:
240        source['args'] = us[1:]
241    source['local'] = \
242        path.join(source['local_prefix'], 'git', source['file'])
243    source['symlink'] = source['local']
244
245def _cvs_parser(source, pathkey, config, opts):
246    #
247    # Check local path
248    #
249    _local_path(source, pathkey, config)
250    #
251    # Symlink.
252    #
253    if not source['url'].startswith('cvs://'):
254        raise error.general('invalid cvs path: %s' % (source['url']))
255    us = source['url'].split('?')
256    try:
257        url = us[0]
258        source['file'] = url[url[6:].index(':') + 7:]
259        source['cvsroot'] = ':%s:' % (url[6:url[6:].index('/') + 6:])
260    except:
261        raise error.general('invalid cvs path: %s' % (source['url']))
262    for a in us[1:]:
263        _as = a.split('=')
264        if _as[0] == 'module':
265            if len(_as) != 2:
266                raise error.general('invalid cvs module: %s' % (a))
267            source['module'] = _as[1]
268        elif _as[0] == 'src-prefix':
269            if len(_as) != 2:
270                raise error.general('invalid cvs src-prefix: %s' % (a))
271            source['src_prefix'] = _as[1]
272        elif _as[0] == 'tag':
273            if len(_as) != 2:
274                raise error.general('invalid cvs tag: %s' % (a))
275            source['tag'] = _as[1]
276        elif _as[0] == 'date':
277            if len(_as) != 2:
278                raise error.general('invalid cvs date: %s' % (a))
279            source['date'] = _as[1]
280    if 'date' in source and 'tag' in source:
281        raise error.general('cvs URL cannot have a date and tag: %s' % (source['url']))
282    # Do here to ensure an ordered path, the URL can include options in any order
283    if 'module' in source:
284        source['file'] += '_%s' % (source['module'])
285    if 'tag' in source:
286        source['file'] += '_%s' % (source['tag'])
287    if 'date' in source:
288        source['file'] += '_%s' % (source['date'])
289    for c in '/@#%.-':
290        source['file'] = source['file'].replace(c, '_')
291    source['local'] = path.join(source['local_prefix'], 'cvs', source['file'])
292    if 'src_prefix' in source:
293        source['symlink'] = path.join(source['local'], source['src_prefix'])
294    else:
295        source['symlink'] = source['local']
296
297def _file_parser(source, pathkey, config, opts):
298    #
299    # Check local path
300    #
301    _local_path(source, pathkey, config)
302    #
303    # Get the paths sorted.
304    #
305    source['file'] = source['url'][6:]
306
307parsers = { 'http': _http_parser,
308            'ftp':  _http_parser,
309            'pw':   _patchworks_parser,
310            'git':  _git_parser,
311            'cvs':  _cvs_parser,
312            'file': _file_parser }
313
314def set_release_path(release_path, macros):
315    if release_path is None:
316        release_path = '%{rtems_release_url}/%{rsb_version}/sources'
317    macros.define('release_path', release_path)
318
319def parse_url(url, pathkey, config, opts, file_override = None):
320    #
321    # Split the source up into the parts we need.
322    #
323    source = {}
324    source['url'] = url
325    source['options'] = []
326    colon = url.find(':')
327    if url[colon + 1:colon + 3] != '//':
328        raise error.general('malforned URL (no protocol prefix): %s' % (url))
329    source['path'] = url[:colon + 3] + path.dirname(url[colon + 3:])
330    if file_override is None:
331        source['file'] = path.basename(url)
332    else:
333        bad_chars = [c for c in ['/', '\\', '?', '*'] if c in file_override]
334        if len(bad_chars) > 0:
335            raise error.general('bad characters in file name: %s' % (file_override))
336        log.output('download: file-override: %s' % (file_override))
337        source['file'] = file_override
338        source['options'] += ['file-override']
339    source['name'], source['ext'] = path.splitext(source['file'])
340    if source['name'].endswith('.tar'):
341        source['name'] = source['name'][:-4]
342        source['ext'] = '.tar' + source['ext']
343    #
344    # Get the file. Checks the local source directory first.
345    #
346    source['local'] = None
347    for p in parsers:
348        if url.startswith(p):
349            source['type'] = p
350            if parsers[p](source, pathkey, config, opts):
351                break
352    source['script'] = ''
353    return source
354
355def _http_downloader(url, local, config, opts):
356    if path.exists(local):
357        return True
358    #
359    # Hack for GitHub.
360    #
361    if url.startswith('https://api.github.com'):
362        url = urllib_parse.urljoin(url, config.expand('tarball/%{version}'))
363    dst = os.path.relpath(path.host(local))
364    log.output('download: (full) %s -> %s' % (url, dst))
365    log.notice('download: %s -> %s' % (_sensible_url(url, len(dst)), dst))
366    failed = False
367    if _do_download(opts):
368        _in = None
369        _out = None
370        _length = None
371        _have = 0
372        _chunk_size = 256 * 1024
373        _chunk = None
374        _last_percent = 200.0
375        _last_msg = ''
376        _have_status_output = False
377        _url = url
378        try:
379            try:
380                _in = None
381                _ssl_context = None
382                # See #2656
383                _req = urllib_request.Request(_url)
384                _req.add_header('User-Agent', 'Wget/1.16.3 (freebsd10.1)')
385                try:
386                    import ssl
387                    _ssl_context = ssl._create_unverified_context()
388                    _in = urllib_request.urlopen(_req, context = _ssl_context)
389                except:
390                    log.output('download: no ssl context')
391                    _ssl_context = None
392                if _ssl_context is None:
393                    _in = urllib_request.urlopen(_req)
394                if _url != _in.geturl():
395                    _url = _in.geturl()
396                    log.output(' redirect: %s' % (_url))
397                    log.notice(' redirect: %s' % (_sensible_url(_url)))
398                _out = open(path.host(local), 'wb')
399                try:
400                    _length = int(_in.info()['Content-Length'].strip())
401                except:
402                    pass
403                while True:
404                    _msg = '\rdownloading: %s - %s ' % (dst, _humanize_bytes(_have))
405                    if _length:
406                        _percent = round((float(_have) / _length) * 100, 2)
407                        if _percent != _last_percent:
408                            _msg += 'of %s (%0.0f%%) ' % (_humanize_bytes(_length), _percent)
409                    if _msg != _last_msg:
410                        extras = (len(_last_msg) - len(_msg))
411                        log.stdout_raw('%s%s' % (_msg, ' ' * extras + '\b' * extras))
412                        _last_msg = _msg
413                        _have_status_output = True
414                    _chunk = _in.read(_chunk_size)
415                    if not _chunk:
416                        break
417                    _out.write(_chunk)
418                    _have += len(_chunk)
419                log.stdout_raw('\n\r')
420            except:
421                if _have_status_output:
422                    log.stdout_raw('\n\r')
423                raise
424        except IOError as err:
425            log.notice('download: %s: error: %s' % (_sensible_url(_url), str(err)))
426            if path.exists(local):
427                os.remove(path.host(local))
428            failed = True
429        except ValueError as err:
430            log.notice('download: %s: error: %s' % (_sensible_url(_url), str(err)))
431            if path.exists(local):
432                os.remove(path.host(local))
433            failed = True
434        except:
435            msg = 'download: %s: error' % (_sensible_url(_url))
436            log.stderr(msg)
437            log.notice(msg)
438            if _in is not None:
439                _in.close()
440            if _out is not None:
441                _out.close()
442            raise
443        if _out is not None:
444            _out.close()
445        if _in is not None:
446            _in.close()
447            del _in
448        if not failed:
449            if not path.isfile(local):
450                raise error.general('source is not a file: %s' % (path.host(local)))
451            if not _hash_check(path.basename(local), local, config.macros, False):
452                raise error.general('checksum failure file: %s' % (dst))
453    return not failed
454
455def _git_downloader(url, local, config, opts):
456    repo = git.repo(local, opts, config.macros)
457    rlp = os.path.relpath(path.host(local))
458    us = url.split('?')
459    #
460    # Handle the various git protocols.
461    #
462    # remove 'git' from 'git://xxxx/xxxx?protocol=...'
463    #
464    url_base = us[0][len('git'):]
465    for a in us[1:]:
466        _as = a.split('=')
467        if _as[0] == 'protocol':
468            if len(_as) != 2:
469                raise error.general('invalid git protocol option: %s' % (_as))
470            if _as[1] == 'none':
471                # remove the rest of the protocol header leaving nothing.
472                us[0] = url_base[len('://'):]
473            else:
474                if _as[1] not in ['ssh', 'git', 'http', 'https', 'ftp', 'ftps', 'rsync']:
475                    raise error.general('unknown git protocol: %s' % (_as[1]))
476                us[0] = _as[1] + url_base
477    if not repo.valid():
478        log.notice('git: clone: %s -> %s' % (us[0], rlp))
479        if _do_download(opts):
480            repo.clone(us[0], local)
481    else:
482        repo.clean(['-f', '-d'])
483        repo.reset('--hard')
484        default_branch = repo.default_branch()
485        repo.checkout(default_branch)
486    for a in us[1:]:
487        _as = a.split('=')
488        if _as[0] == 'branch' or _as[0] == 'checkout':
489            if len(_as) != 2:
490                raise error.general('invalid git branch/checkout: %s' % (_as))
491            log.notice('git: checkout: %s => %s' % (us[0], _as[1]))
492            if _do_download(opts):
493                repo.checkout(_as[1])
494        elif _as[0] == 'submodule':
495            if len(_as) != 2:
496                raise error.general('invalid git submodule: %s' % (_as))
497            log.notice('git: submodule: %s <= %s' % (us[0], _as[1]))
498            if _do_download(opts):
499                repo.submodule(_as[1])
500        elif _as[0] == 'fetch':
501            log.notice('git: fetch: %s -> %s' % (us[0], rlp))
502            if _do_download(opts):
503                repo.fetch()
504        elif _as[0] == 'merge':
505            log.notice('git: merge: %s' % (us[0]))
506            if _do_download(opts):
507                repo.merge()
508        elif _as[0] == 'pull':
509            log.notice('git: pull: %s' % (us[0]))
510            if _do_download(opts):
511                repo.pull()
512        elif _as[0] == 'reset':
513            arg = []
514            if len(_as) > 1:
515                arg = ['--%s' % (_as[1])]
516            log.notice('git: reset: %s' % (us[0]))
517            if _do_download(opts):
518                repo.reset(arg)
519                repo.submodule_foreach(['reset'] + arg)
520        elif _as[0] == 'clean':
521            arg = []
522            if len(_as) > 1:
523                arg = ['--%s' % (_as[1])]
524            log.notice('git: clean: %s' % (us[0]))
525            if _do_download(opts):
526                repo.clean(arg)
527                repo.submodule_foreach(['clean'] + arg)
528        elif _as[0] == 'protocol':
529            pass
530        else:
531            raise error.general('invalid git option: %s' % (_as))
532    return True
533
534def _cvs_downloader(url, local, config, opts):
535    rlp = os.path.relpath(path.host(local))
536    us = url.split('?')
537    module = None
538    tag = None
539    date = None
540    src_prefix = None
541    for a in us[1:]:
542        _as = a.split('=')
543        if _as[0] == 'module':
544            if len(_as) != 2:
545                raise error.general('invalid cvs module: %s' % (a))
546            module = _as[1]
547        elif _as[0] == 'src-prefix':
548            if len(_as) != 2:
549                raise error.general('invalid cvs src-prefix: %s' % (a))
550            src_prefix = _as[1]
551        elif _as[0] == 'tag':
552            if len(_as) != 2:
553                raise error.general('invalid cvs tag: %s' % (a))
554            tag = _as[1]
555        elif _as[0] == 'date':
556            if len(_as) != 2:
557                raise error.general('invalid cvs date: %s' % (a))
558            date = _as[1]
559    repo = cvs.repo(local, opts, config.macros, src_prefix)
560    if not repo.valid():
561        if not path.isdir(local):
562            log.notice('Creating source directory: %s' % \
563                           (os.path.relpath(path.host(local))))
564            if _do_download(opts):
565                path.mkdir(local)
566            log.notice('cvs: checkout: %s -> %s' % (us[0], rlp))
567            if _do_download(opts):
568                repo.checkout(':%s' % (us[0][6:]), module, tag, date)
569    for a in us[1:]:
570        _as = a.split('=')
571        if _as[0] == 'update':
572            log.notice('cvs: update: %s' % (us[0]))
573            if _do_download(opts):
574                repo.update()
575        elif _as[0] == 'reset':
576            log.notice('cvs: reset: %s' % (us[0]))
577            if _do_download(opts):
578                repo.reset()
579    return True
580
581def _file_downloader(url, local, config, opts):
582    if not path.exists(local):
583        try:
584            src = url[7:]
585            dst = local
586            log.notice('download: copy %s -> %s' % (src, dst))
587            path.copy(src, dst)
588        except:
589            return False
590    return True
591
592downloaders = { 'http': _http_downloader,
593                'ftp':  _http_downloader,
594                'pw':   _http_downloader,
595                'git':  _git_downloader,
596                'cvs':  _cvs_downloader,
597                'file': _file_downloader }
598
599def get_file(url, local, opts, config):
600    if local is None:
601        raise error.general('source/patch path invalid')
602    if not path.isdir(path.dirname(local)) and not opts.download_disabled():
603        log.notice('Creating source directory: %s' % \
604                       (os.path.relpath(path.host(path.dirname(local)))))
605    log.output('making dir: %s' % (path.host(path.dirname(local))))
606    if _do_download(opts):
607        path.mkdir(path.dirname(local))
608    if not path.exists(local) and opts.download_disabled():
609        raise error.general('source not found: %s' % (path.host(local)))
610    #
611    # Check if a URL has been provided on the command line. If the package is
612    # released push the release path URLs to the start the RTEMS URL list
613    # unless overriden by the command line option --without-release-url. The
614    # variant --without-release-url can override the released check.
615    #
616    url_bases = opts.urls()
617    if url_bases is None:
618        url_bases = []
619    try:
620        rtems_release_url_value = config.macros.expand('%{release_path}')
621    except:
622        rtems_release_url_value = None
623    rtems_release_url = None
624    rtems_release_urls = []
625    if version.released() and rtems_release_url_value:
626        rtems_release_url = rtems_release_url_value
627    with_rel_url = opts.with_arg('release-url')
628    if with_rel_url[1] == 'not-found':
629        if config.defined('without_release_url'):
630            with_rel_url = ('without_release-url', 'yes')
631    if with_rel_url[0] == 'with_release-url':
632        if with_rel_url[1] == 'yes':
633            if rtems_release_url_value is None:
634                raise error.general('no valid release URL')
635            rtems_release_url = rtems_release_url_value
636        elif with_rel_url[1] == 'no':
637            pass
638        else:
639            rtems_release_url = with_rel_url[1]
640    elif with_rel_url[0] == 'without_release-url' and with_rel_url[1] == 'yes':
641        rtems_release_url = None
642    if rtems_release_url is not None:
643        rtems_release_urls = rtems_release_url.split(',')
644        for release_url in rtems_release_urls:
645            log.trace('release url: %s' % (release_url))
646            #
647            # If the URL being fetched is under the release path do not add
648            # the sources release path because it is already there.
649            #
650            if not url.startswith(release_url):
651                url_bases = [release_url] + url_bases
652    urls = []
653    if len(url_bases) > 0:
654        #
655        # Split up the URL we are being asked to download.
656        #
657        url_path = urllib_parse.urlsplit(url)[2]
658        slash = url_path.rfind('/')
659        if slash < 0:
660            url_file = url_path
661        else:
662            url_file = url_path[slash + 1:]
663        log.trace('url_file: %s' %(url_file))
664        for base in url_bases:
665            #
666            # Hack to fix #3064 where --rsb-file is being used. This code is a
667            # mess and should be refactored.
668            #
669            if version.released() and base in rtems_release_urls:
670                url_file = path.basename(local)
671            if base[-1:] != '/':
672                base += '/'
673            next_url = urllib_parse.urljoin(base, url_file)
674            log.trace('url: %s' %(next_url))
675            urls.append(next_url)
676    urls += url.split()
677    log.trace('_url: %s -> %s' % (','.join(urls), local))
678    for url in urls:
679        for dl in downloaders:
680            if url.startswith(dl):
681                if downloaders[dl](url, local, config, opts):
682                    return
683    if _do_download(opts):
684        raise error.general('downloading %s: all paths have failed, giving up' % (url))
Note: See TracBrowser for help on using the repository browser.