]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: direct_plugin: stop using config manager
authorEd Bartosh <ed.bartosh@linux.intel.com>
Mon, 30 Jan 2017 21:31:53 +0000 (23:31 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Feb 2017 17:37:34 +0000 (17:37 +0000)
This is a preparation to removing conf.py and config/wic.conf
from the codebase.

Got rid of using configmgr global object in direct_plugin and direct
modules. It was used to implicitly parse kickstart file and set
couple of variables.

Replaced usage of configmgr by passing parameters directly to the
DirectImageCreator.

[YOCTO #10619]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
scripts/lib/wic/imager/direct.py
scripts/lib/wic/plugins/imager/direct_plugin.py

index 575fd95f11028bca86396d5d05196b35a795e4e4..ff06b504ced6e16102c301be0cfb708e4b29879d 100644 (file)
@@ -72,18 +72,18 @@ class DirectImageCreator:
     media and used on actual hardware.
     """
 
-    def __init__(self, oe_builddir, image_output_dir, rootfs_dir,
-                 bootimg_dir, kernel_dir, native_sysroot, compressor,
-                 creatoropts, bmap=False):
+    def __init__(self, image_name, ksobj, oe_builddir, image_output_dir,
+                 rootfs_dir, bootimg_dir, kernel_dir, native_sysroot,
+                 compressor, bmap=False):
         """
         Initialize a DirectImageCreator instance.
 
         This method takes the same arguments as ImageCreator.__init__()
         """
-        self.name = creatoropts['name']
+        self.name = image_name
         self.outdir = image_output_dir
         self.workdir = tempfile.mktemp(prefix='wic')
-        self.ks = creatoropts['ks']
+        self.ks = ksobj
 
         self.__image = None
         self.__disks = {}
index 8fe39308046fb3b067f96102bb6931d38c909d67..e839d2feae28462e2ac18be4d1884ff7ac0a173b 100644 (file)
 # Tom Zanussi <tom.zanussi (at] linux.intel.com>
 #
 
+from time import strftime
+
+from os.path import basename, splitext
 from wic.utils import errors
-from wic.conf import configmgr
+from wic.ksparser import KickStart, KickStartError
+from wic import msger
 
 import wic.imager.direct as direct
 from wic.pluginbase import ImagerPlugin
@@ -68,27 +72,31 @@ class DirectPlugin(ImagerPlugin):
         bootimg_dir = args[2]
         rootfs_dir = args[3]
 
-        creatoropts = configmgr.create
         ksconf = args[4]
 
         image_output_dir = args[5]
         oe_builddir = args[6]
         compressor = args[7]
 
-        krootfs_dir = cls.__rootfs_dir_to_dict(rootfs_dir)
+        try:
+            ksobj = KickStart(ksconf)
+        except KickStartError as err:
+            msger.error(str(err))
 
-        configmgr._ksconf = ksconf
+        image_name = "%s-%s" % (splitext(basename(ksconf))[0],
+                          strftime("%Y%m%d%H%M"))
+        krootfs_dir = cls.__rootfs_dir_to_dict(rootfs_dir)
 
-        creator = direct.DirectImageCreator(oe_builddir,
+        creator = direct.DirectImageCreator(image_name,
+                                            ksobj,
+                                            oe_builddir,
                                             image_output_dir,
                                             krootfs_dir,
                                             bootimg_dir,
                                             kernel_dir,
                                             native_sysroot,
                                             compressor,
-                                            creatoropts,
                                             opts.bmap)
-
         try:
             creator.create()
             creator.assemble()