summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/3rdparty
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-02-04 23:45:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-02-08 08:00:27 +0000
commit602d90d57a55f240b81ad286224c5cc39460e3c1 (patch)
treec921f7a66fce1692281ff2ca6f8d2d68e735250a /scripts/lib/wic/3rdparty
parent7c3b9a9a9fe0bcad7d7d3f0af84d6eb8546904f7 (diff)
downloadpoky-602d90d57a55f240b81ad286224c5cc39460e3c1.tar.gz
wic: use kB for the partitions size
Use kB instead of MB for the partition size to get a better granularity. This is needed on some SoC (i.mx, omap) where it is necessary to create partitions as small as 64kB. Keep the backward compatibility by assuming MB when no unit is provided. (From OE-Core rev: 3d4da9186016d54b76ad2fa710646de253f0f063) Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Tested-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl> Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com> Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/3rdparty')
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/commands/partition.py4
-rw-r--r--scripts/lib/wic/3rdparty/pykickstart/options.py21
2 files changed, 22 insertions, 3 deletions
diff --git a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py b/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
index 56b91aa9d9..b564b1a7ab 100644
--- a/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
+++ b/scripts/lib/wic/3rdparty/pykickstart/commands/partition.py
@@ -78,7 +78,7 @@ class FC3_PartData(BaseData):
78 if self.recommended: 78 if self.recommended:
79 retval += " --recommended" 79 retval += " --recommended"
80 if self.size and self.size != 0: 80 if self.size and self.size != 0:
81 retval += " --size=%s" % self.size 81 retval += " --size=%sk" % self.size
82 if hasattr(self, "start") and self.start != 0: 82 if hasattr(self, "start") and self.start != 0:
83 retval += " --start=%s" % self.start 83 retval += " --start=%s" % self.start
84 84
@@ -216,7 +216,7 @@ class FC3_Partition(KickstartCommand):
216 callback=part_cb, nargs=1, type="string") 216 callback=part_cb, nargs=1, type="string")
217 op.add_option("--recommended", dest="recommended", action="store_true", 217 op.add_option("--recommended", dest="recommended", action="store_true",
218 default=False) 218 default=False)
219 op.add_option("--size", dest="size", action="store", type="int", 219 op.add_option("--size", dest="size", action="store", type="size",
220 nargs=1) 220 nargs=1)
221 op.add_option("--start", dest="start", action="store", type="int", 221 op.add_option("--start", dest="start", action="store", type="int",
222 nargs=1) 222 nargs=1)
diff --git a/scripts/lib/wic/3rdparty/pykickstart/options.py b/scripts/lib/wic/3rdparty/pykickstart/options.py
index 341c5d7298..b2d8e3e516 100644
--- a/scripts/lib/wic/3rdparty/pykickstart/options.py
+++ b/scripts/lib/wic/3rdparty/pykickstart/options.py
@@ -143,6 +143,24 @@ def _check_string(option, opt, value):
143 else: 143 else:
144 return value 144 return value
145 145
146def _check_size(option, opt, value):
147 # Former default was MB
148 if (value.isdigit()):
149 return int(value) * 1024L
150
151 mapping = {"opt": opt, "value": value}
152 if (not value[:-1].isdigit()):
153 raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
154
155 size = int(value[:-1])
156 if (value.endswith("k") or value.endswith("K")):
157 return size
158 if (value.endswith("M")):
159 return size * 1024L
160 if (value.endswith("G")):
161 return size * 1024L * 1024L
162 raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
163
146# Creates a new Option class that supports several new attributes: 164# Creates a new Option class that supports several new attributes:
147# - required: any option with this attribute must be supplied or an exception 165# - required: any option with this attribute must be supplied or an exception
148# is thrown 166# is thrown
@@ -169,10 +187,11 @@ class KSOption (Option):
169 ACTIONS = Option.ACTIONS + ("map", "map_extend",) 187 ACTIONS = Option.ACTIONS + ("map", "map_extend",)
170 STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",) 188 STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",)
171 189
172 TYPES = Option.TYPES + ("ksboolean", "string") 190 TYPES = Option.TYPES + ("ksboolean", "string", "size")
173 TYPE_CHECKER = copy(Option.TYPE_CHECKER) 191 TYPE_CHECKER = copy(Option.TYPE_CHECKER)
174 TYPE_CHECKER["ksboolean"] = _check_ksboolean 192 TYPE_CHECKER["ksboolean"] = _check_ksboolean
175 TYPE_CHECKER["string"] = _check_string 193 TYPE_CHECKER["string"] = _check_string
194 TYPE_CHECKER["size"] = _check_size
176 195
177 def _check_required(self): 196 def _check_required(self):
178 if self.required and not self.takes_value(): 197 if self.required and not self.takes_value():