]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: add --system-id wks option
authorEd Bartosh <ed.bartosh@linux.intel.com>
Fri, 22 Apr 2016 09:31:59 +0000 (12:31 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 29 Apr 2016 06:53:57 +0000 (07:53 +0100)
Added new option --system-id to wks parser. The option
will be used to set partition system id.

[YOCTO #9096]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/lib/wic/ksparser.py

index 8c3f80882cbe5c139820eadbdfed0349e436a355..10d0d7c1155e6788127667557096944ded076003 100644 (file)
@@ -92,6 +92,24 @@ def cannedpathtype(arg):
         raise ArgumentTypeError("file not found: %s" % arg)
     return result
 
+def systemidtype(arg):
+    """
+    Custom type for ArgumentParser
+    Checks if the argument sutisfies system id requirements,
+    i.e. if it's one byte long integer > 0
+    """
+    error = "Invalid system type: %s. must be hex "\
+            "between 0x1 and 0xFF" % arg
+    try:
+        result = int(arg, 16)
+    except ValueError:
+        raise ArgumentTypeError(error)
+
+    if result <= 0 or result > 0xff:
+        raise ArgumentTypeError(error)
+
+    return arg
+
 class KickStart(object):
     """"Kickstart parser implementation."""
 
@@ -121,6 +139,7 @@ class KickStart(object):
         part.add_argument('--size', type=sizetype, default=0)
         part.add_argument('--source')
         part.add_argument('--sourceparams')
+        part.add_argument('--system-id', type=systemidtype)
         part.add_argument('--use-uuid', action='store_true')
         part.add_argument('--uuid')