* [PATCH 0/1] toaster: buildinfohelper Handle regex pattern paths
@ 2016-10-24 20:53 brian avery
2016-10-24 20:53 ` [PATCH 1/1] toaster: buildinfohelper brian avery
0 siblings, 1 reply; 3+ messages in thread
From: brian avery @ 2016-10-24 20:53 UTC (permalink / raw)
To: toaster; +Cc: brian avery
We were presuming that all the layer dependency information was of the
form "^/path/to/layer" so we were just stripping the leading "^" off of
the layer information when we were matching the layer priorities to the
toaster database. This patch splits out the priorities layer match which
gets a regex from the task/recipe match which gets a path.
In V3, I added a doc string to explain pathRE and used Michael's name for the
sort function.
avail on poky-contrib/bavery/toaster/mentor-regex-layerV3
-bavery
The following changes since commit ef627ab364d52fe19994c94c1a78fbe21620a32c:
local.conf.sample.extended: remove RM_OLD_IMAGE (2016-10-19 17:07:41 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib bavery/toaster/mentor-regex-layerV3
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/toaster/mentor-regex-layerV3
brian avery (1):
toaster: buildinfohelper
lib/bb/ui/buildinfohelper.py | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
--
1.9.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] toaster: buildinfohelper
2016-10-24 20:53 [PATCH 0/1] toaster: buildinfohelper Handle regex pattern paths brian avery
@ 2016-10-24 20:53 ` brian avery
2016-10-25 13:41 ` Michael Wood
0 siblings, 1 reply; 3+ messages in thread
From: brian avery @ 2016-10-24 20:53 UTC (permalink / raw)
To: toaster; +Cc: brian avery
We were presuming that all the layer dependency information was of the
form "^/path/to/layer" to we were just stripping the leading "^" off of
the layer information when we were matching the layer priorities to the
toaster database. This patch splits out the priorities layer match which
gets a regex from the task/recipe match which is gets a path.
Signed-off-by: brian avery <brian.avery@intel.com>
---
lib/bb/ui/buildinfohelper.py | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 5b69660..3ddcb2a 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -982,6 +982,31 @@ class BuildInfoHelper(object):
pass
return task_information
+ def _get_layer_version_for_dependency(self, pathRE):
+ """ Returns the layer in the toaster db that has a full regex match to the pathRE.
+ pathRE - the layer path passed as a regex in the event. It is created in
+ cooker.py as a collection for the layer priorities.
+ """
+ self._ensure_build()
+
+ def _sort_longest_path(layer_version):
+ assert isinstance(layer_version, Layer_Version)
+ return len(layer_version.local_path)
+
+ # we don't care if we match the trailing slashes
+ p = re.compile(re.sub("/[^/]*?$","",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(lvo.local_path):
+ return lvo
+ if lvo.layer.local_source_dir:
+ if p.fullmatch(lvo.layer.local_source_dir):
+ 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)
+
+
+
def _get_layer_version_for_path(self, path):
self._ensure_build()
@@ -1372,7 +1397,7 @@ class BuildInfoHelper(object):
if 'layer-priorities' in event._depgraph.keys():
for lv in event._depgraph['layer-priorities']:
(_, path, _, priority) = lv
- layer_version_obj = self._get_layer_version_for_path(path[1:]) # paths start with a ^
+ layer_version_obj = self._get_layer_version_for_dependency(path)
assert layer_version_obj is not None
layer_version_obj.priority = priority
layer_version_obj.save()
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] toaster: buildinfohelper
2016-10-24 20:53 ` [PATCH 1/1] toaster: buildinfohelper brian avery
@ 2016-10-25 13:41 ` Michael Wood
0 siblings, 0 replies; 3+ messages in thread
From: Michael Wood @ 2016-10-25 13:41 UTC (permalink / raw)
To: toaster
On 24/10/16 21:53, brian avery wrote:
> We were presuming that all the layer dependency information was of the
> form "^/path/to/layer" to we were just stripping the leading "^" off of
> the layer information when we were matching the layer priorities to the
> toaster database. This patch splits out the priorities layer match which
> gets a regex from the task/recipe match which is gets a path.
>
> Signed-off-by: brian avery <brian.avery@intel.com>
> ---
> lib/bb/ui/buildinfohelper.py | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
> index 5b69660..3ddcb2a 100644
> --- a/lib/bb/ui/buildinfohelper.py
> +++ b/lib/bb/ui/buildinfohelper.py
> @@ -982,6 +982,31 @@ class BuildInfoHelper(object):
> pass
> return task_information
>
> + def _get_layer_version_for_dependency(self, pathRE):
> + """ Returns the layer in the toaster db that has a full regex match to the pathRE.
> + pathRE - the layer path passed as a regex in the event. It is created in
> + cooker.py as a collection for the layer priorities.
> + """
> + self._ensure_build()
> +
> + def _sort_longest_path(layer_version):
> + assert isinstance(layer_version, Layer_Version)
> + return len(layer_version.local_path)
> +
> + # we don't care if we match the trailing slashes
> + p = re.compile(re.sub("/[^/]*?$","",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(lvo.local_path):
> + return lvo
> + if lvo.layer.local_source_dir:
> + if p.fullmatch(lvo.layer.local_source_dir):
> + 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)
> +
> +
> +
> def _get_layer_version_for_path(self, path):
> self._ensure_build()
>
> @@ -1372,7 +1397,7 @@ class BuildInfoHelper(object):
> if 'layer-priorities' in event._depgraph.keys():
> for lv in event._depgraph['layer-priorities']:
> (_, path, _, priority) = lv
> - layer_version_obj = self._get_layer_version_for_path(path[1:]) # paths start with a ^
> + layer_version_obj = self._get_layer_version_for_dependency(path)
> assert layer_version_obj is not None
> layer_version_obj.priority = priority
> layer_version_obj.save()
Thanks, do you think this should be submitted for morty and master?
Michael
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-25 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24 20:53 [PATCH 0/1] toaster: buildinfohelper Handle regex pattern paths brian avery
2016-10-24 20:53 ` [PATCH 1/1] toaster: buildinfohelper brian avery
2016-10-25 13:41 ` Michael Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).