Skip to contentSkip to conversation

yocto_kernel: check current items before add a new one

PATCH New Ning Zhang 1 participant 2 messages May 29, 2013

lore
Share & tools
lore

Ning Zhang

author
#0 lore raw

v2 cover yocto_kernel: check current items before add a new one

The following changes since commit 676fd3f394a0c0576b63c77ed2184bf5f42c29b6:

dropbear: a fix for hang in dropbearkey, built for x32 (2013-05-24 14:14:49 +0100)

are available in the git repository at:

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

Ning Zhang (1):
yocto_kernel: check current items before add a new one

 scripts/lib/bsp/kernel.py |   32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v2 1/1 yocto_kernel: check current items before add a new one

When use "yocto-kernel config add" to add the same config many times, all of these are list when use "yocto-kernel config list" to check.

This fix modify routine yocto_kernel_config_add, if the new added components already exist in current configuration, just igore them. Now, one config could only be added one time.

[YOCTO #4558]

---
 scripts/lib/bsp/kernel.py |   32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
scripts/lib/bsp/kernel.py +21 -11
index fc1e6bd..9ed6e94 100644
@@ -239,22 +239,32 @@ def yocto_kernel_config_add(scripts_path, machine, config_items):
     user-defined config fragment [${machine}-user-config.cfg].
     """
     new_items = []
+    dup_items = []
+
+    cur_items = read_config_items(scripts_path, machine)
 
     for item in config_items:
         if not item.startswith("CONFIG") or (not "=y" in item and not "=m" in item):
             print "Invalid config item (%s), exiting" % item
             sys.exit(1)
-        new_items.append(item)
-
-    cur_items = read_config_items(scripts_path, machine)
-    cur_items.extend(new_items)
-
-    write_config_items(scripts_path, machine, cur_items)
-
-    print "Added items:"
-    for n in new_items:
-        print "\t%s" % n
-
+        if item not in cur_items and item not in new_items:
+            new_items.append(item)
+        else:
+            dup_items.append(item)
+
+    if len(new_items) > 0:
+        cur_items.extend(new_items)
+        write_config_items(scripts_path, machine, cur_items)
+        print "Added item%s:" % ("" if len(new_items)==1 else "s")
+        for n in new_items:
+            print "\t%s" % n
+
+    if len(dup_items) > 0:
+        output="Below item%s already exist%s in current configuration, ignore %s" % \
+            (("","s", "it") if len(dup_items)==1 else ("s", "", "them" ))
+        print output
+        for n in dup_items:
+            print "\t%s" % n
 
 def find_current_kernel(bsp_layer, machine):
     """
Signature · 1 line
1.7.9.5