diff options
author | Chris Johns <chrisj@rtems.org> | 2014-02-04 18:23:08 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2014-02-04 18:23:08 +1100 |
commit | 53b918e6981dc3a6c5a63324ffe64cb5df6d6708 (patch) | |
tree | bd6e3d2629892fb351f1e551aceadd34d46f0423 /source-builder/sb/download.py | |
parent | sb: Add submodule support to the git support. (diff) | |
download | rtems-source-builder-53b918e6981dc3a6c5a63324ffe64cb5df6d6708.tar.bz2 |
sb: Fix downloader url parsing and add submodule git support.
Split the URL by line breaks into separate requests.
With git reset the repo with each run. First perform a hard reset
to remove any local patches and then switch back to master incase
the repo was left on a branch or a detached head.
Diffstat (limited to 'source-builder/sb/download.py')
-rw-r--r-- | source-builder/sb/download.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/source-builder/sb/download.py b/source-builder/sb/download.py index 0aadb80..9259f51 100644 --- a/source-builder/sb/download.py +++ b/source-builder/sb/download.py @@ -203,9 +203,14 @@ def _git_downloader(url, local, config, opts): log.notice('git: clone: %s -> %s' % (us[0], rlp)) if not opts.dry_run(): repo.clone(us[0], local) + else: + repo.reset('--hard') + repo.checkout('master') for a in us[1:]: _as = a.split('=') - if _as[0] == 'branch': + if _as[0] == 'branch' or _as[0] == 'checkout': + if len(_as) != 2: + raise error.general('invalid git branch/checkout: %s' % (_as)) log.notice('git: checkout: %s => %s' % (us[0], _as[1])) if not opts.dry_run(): repo.checkout(_as[1]) @@ -213,6 +218,12 @@ def _git_downloader(url, local, config, opts): log.notice('git: pull: %s' % (us[0])) if not opts.dry_run(): repo.pull() + elif _as[0] == 'submodule': + if len(_as) != 2: + raise error.general('invalid git submodule: %s' % (_as)) + log.notice('git: submodule: %s <= %s' % (us[0], _as[1])) + if not opts.dry_run(): + repo.submodule(_as[1]) elif _as[0] == 'fetch': log.notice('git: fetch: %s -> %s' % (us[0], rlp)) if not opts.dry_run(): @@ -296,7 +307,7 @@ def get_file(url, local, opts, config): if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # - # Check if a URL hasbeen provided on the command line. + # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] @@ -311,12 +322,12 @@ def get_file(url, local, opts, config): else: url_file = url_path[slash + 1:] urls.append(urlparse.urljoin(base, url_file)) - urls.append(url) + urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) + for url in urls: + for dl in downloaders: + if url.startswith(dl): + if downloaders[dl](url, local, config, opts): + return if not opts.dry_run(): - for url in urls: - for dl in downloaders: - if url.startswith(dl): - if downloaders[dl](url, local, config, opts): - return raise error.general('downloading %s: all paths have failed, giving up' % (url)) |