All of lore.kernel.org
 help / color / mirror / Atom feed
* [layerindex-web][V2 PATCH 0/1] import_layer.py: add -t option for layer_type
@ 2018-09-11  8:48 Robert Yang
  2018-09-11  8:48 ` [layerindex-web][V2 PATCH 1/1] " Robert Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Yang @ 2018-09-11  8:48 UTC (permalink / raw)
  To: paul.eggleton; +Cc: yocto

* V2:
  - Make -t option use LAYER_TYPE_CHOICES from models.py.

* V1:
  - Initial version

// Robert

The following changes since commit ac32edb5bdbdef30ccf3ef49af0977246571abaa:

  TODO: add some more items (2018-09-06 11:08:43 +1200)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib rbt/li
  http://git.pokylinux.org/cgit.cgi//log/?h=rbt/li

Robert Yang (1):
  import_layer.py: add -t option for layer_type

 layerindex/tools/import_layer.py | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [layerindex-web][V2 PATCH 1/1] import_layer.py: add -t option for layer_type
  2018-09-11  8:48 [layerindex-web][V2 PATCH 0/1] import_layer.py: add -t option for layer_type Robert Yang
@ 2018-09-11  8:48 ` Robert Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Yang @ 2018-09-11  8:48 UTC (permalink / raw)
  To: paul.eggleton; +Cc: yocto

Now the logic is:
Use options.layer_type if specified, and 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 is the default value, we don't guess if it is specified by user,
otherwise, guess.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 layerindex/tools/import_layer.py | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py
index 2413cff..60986e0 100755
--- a/layerindex/tools/import_layer.py
+++ b/layerindex/tools/import_layer.py
@@ -178,6 +178,22 @@ def get_github_layerinfo(layer_url, username = None, password = None):
 
     return (json_data, owner_json_data)
 
+def get_layer_type_choices():
+    """
+    Return help string and choices for --type.
+    """
+    from layerindex.models import LayerItem
+    help_str = "Specify layer type."
+    choices = []
+    for i in LayerItem.LAYER_TYPE_CHOICES:
+        key, description = i
+        help_str += ' %s: %s,' % (key, description)
+        choices.append(key)
+
+    help_str = help_str.rstrip(',')
+    choices.append('')
+
+    return (help_str, choices)
 
 def main():
     valid_layer_name = re.compile('[-\w]+$')
@@ -186,9 +202,16 @@ def main():
         usage = """
     %prog [options] <url> [name]""")
 
+    utils.setup_django()
+    layer_type_help, layer_type_choices = get_layer_type_choices()
+
     parser.add_option("-s", "--subdir",
             help = "Specify subdirectory",
             action="store", dest="subdir")
+    parser.add_option("-t", "--type",
+            help = layer_type_help,
+            choices = layer_type_choices,
+            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")
@@ -238,7 +261,6 @@ def main():
         github_login = None
         github_password = None
 
-    utils.setup_django()
     import settings
     from layerindex.models import LayerItem, LayerBranch, LayerDependency, LayerMaintainer
     from django.db import transaction
@@ -263,7 +285,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 +370,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 +439,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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-11  8:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-11  8:48 [layerindex-web][V2 PATCH 0/1] import_layer.py: add -t option for layer_type Robert Yang
2018-09-11  8:48 ` [layerindex-web][V2 PATCH 1/1] " Robert Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.