recipetool: create: fix error with git tree and no network

When creating a recipe for an existing local git clone, we attempt to
use the fetcher to determine if it supports the SRCREV variable.
Unfortunately running this code does a network check to get the latest
revision as a direct result of us using '${AUTOREV}' as a default value.
If you don't have a network connection this will of course fail. Rather
than have this block creating the recipe, catch the exception and just
guess from the URL.

Ultimately this should probably be fixed in the fetcher but for now this
will at least resolve the issue on this end.

(From OE-Core rev: f7e43f931d7d6019a3b2509b2b2635978fbbae36)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton 2016-09-19 08:08:07 +12:00 committed by Richard Purdie
parent e30276cb18
commit 541c54e301
1 changed files with 10 additions and 4 deletions

View File

@ -336,10 +336,16 @@ def supports_srcrev(uri):
# odd interactions with the urldata cache which lead to errors
localdata.setVar('SRCREV', '${AUTOREV}')
bb.data.update_data(localdata)
fetcher = bb.fetch2.Fetch([uri], localdata)
urldata = fetcher.ud
for u in urldata:
if urldata[u].method.supports_srcrev():
try:
fetcher = bb.fetch2.Fetch([uri], localdata)
urldata = fetcher.ud
for u in urldata:
if urldata[u].method.supports_srcrev():
return True
except bb.fetch2.FetchError as e:
logger.debug('FetchError in supports_srcrev: %s' % str(e))
# Fall back to basic check
if uri.startswith(('git://', 'gitsm://')):
return True
return False