summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/ksparser.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-08-21 14:46:23 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-06 14:15:22 +0100
commit181eeebd958552cd4cfd0fbf14f2dd23365a20b7 (patch)
tree9164f19e5cb9663a607c876d38432453f73d0714 /scripts/lib/wic/ksparser.py
parent3c4f891402a4a271bc5d7b5c0f50ee85ba74f984 (diff)
downloadpoky-181eeebd958552cd4cfd0fbf14f2dd23365a20b7.tar.gz
wic: Add 512 Byte alignment to --offset
Allows the --offset argument to use the "s" or "S" suffix to specify that it is reporting the number of 512 byte sectors. This is required for some SoCs where the mask ROM looks for an item at a sector that isn't aligned to a 1KB boundary. (From OE-Core rev: b9296bdeaacc1dce97aac9c9bf0d70555bb36646) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 938595d1dc4abaf5f7f3a7900add3f0492b805d0) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/ksparser.py')
-rw-r--r--scripts/lib/wic/ksparser.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index ac6f427564..76cc55b848 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -51,11 +51,11 @@ class KickStartParser(ArgumentParser):
51 def error(self, message): 51 def error(self, message):
52 raise ArgumentError(None, message) 52 raise ArgumentError(None, message)
53 53
54def sizetype(default): 54def sizetype(default, size_in_bytes=False):
55 def f(arg): 55 def f(arg):
56 """ 56 """
57 Custom type for ArgumentParser 57 Custom type for ArgumentParser
58 Converts size string in <num>[K|k|M|G] format into the integer value 58 Converts size string in <num>[S|s|K|k|M|G] format into the integer value
59 """ 59 """
60 try: 60 try:
61 suffix = default 61 suffix = default
@@ -67,12 +67,20 @@ def sizetype(default):
67 except ValueError: 67 except ValueError:
68 raise ArgumentTypeError("Invalid size: %r" % arg) 68 raise ArgumentTypeError("Invalid size: %r" % arg)
69 69
70
71 if size_in_bytes:
72 if suffix == 's' or suffix == 'S':
73 return size * 512
74 mult = 1024
75 else:
76 mult = 1
77
70 if suffix == "k" or suffix == "K": 78 if suffix == "k" or suffix == "K":
71 return size 79 return size * mult
72 if suffix == "M": 80 if suffix == "M":
73 return size * 1024 81 return size * mult * 1024
74 if suffix == "G": 82 if suffix == "G":
75 return size * 1024 * 1024 83 return size * mult * 1024 * 1024
76 84
77 raise ArgumentTypeError("Invalid size: %r" % arg) 85 raise ArgumentTypeError("Invalid size: %r" % arg)
78 return f 86 return f
@@ -141,7 +149,7 @@ class KickStart():
141 part.add_argument('mountpoint', nargs='?') 149 part.add_argument('mountpoint', nargs='?')
142 part.add_argument('--active', action='store_true') 150 part.add_argument('--active', action='store_true')
143 part.add_argument('--align', type=int) 151 part.add_argument('--align', type=int)
144 part.add_argument('--offset', type=sizetype("K")) 152 part.add_argument('--offset', type=sizetype("K", True))
145 part.add_argument('--exclude-path', nargs='+') 153 part.add_argument('--exclude-path', nargs='+')
146 part.add_argument('--include-path', nargs='+') 154 part.add_argument('--include-path', nargs='+')
147 part.add_argument("--extra-space", type=sizetype("M")) 155 part.add_argument("--extra-space", type=sizetype("M"))