recipeparse: handle recipes at root of repository

You'd think this is very unlikely to happen, but back in
meta-openembedded commit 415e213ad75ec9a93171c963395a1c4b92c6233b and
the commits preceding it, a recipe was added to the root of the
repository and then moved into place, and os.path.relpath() does not
like to be called with a blank path and thus raises an exception. To
avoid the exception, get the relative path to the filename and then chop
that off instead of the other way around.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-09-03 16:07:58 +12:00
parent f774a31eb4
commit effd76af7d

View File

@ -146,7 +146,7 @@ def detect_file_type(path, subdir_start):
if typename in ['recipe', 'bbappend', 'incfile']:
if subdir_start:
filepath = os.path.relpath(os.path.dirname(path), subdir_start)
filepath = os.path.dirname(os.path.relpath(path, subdir_start))
else:
filepath = os.path.dirname(path)
return (typename, filepath, os.path.basename(path))