mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
recipetool: create: add new optional process_url callback for plugins
Add a new process_url callback that plugins can optionally implement if they which to handle url. Plugins can implement this callback for example, to: * transform the url * add special variables using extravalues * add extra classes * ... If a plugin handles the url, it must append 'url' to the handled list and must return the fetchuri No functional changes expected for plugins non implementing this optional callback (From OE-Core rev: 3e5ce351e7dbe283562bf1db1f2ce3b121c49b53) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
86b9510bd3
commit
6c06fb0a43
|
@ -423,6 +423,36 @@ def create_recipe(args):
|
|||
storeTagName = ''
|
||||
pv_srcpv = False
|
||||
|
||||
handled = []
|
||||
classes = []
|
||||
|
||||
# Find all plugins that want to register handlers
|
||||
logger.debug('Loading recipe handlers')
|
||||
raw_handlers = []
|
||||
for plugin in plugins:
|
||||
if hasattr(plugin, 'register_recipe_handlers'):
|
||||
plugin.register_recipe_handlers(raw_handlers)
|
||||
# Sort handlers by priority
|
||||
handlers = []
|
||||
for i, handler in enumerate(raw_handlers):
|
||||
if isinstance(handler, tuple):
|
||||
handlers.append((handler[0], handler[1], i))
|
||||
else:
|
||||
handlers.append((handler, 0, i))
|
||||
handlers.sort(key=lambda item: (item[1], -item[2]), reverse=True)
|
||||
for handler, priority, _ in handlers:
|
||||
logger.debug('Handler: %s (priority %d)' % (handler.__class__.__name__, priority))
|
||||
setattr(handler, '_devtool', args.devtool)
|
||||
handlers = [item[0] for item in handlers]
|
||||
|
||||
fetchuri = None
|
||||
for handler in handlers:
|
||||
if hasattr(handler, 'process_url'):
|
||||
ret = handler.process_url(args, classes, handled, extravalues)
|
||||
if 'url' in handled and ret:
|
||||
fetchuri = ret
|
||||
break
|
||||
|
||||
if os.path.isfile(source):
|
||||
source = 'file://%s' % os.path.abspath(source)
|
||||
|
||||
|
@ -431,7 +461,8 @@ def create_recipe(args):
|
|||
if re.match(r'https?://github.com/[^/]+/[^/]+/archive/.+(\.tar\..*|\.zip)$', source):
|
||||
logger.warning('github archive files are not guaranteed to be stable and may be re-generated over time. If the latter occurs, the checksums will likely change and the recipe will fail at do_fetch. It is recommended that you point to an actual commit or tag in the repository instead (using the repository URL in conjunction with the -S/--srcrev option).')
|
||||
# Fetch a URL
|
||||
fetchuri = reformat_git_uri(urldefrag(source)[0])
|
||||
if not fetchuri:
|
||||
fetchuri = reformat_git_uri(urldefrag(source)[0])
|
||||
if args.binary:
|
||||
# Assume the archive contains the directory structure verbatim
|
||||
# so we need to extract to a subdirectory
|
||||
|
@ -638,8 +669,6 @@ def create_recipe(args):
|
|||
# We'll come back and replace this later in handle_license_vars()
|
||||
lines_before.append('##LICENSE_PLACEHOLDER##')
|
||||
|
||||
handled = []
|
||||
classes = []
|
||||
|
||||
# FIXME This is kind of a hack, we probably ought to be using bitbake to do this
|
||||
pn = None
|
||||
|
@ -718,25 +747,6 @@ def create_recipe(args):
|
|||
if args.npm_dev:
|
||||
extravalues['NPM_INSTALL_DEV'] = 1
|
||||
|
||||
# Find all plugins that want to register handlers
|
||||
logger.debug('Loading recipe handlers')
|
||||
raw_handlers = []
|
||||
for plugin in plugins:
|
||||
if hasattr(plugin, 'register_recipe_handlers'):
|
||||
plugin.register_recipe_handlers(raw_handlers)
|
||||
# Sort handlers by priority
|
||||
handlers = []
|
||||
for i, handler in enumerate(raw_handlers):
|
||||
if isinstance(handler, tuple):
|
||||
handlers.append((handler[0], handler[1], i))
|
||||
else:
|
||||
handlers.append((handler, 0, i))
|
||||
handlers.sort(key=lambda item: (item[1], -item[2]), reverse=True)
|
||||
for handler, priority, _ in handlers:
|
||||
logger.debug('Handler: %s (priority %d)' % (handler.__class__.__name__, priority))
|
||||
setattr(handler, '_devtool', args.devtool)
|
||||
handlers = [item[0] for item in handlers]
|
||||
|
||||
# Apply the handlers
|
||||
if args.binary:
|
||||
classes.append('bin_package')
|
||||
|
|
Loading…
Reference in New Issue
Block a user