Re: [OE-core] [PATCH v2 1/6] yocto-compat-layer.py: avoid adding layers more than once

2017-06-28 Thread Mark Hatle
On 6/28/17 9:50 AM, Patrick Ohly wrote:
> On Tue, 2017-06-27 at 15:46 -0700, Christopher Larson wrote:
>>
>> On Tue, Jun 27, 2017 at 8:33 AM, Patrick Ohly 
>> wrote:
>> add_layer_dependencies() might get called more than once, or
>> one of
>> the layer dependencies might already be present. The function
>> should
>> not add layers again because doing so can cause warnings like:
>> 
>>   WARNING: Duplicate inclusion
>> for 
>> .../meta-openembedded/meta-oe/conf/distro/include/meta_oe_security_flags.inc 
>> in .../meta-openembedded/meta-oe/conf/layer.conf
>> 
>> Signed-off-by: Patrick Ohly 
>> ---
>>
>> I’m curious about why this isn’t either just calling out to
>> `bitbake-layers add-layer` or using one of the existing functions we
>> have for modifying bblayers, rather than doing its own +=.
> 
> I don't know exactly, Mark implemented it like that. My guess is that
> more control was needed over which layers get added. For example,
> "bitbake-layers add-layer" only adds one layer, but does not recursively
> add layers it depends on. This could be improved of course.
> 

Correct.  Dependencies had to be evaluated for the layers to be added properly.
The existing add-layer does not process dependencies, it simply adds the layer.

The code was also based on the prior version which did it directly and not via
bitbake add-layer.  I did not change that behavior, but simply added the ability
to evaluate the dependency set and include the necessary combinations for the
layer to work properly.

I have no objections to using bitbake-layers add-layer.  (Note, I'm working on
general enhancements that may allow this to process dependencies, but I'm not
sure when I will have that work done.)

--Mark
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v2 1/6] yocto-compat-layer.py: avoid adding layers more than once

2017-06-28 Thread Patrick Ohly
On Tue, 2017-06-27 at 15:46 -0700, Christopher Larson wrote:
> 
> On Tue, Jun 27, 2017 at 8:33 AM, Patrick Ohly 
> wrote:
> add_layer_dependencies() might get called more than once, or
> one of
> the layer dependencies might already be present. The function
> should
> not add layers again because doing so can cause warnings like:
> 
>   WARNING: Duplicate inclusion
> for 
> .../meta-openembedded/meta-oe/conf/distro/include/meta_oe_security_flags.inc 
> in .../meta-openembedded/meta-oe/conf/layer.conf
> 
> Signed-off-by: Patrick Ohly 
> ---
> 
> I’m curious about why this isn’t either just calling out to
> `bitbake-layers add-layer` or using one of the existing functions we
> have for modifying bblayers, rather than doing its own +=.

I don't know exactly, Mark implemented it like that. My guess is that
more control was needed over which layers get added. For example,
"bitbake-layers add-layer" only adds one layer, but does not recursively
add layers it depends on. This could be improved of course.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH v2 1/6] yocto-compat-layer.py: avoid adding layers more than once

2017-06-27 Thread Christopher Larson
On Tue, Jun 27, 2017 at 8:33 AM, Patrick Ohly 
wrote:

> add_layer_dependencies() might get called more than once, or one of
> the layer dependencies might already be present. The function should
> not add layers again because doing so can cause warnings like:
>
>   WARNING: Duplicate inclusion for .../meta-openembedded/meta-oe/conf
> /distro/include/meta_oe_security_flags.inc in
> .../meta-openembedded/meta-oe/conf/layer.conf
>
> Signed-off-by: Patrick Ohly 
> ---
>

I’m curious about why this isn’t either just calling out to `bitbake-layers
add-layer` or using one of the existing functions we have for modifying
bblayers, rather than doing its own +=.
-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH v2 1/6] yocto-compat-layer.py: avoid adding layers more than once

2017-06-27 Thread Patrick Ohly
add_layer_dependencies() might get called more than once, or one of
the layer dependencies might already be present. The function should
not add layers again because doing so can cause warnings like:

  WARNING: Duplicate inclusion for 
.../meta-openembedded/meta-oe/conf/distro/include/meta_oe_security_flags.inc in 
.../meta-openembedded/meta-oe/conf/layer.conf

Signed-off-by: Patrick Ohly 
---
 scripts/lib/compatlayer/__init__.py | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/compatlayer/__init__.py 
b/scripts/lib/compatlayer/__init__.py
index e35f8c0..eaae4e5 100644
--- a/scripts/lib/compatlayer/__init__.py
+++ b/scripts/lib/compatlayer/__init__.py
@@ -4,6 +4,7 @@
 # Released under the MIT license (see COPYING.MIT)
 
 import os
+import re
 import subprocess
 from enum import Enum
 
@@ -189,10 +190,22 @@ def add_layer_dependencies(bblayersconf, layer, layers, 
logger):
 if layer_depends is None:
 return False
 else:
+# Don't add a layer that is already present.
+added = set()
+output = check_command('Getting existing layers failed.', 
'bitbake-layers show-layers').decode('utf-8')
+for layer, path, pri in re.findall(r'^(\S+) +([^\n]*?) +(\d+)$', 
output, re.MULTILINE):
+added.add(path)
+
 for layer_depend in layer_depends:
-logger.info('Adding layer dependency %s' % layer_depend['name'])
+name = layer_depend['name']
+path = layer_depend['path']
+if path in added:
+continue
+else:
+added.add(path)
+logger.info('Adding layer dependency %s' % name)
 with open(bblayersconf, 'a+') as f:
-f.write("\nBBLAYERS += \"%s\"\n" % layer_depend['path'])
+f.write("\nBBLAYERS += \"%s\"\n" % path)
 return True
 
 def add_layer(bblayersconf, layer, layers, logger):
-- 
git-series 0.9.1
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core