bitbake: toaster: buildinfohelper fix _get_layer_version_for_dependency
This function is simplified by not trying to handle replacing the regex and just compiling and using it for matching. - Fix typo in logger output with undefined variable - Fix pyflake errors (Bitbake rev: ea298ece8d678889cd5bcde46e00545e9a73edb9) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
439f3da1a1
commit
6dba0281e1
|
@ -965,9 +965,10 @@ class BuildInfoHelper(object):
|
||||||
return task_information
|
return task_information
|
||||||
|
|
||||||
def _get_layer_version_for_dependency(self, pathRE):
|
def _get_layer_version_for_dependency(self, pathRE):
|
||||||
""" Returns the layer in the toaster db that has a full regex match to the pathRE.
|
""" Returns the layer in the toaster db that has a full regex
|
||||||
pathRE - the layer path passed as a regex in the event. It is created in
|
match to the pathRE. pathRE - the layer path passed as a regex in the
|
||||||
cooker.py as a collection for the layer priorities.
|
event. It is created in cooker.py as a collection for the layer
|
||||||
|
priorities.
|
||||||
"""
|
"""
|
||||||
self._ensure_build()
|
self._ensure_build()
|
||||||
|
|
||||||
|
@ -975,19 +976,26 @@ class BuildInfoHelper(object):
|
||||||
assert isinstance(layer_version, Layer_Version)
|
assert isinstance(layer_version, Layer_Version)
|
||||||
return len(layer_version.local_path)
|
return len(layer_version.local_path)
|
||||||
|
|
||||||
# we don't care if we match the trailing slashes
|
# Our paths don't append a trailing slash
|
||||||
p = re.compile(re.sub("/[^/]*?$","",pathRE))
|
if pathRE.endswith("/"):
|
||||||
# Heuristics: we always match recipe to the deepest layer path in the discovered layers
|
pathRE = pathRE[:-1]
|
||||||
for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_sort_longest_path):
|
|
||||||
if p.fullmatch(lvo.local_path):
|
p = re.compile(pathRE)
|
||||||
|
# Heuristics: we always match recipe to the deepest layer path in
|
||||||
|
# the discovered layers
|
||||||
|
for lvo in sorted(self.orm_wrapper.layer_version_objects,
|
||||||
|
reverse=True, key=_sort_longest_path):
|
||||||
|
if p.fullmatch(os.path.abspath(lvo.local_path)):
|
||||||
return lvo
|
return lvo
|
||||||
if lvo.layer.local_source_dir:
|
if lvo.layer.local_source_dir:
|
||||||
if p.fullmatch(lvo.layer.local_source_dir):
|
if p.fullmatch(os.path.abspath(lvo.layer.local_source_dir)):
|
||||||
return lvo
|
return lvo
|
||||||
#if we get here, we didn't read layers correctly; dump whatever information we have on the error log
|
|
||||||
logger.warning("Could not match layer dependency for path %s : %s", path, self.orm_wrapper.layer_version_objects)
|
|
||||||
|
|
||||||
|
|
||||||
|
# if we get here, we didn't read layers correctly;
|
||||||
|
# dump whatever information we have on the error log
|
||||||
|
logger.warning("Could not match layer dependency for path %s : %s",
|
||||||
|
pathRE,
|
||||||
|
self.orm_wrapper.layer_version_objects)
|
||||||
|
|
||||||
def _get_layer_version_for_path(self, path):
|
def _get_layer_version_for_path(self, path):
|
||||||
self._ensure_build()
|
self._ensure_build()
|
||||||
|
|
Loading…
Reference in New Issue