Changeset dc1cd68 in rtems-source-builder


Ignore:
Timestamp:
Dec 14, 2015, 5:09:27 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.9, master
Children:
3ffbfc8
Parents:
00b60d7
git-author:
Chris Johns <chrisj@…> (12/14/15 05:09:27)
git-committer:
Chris Johns <chrisj@…> (12/14/15 05:14:26)
Message:

Download source from RTEMS if a release.

Download source from ftp.rtems.org before the package's URL if
a release.

If a user adds a URL via the command line that is used then the
RTEMS release path then the package's URL.

A user can add --url=file://path/../morepath to have the RSB use
a local cache of source on their hard disk. This is useful if you
need to wipe the RSB and start again. Save away the 'sources' and
'patches' directories to a common directory and provide it with via
the --url option using the 'file://' prefix.

Closes #2482.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source-builder/sb/download.py

    r00b60d7 rdc1cd68  
    514514
    515515def _file_downloader(url, local, config, opts):
    516     try:
    517         path.copy(url[6:], local)
    518     except:
    519         return False
     516    if not path.exists(local):
     517        try:
     518            src = url[7:]
     519            dst = local
     520            log.notice('download: copy %s -> %s' % (src, dst))
     521            path.copy(src, dst)
     522        except:
     523            return False
    520524    return True
    521525
     
    539543        raise error.general('source not found: %s' % (path.host(local)))
    540544    #
    541     # Check if a URL has been provided on the command line.
     545    # Check if a URL has been provided on the command line. If the package is
     546    # release push to the start the RTEMS URL.
    542547    #
    543548    url_bases = opts.urls()
     549    if version.released():
     550        rtems_release_url = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources')
     551        log.trace('release url: %s' % (rtems_release_url))
     552        #
     553        # If the URL being fetched is under the release path do not add the
     554        # sources release path because it is already there.
     555        #
     556        if not url.startswith(rtems_release_url):
     557            if url_bases is None:
     558                url_bases = [rtems_release_url]
     559            else:
     560                url_bases.append(rtems_release_url)
    544561    urls = []
    545562    if url_bases is not None:
     563        #
     564        # Split up the URL we are being asked to download.
     565        #
     566        url_path = urlparse.urlsplit(url)[2]
     567        slash = url_path.rfind('/')
     568        if slash < 0:
     569            url_file = url_path
     570        else:
     571            url_file = url_path[slash + 1:]
     572        log.trace('url_file: %s' %(url_file))
    546573        for base in url_bases:
    547574            if base[-1:] != '/':
    548575                base += '/'
    549             url_path = urlparse.urlsplit(url)[2]
    550             slash = url_path.rfind('/')
    551             if slash < 0:
    552                 url_file = url_path
    553             else:
    554                 url_file = url_path[slash + 1:]
    555             urls.append(urlparse.urljoin(base, url_file))
     576            next_url = urlparse.urljoin(base, url_file)
     577            log.trace('url: %s' %(next_url))
     578            urls.append(next_url)
    556579    urls += url.split()
    557580    log.trace('_url: %s -> %s' % (','.join(urls), local))
Note: See TracChangeset for help on using the changeset viewer.