summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/partition.py
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-01-31 12:37:45 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-02 17:37:44 +0000
commit08217a4c80e4abba15270a6a023f0dd1dbadb84c (patch)
tree5e5dc9849e24064ed040a9c243f46a48177ebfd6 /scripts/lib/wic/partition.py
parentd8a89baffbeced00025fb27dce102e11b8193075 (diff)
downloadpoky-08217a4c80e4abba15270a6a023f0dd1dbadb84c.tar.gz
wic: partition: simlify calling plugin methods
Replaced parse_sourceparams function with list comprehension. Used local variables instead of attributes. Moved global variable to the local scope. [YOCTO #10619] (From OE-Core rev: 4adbac84046ff744f1452b5ff4d017d17d2d45e2) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/partition.py')
-rw-r--r--scripts/lib/wic/partition.py53
1 files changed, 25 insertions, 28 deletions
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 49d13277c3..094a8c3bec 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -27,16 +27,10 @@
27import os 27import os
28import tempfile 28import tempfile
29 29
30from wic.utils.oe.misc import msger, parse_sourceparams 30from wic.utils.oe.misc import msger
31from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var 31from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var
32from wic.plugin import pluginmgr 32from wic.plugin import pluginmgr
33 33
34partition_methods = {
35 "do_stage_partition":None,
36 "do_prepare_partition":None,
37 "do_configure_partition":None,
38}
39
40class Partition(): 34class Partition():
41 35
42 def __init__(self, args, lineno): 36 def __init__(self, args, lineno):
@@ -129,9 +123,6 @@ class Partition():
129 Prepare content for individual partitions, depending on 123 Prepare content for individual partitions, depending on
130 partition command parameters. 124 partition command parameters.
131 """ 125 """
132 if self.sourceparams:
133 self.sourceparams_dict = parse_sourceparams(self.sourceparams)
134
135 if not self.source: 126 if not self.source:
136 if not self.size and not self.fixed_size: 127 if not self.size and not self.fixed_size:
137 msger.error("The %s partition has a size of zero. Please " 128 msger.error("The %s partition has a size of zero. Please "
@@ -164,24 +155,30 @@ class Partition():
164 "details on adding a new source plugin." % \ 155 "details on adding a new source plugin." % \
165 (self.source, self.mountpoint)) 156 (self.source, self.mountpoint))
166 157
167 self._source_methods = pluginmgr.get_source_plugin_methods(\ 158 srcparams_dict = {}
168 self.source, partition_methods) 159 if self.sourceparams:
169 self._source_methods["do_configure_partition"](self, self.sourceparams_dict, 160 # Split sourceparams string of the form key1=val1[,key2=val2,...]
170 creator, cr_workdir, 161 # into a dict. Also accepts valueless keys i.e. without =
171 oe_builddir, 162 splitted = self.sourceparams.split(',')
172 bootimg_dir, 163 srcparams_dict = dict(par.split('=') for par in splitted if par)
173 kernel_dir, 164
174 native_sysroot) 165 partition_methods = {
175 self._source_methods["do_stage_partition"](self, self.sourceparams_dict, 166 "do_stage_partition": None,
176 creator, cr_workdir, 167 "do_prepare_partition": None,
177 oe_builddir, 168 "do_configure_partition": None
178 bootimg_dir, kernel_dir, 169 }
179 native_sysroot) 170
180 self._source_methods["do_prepare_partition"](self, self.sourceparams_dict, 171 methods = pluginmgr.get_source_plugin_methods(self.source,
181 creator, cr_workdir, 172 partition_methods)
182 oe_builddir, 173 methods["do_configure_partition"](self, srcparams_dict, creator,
183 bootimg_dir, kernel_dir, rootfs_dir, 174 cr_workdir, oe_builddir, bootimg_dir,
184 native_sysroot) 175 kernel_dir, native_sysroot)
176 methods["do_stage_partition"](self, srcparams_dict, creator,
177 cr_workdir, oe_builddir, bootimg_dir,
178 kernel_dir, native_sysroot)
179 methods["do_prepare_partition"](self, srcparams_dict, creator,
180 cr_workdir, oe_builddir, bootimg_dir,
181 kernel_dir, rootfs_dir, native_sysroot)
185 182
186 # further processing required Partition.size to be an integer, make 183 # further processing required Partition.size to be an integer, make
187 # sure that it is one 184 # sure that it is one