Now the logic is: Use options.layer_type if specified, guess if not, default to 'M'.
Note choices=['A', 'B', 'S', 'D', 'M', ''], the '' is for default='', we can't use default='M' here, otherwise we don't know whether the 'M' is specified by user or not, we don't guess if it is specified by user, otherwise, guess. Signed-off-by: Robert Yang <liezhi.y...@windriver.com> --- layerindex/tools/import_layer.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py index 2413cff..0d501f6 100755 --- a/layerindex/tools/import_layer.py +++ b/layerindex/tools/import_layer.py @@ -189,6 +189,10 @@ def main(): parser.add_option("-s", "--subdir", help = "Specify subdirectory", action="store", dest="subdir") + parser.add_option("-t", "--type", + help = "Specify layer type. A: Base, B: Machine(BSP), S: Software, D: Distribution, M: Miscellaneous", + choices=['A', 'B', 'S', 'D', 'M', ''], + action="store", dest="layer_type", default='') parser.add_option("-n", "--dry-run", help = "Don't write any data back to the database", action="store_true", dest="dryrun") @@ -263,7 +267,6 @@ def main(): layer = LayerItem() layer.name = layer_name layer.status = 'P' - layer.layer_type = 'M' layer.summary = 'tempvalue' layer.description = layer.summary @@ -349,11 +352,18 @@ def main(): logger.info('Creating layer %s' % layer.name) - # Guess layer type - if glob.glob(os.path.join(layerdir, 'conf/distro/*.conf')): + # Guess layer type if not specified + if options.layer_type: + layer.layer_type = options.layer_type + elif layer.name in ['openembedded-core', 'meta-oe']: + layer.layer_type = 'A' + elif glob.glob(os.path.join(layerdir, 'conf/distro/*.conf')): layer.layer_type = 'D' elif glob.glob(os.path.join(layerdir, 'conf/machine/*.conf')): layer.layer_type = 'B' + else: + layer.layer_type = 'M' + layer.save() layerbranch = LayerBranch() layerbranch.layer = layer @@ -411,11 +421,9 @@ def main(): if layer.name == 'openembedded-core': layer.summary = 'Core metadata' - layer.layer_type = 'A' elif layer.name == 'meta-oe': layer.summary = 'Additional shared OE metadata' layer.description = layer.summary - layer.layer_type = 'A' if maintainers: maint_re = re.compile(r'^"?([^"@$<>]+)"? *<([^<> ]+)>[ -]*(.+)?$') -- 2.7.4 -- _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto