summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2017-01-31 03:43:56 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-02-02 17:37:44 +0000
commitf36c70b0679251cfd5706f163eb6bf2f1e9ac335 (patch)
tree9087b983350a53830c38d05efe515deb0ddfe1ea /scripts/lib/wic
parent2db161f1c0df9ed5047804c396bc6ebfdb0840ef (diff)
downloadpoky-f36c70b0679251cfd5706f163eb6bf2f1e9ac335.tar.gz
wic: improve naming in direct_plugin classes
Synchronized attribure names in DirectImageCreator and DirectPlugin for better readability. Simplified code, removed unneeded global variable disk_methods. (From OE-Core rev: b87b9ef84791615636424a224f74386a4aa0c2fa) 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')
-rw-r--r--scripts/lib/wic/plugins/imager/direct_plugin.py62
1 files changed, 22 insertions, 40 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py
index c6df5fbb7d..48588dbc55 100644
--- a/scripts/lib/wic/plugins/imager/direct_plugin.py
+++ b/scripts/lib/wic/plugins/imager/direct_plugin.py
@@ -58,50 +58,33 @@ class DirectPlugin(ImagerPlugin):
58 """ 58 """
59 Create direct image, called from creator as 'direct' cmd 59 Create direct image, called from creator as 'direct' cmd
60 """ 60 """
61 if len(args) != 8: 61 native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, ksconf, \
62 raise errors.Usage("Extra arguments given") 62 outdir, oe_builddir, compressor = args
63
64 native_sysroot = args[0]
65 kernel_dir = args[1]
66 bootimg_dir = args[2]
67 rootfs_dir = args[3]
68
69 ksconf = args[4]
70
71 image_output_dir = args[5]
72 oe_builddir = args[6]
73 compressor = args[7]
74 63
75 try: 64 try:
76 ksobj = KickStart(ksconf) 65 ksobj = KickStart(ksconf)
77 except KickStartError as err: 66 except KickStartError as err:
78 msger.error(str(err)) 67 msger.error(str(err))
79 68
80 image_name = "%s-%s" % (splitext(basename(ksconf))[0], 69 name = "%s-%s" % (splitext(basename(ksconf))[0],
81 strftime("%Y%m%d%H%M")) 70 strftime("%Y%m%d%H%M"))
82 71
83 # parse possible 'rootfs=name' items 72 # parse possible 'rootfs=name' items
84 krootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) 73 krootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' '))
85 74
86 creator = DirectImageCreator(image_name, ksobj, oe_builddir, 75 creator = DirectImageCreator(name, ksobj, oe_builddir, outdir,
87 image_output_dir, krootfs_dir, 76 krootfs_dir, bootimg_dir, kernel_dir,
88 bootimg_dir, kernel_dir, native_sysroot, 77 native_sysroot, compressor, opts.bmap)
89 compressor, opts.bmap)
90 try: 78 try:
91 creator.create() 79 creator.create()
92 creator.assemble() 80 creator.assemble()
93 creator.finalize() 81 creator.finalize()
94 creator.print_outimage_info() 82 creator.print_info()
95
96 except errors.CreatorError: 83 except errors.CreatorError:
97 raise 84 raise
98 finally: 85 finally:
99 creator.cleanup() 86 creator.cleanup()
100 87
101disk_methods = {
102 "do_install_disk":None,
103}
104
105class DiskImage(): 88class DiskImage():
106 """ 89 """
107 A Disk backed by a file. 90 A Disk backed by a file.
@@ -134,22 +117,22 @@ class DirectImageCreator:
134 media and used on actual hardware. 117 media and used on actual hardware.
135 """ 118 """
136 119
137 def __init__(self, image_name, ksobj, oe_builddir, image_output_dir, 120 def __init__(self, name, ksobj, oe_builddir, outdir,
138 rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, 121 rootfs_dir, bootimg_dir, kernel_dir,
139 compressor, bmap=False): 122 native_sysroot, compressor, bmap=False):
140 """ 123 """
141 Initialize a DirectImageCreator instance. 124 Initialize a DirectImageCreator instance.
142 125
143 This method takes the same arguments as ImageCreator.__init__() 126 This method takes the same arguments as ImageCreator.__init__()
144 """ 127 """
145 self.name = image_name 128 self.name = name
146 self.outdir = image_output_dir 129 self.outdir = outdir
147 self.workdir = tempfile.mktemp(prefix='wic') 130 self.workdir = tempfile.mktemp(prefix='wic')
148 self.ks = ksobj 131 self.ks = ksobj
149 132
150 self.__image = None 133 self._image = None
151 self.__disks = {} 134 self._disks = {}
152 self.__disk_format = "direct" 135 self._disk_format = "direct"
153 self._disk_names = [] 136 self._disk_names = []
154 self.ptable_format = self.ks.bootloader.ptable 137 self.ptable_format = self.ks.bootloader.ptable
155 138
@@ -372,14 +355,13 @@ class DirectImageCreator:
372 """ 355 """
373 source_plugin = self.get_default_source_plugin() 356 source_plugin = self.get_default_source_plugin()
374 if source_plugin: 357 if source_plugin:
375 self._source_methods = pluginmgr.get_source_plugin_methods(source_plugin, disk_methods) 358 name = "do_install_disk"
359 methods = pluginmgr.get_source_plugin_methods(source_plugin,
360 {name: None})
376 for disk_name, disk in self._image.disks.items(): 361 for disk_name, disk in self._image.disks.items():
377 self._source_methods["do_install_disk"](disk, disk_name, self, 362 methods["do_install_disk"](disk, disk_name, self, self.workdir,
378 self.workdir, 363 self.oe_builddir, self.bootimg_dir,
379 self.oe_builddir, 364 self.kernel_dir, self.native_sysroot)
380 self.bootimg_dir,
381 self.kernel_dir,
382 self.native_sysroot)
383 365
384 for disk_name, disk in self._image.disks.items(): 366 for disk_name, disk in self._image.disks.items():
385 full_path = self._full_path(self.workdir, disk_name, "direct") 367 full_path = self._full_path(self.workdir, disk_name, "direct")
@@ -393,7 +375,7 @@ class DirectImageCreator:
393 msger.debug("Compressing disk %s with %s" % (disk_name, self.compressor)) 375 msger.debug("Compressing disk %s with %s" % (disk_name, self.compressor))
394 exec_cmd("%s %s" % (self.compressor, full_path)) 376 exec_cmd("%s %s" % (self.compressor, full_path))
395 377
396 def print_outimage_info(self): 378 def print_info(self):
397 """ 379 """
398 Print the image(s) and artifacts used, for the user. 380 Print the image(s) and artifacts used, for the user.
399 """ 381 """