mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
sb: Add support for the standard git protocols for the %source command.
The source selector 'git://' now supports a protocol option that lets you set the specific protocol git is to use to access a remote repository.
This commit is contained in:
@@ -1413,6 +1413,8 @@ the repository via the URL by appending options and arguments to the GIT
|
|||||||
path. The options are delimited by `?` and option arguments are delimited from
|
path. The options are delimited by `?` and option arguments are delimited from
|
||||||
the options with `=`. The options are:
|
the options with `=`. The options are:
|
||||||
|
|
||||||
|
`protocol`:: Use a specific protocol. The supported values are _ssh_, _git_,
|
||||||
|
_http_, _https_, _ftp_, _ftps_, _rsync_, and _none_.
|
||||||
`branch`:: Checkout the specified branch.
|
`branch`:: Checkout the specified branch.
|
||||||
`pull`:: Perform a pull to update the repository.
|
`pull`:: Perform a pull to update the repository.
|
||||||
`fetch`:: Perform a fetch to get any remote updates.
|
`fetch`:: Perform a fetch to get any remote updates.
|
||||||
@@ -1428,6 +1430,10 @@ a hard reset. You can select specific branches and apply patches. The
|
|||||||
repository is cleaned up before each build to avoid various version control
|
repository is cleaned up before each build to avoid various version control
|
||||||
errors that can arise.
|
errors that can arise.
|
||||||
|
|
||||||
|
The protocol option lets you set a specific protocol. The 'git://' prefix used
|
||||||
|
by the RSB to select a git repository can be removed using _none_ or replaced
|
||||||
|
with one of the standard git protcols.
|
||||||
|
|
||||||
CVS
|
CVS
|
||||||
^^^
|
^^^
|
||||||
|
|
||||||
|
@@ -201,7 +201,7 @@ def parse_url(url, pathkey, config, opts):
|
|||||||
source['url'] = url
|
source['url'] = url
|
||||||
colon = url.find(':')
|
colon = url.find(':')
|
||||||
if url[colon + 1:colon + 3] != '//':
|
if url[colon + 1:colon + 3] != '//':
|
||||||
raise error.general('malforned URL: %s' % (url))
|
raise error.general('malforned URL (no protocol prefix): %s' % (url))
|
||||||
source['path'] = url[:colon + 3] + path.dirname(url[colon + 3:])
|
source['path'] = url[:colon + 3] + path.dirname(url[colon + 3:])
|
||||||
source['file'] = path.basename(url)
|
source['file'] = path.basename(url)
|
||||||
source['name'], source['ext'] = path.splitext(source['file'])
|
source['name'], source['ext'] = path.splitext(source['file'])
|
||||||
@@ -310,9 +310,27 @@ def _http_downloader(url, local, config, opts):
|
|||||||
return not failed
|
return not failed
|
||||||
|
|
||||||
def _git_downloader(url, local, config, opts):
|
def _git_downloader(url, local, config, opts):
|
||||||
|
repo = git.repo(local, opts, config.macros)
|
||||||
rlp = os.path.relpath(path.host(local))
|
rlp = os.path.relpath(path.host(local))
|
||||||
us = url.split('?')
|
us = url.split('?')
|
||||||
repo = git.repo(local, opts, config.macros)
|
#
|
||||||
|
# Handle the various git protocols.
|
||||||
|
#
|
||||||
|
# remove 'git' from 'git://xxxx/xxxx?protocol=...'
|
||||||
|
#
|
||||||
|
url_base = us[0][len('git'):]
|
||||||
|
for a in us[1:]:
|
||||||
|
_as = a.split('=')
|
||||||
|
if _as[0] == 'protocol':
|
||||||
|
if len(_as) != 2:
|
||||||
|
raise error.general('invalid git protocol option: %s' % (_as))
|
||||||
|
if _as[1] == 'none':
|
||||||
|
# remove the rest of the protocol header leaving nothing.
|
||||||
|
us[0] = url_base[len('://'):]
|
||||||
|
else:
|
||||||
|
if _as[1] not in ['ssh', 'git', 'http', 'https', 'ftp', 'ftps', 'rsync']:
|
||||||
|
raise error.general('unknown git protocol: %s' % (_as[1]))
|
||||||
|
us[0] = _as[1] + url_base
|
||||||
if not repo.valid():
|
if not repo.valid():
|
||||||
log.notice('git: clone: %s -> %s' % (us[0], rlp))
|
log.notice('git: clone: %s -> %s' % (us[0], rlp))
|
||||||
if not opts.dry_run():
|
if not opts.dry_run():
|
||||||
@@ -350,6 +368,10 @@ def _git_downloader(url, local, config, opts):
|
|||||||
log.notice('git: reset: %s' % (us[0]))
|
log.notice('git: reset: %s' % (us[0]))
|
||||||
if not opts.dry_run():
|
if not opts.dry_run():
|
||||||
repo.reset(arg)
|
repo.reset(arg)
|
||||||
|
elif _as[0] == 'protocol':
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise error.general('invalid git option: %s' % (_as))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _cvs_downloader(url, local, config, opts):
|
def _cvs_downloader(url, local, config, opts):
|
||||||
|
@@ -57,6 +57,9 @@ class repo:
|
|||||||
self.macros = opts.defaults
|
self.macros = opts.defaults
|
||||||
else:
|
else:
|
||||||
self.macros = macros
|
self.macros = macros
|
||||||
|
if self.macros is None:
|
||||||
|
self.git = 'git'
|
||||||
|
else:
|
||||||
self.git = self.macros.expand('%{__git}')
|
self.git = self.macros.expand('%{__git}')
|
||||||
|
|
||||||
def git_version(self):
|
def git_version(self):
|
||||||
|
Reference in New Issue
Block a user