Skip to contentSkip to conversation

wic updates: Initial source plugin implementation

PATCH New Tom Zanussi 1 participant 8 messages Feb 4, 2014

lore
Share & tools
lore
#0 lore raw

cover wic updates: Initial source plugin implementation

This patchset implements wic 'source plugins', basically a generalization of the existing --source params to wic .wks commands.

The following changes since commit 358dd840c53e2e69e668a6d5da04eb3da3769ba3:

sstate-cache-management.sh: don't remove all packagedata sstate archives (2014-02-02 11:30:34 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-plugins-v0
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/wic-plugins-v0

Tom Zanussi (7):
wic: Move some common items to oe.misc
wic: Create and use new functions for getting bitbake variables
wic: Add wic-specific bootloader subclass
wic: Add SourcePlugin class
wic: Add BootimgEFIPlugin and BootimgPcbiosPlugin
wic: Hook up BootimgEFIPlugin and BootimgPcbiosPlugin plugins
wic: Hook up --debug option

 scripts/lib/image/canned-wks/directdisk.wks        |   2 +-
 scripts/lib/image/canned-wks/mkefidisk.wks         |   2 +-
 scripts/lib/image/engine.py                        |  28 +--
 scripts/lib/mic/imager/direct.py                   | 198 +++++----------------
 scripts/lib/mic/kickstart/__init__.py              |   4 +-
 .../lib/mic/kickstart/custom_commands/partition.py | 155 ++++------------
 .../lib/mic/kickstart/custom_commands/wicboot.py   |  57 ++++++
 scripts/lib/mic/plugin.py                          |  23 ++-
 scripts/lib/mic/pluginbase.py                      |  55 +++++-
 scripts/lib/mic/plugins/source/bootimg-efi.py      | 161 +++++++++++++++++
 scripts/lib/mic/plugins/source/bootimg-pcbios.py   | 187 +++++++++++++++++++
 scripts/lib/mic/utils/oe/misc.py                   |  28 +++
 scripts/wic                                        |  17 +-
 13 files changed, 618 insertions(+), 299 deletions(-)
 create mode 100644 scripts/lib/mic/kickstart/custom_commands/wicboot.py
 create mode 100644 scripts/lib/mic/plugins/source/bootimg-efi.py
 create mode 100644 scripts/lib/mic/plugins/source/bootimg-pcbios.py
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/7 wic: Move some common items to oe.misc

Move a couple items into a more common location since they're going to need to be accessible from source plugins.

---
 scripts/lib/image/engine.py                            | 11 -----------
 scripts/lib/mic/kickstart/custom_commands/partition.py |  2 --
 scripts/lib/mic/utils/oe/misc.py                       | 12 ++++++++++++
 3 files changed, 12 insertions(+), 13 deletions(-)
scripts/lib/image/engine.py +0 -11
index b3a9c74..0e8b89e 100644
@@ -60,17 +60,6 @@ def verify_build_env():
     return True
 
 
-def get_line_val(line, key):
-    """
-    Extract the value from the VAR="val" string
-    """
-    if line.startswith(key + "="):
-        stripped_line = line.split('=')[1]
-        stripped_line = stripped_line.replace('\"', '')
-        return stripped_line
-    return None
-
-
 def find_artifacts(image_name):
     """
     Gather the build artifacts for the current image (the image_name
scripts/lib/mic/kickstart/custom_commands/partition.py +0 -2
index 4b11195..fe8e55a 100644
@@ -31,8 +31,6 @@ from mic.utils.oe.misc import *
 
 from mic.kickstart.custom_commands import *
 
-BOOTDD_EXTRA_SPACE = 16384
-
 class Wic_PartData(Mic_PartData):
     removedKeywords = Mic_PartData.removedKeywords
     removedAttrs = Mic_PartData.removedAttrs
scripts/lib/mic/utils/oe/misc.py +12 -0
index 9edaa23..097d44c 100644
@@ -106,3 +106,15 @@ def get_wks_var(key):
 
 def add_wks_var(key, val):
     wks_vars[key] = val
+
+BOOTDD_EXTRA_SPACE = 16384
+
+def get_line_val(line, key):
+    """
+    Extract the value from the VAR="val" string
+    """
+    if line.startswith(key + "="):
+        stripped_line = line.split('=')[1]
+        stripped_line = stripped_line.replace('\"', '')
+        return stripped_line
+    return None
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/7 wic: Create and use new functions for getting bitbake variables

Add get_bitbake_var() and bitbake_env_lines() functions for use by plugins, which will need access to them for customization.

---
 scripts/lib/image/engine.py      | 20 +++++++++++++++-----
 scripts/lib/mic/utils/oe/misc.py | 16 ++++++++++++++++
 scripts/wic                      |  6 ++++++
 3 files changed, 37 insertions(+), 5 deletions(-)
scripts/lib/image/engine.py +15 -5
index 0e8b89e..2dd98b9 100644
@@ -60,16 +60,26 @@ def verify_build_env():
     return True
 
 
-def find_artifacts(image_name):
+def find_bitbake_env_lines(image_name):
     """
-    Gather the build artifacts for the current image (the image_name
-    e.g. core-image-minimal) for the current MACHINE set in local.conf
+    If image_name is empty, plugins might still be able to use the
+    environment, so set it regardless.
     """
     bitbake_env_cmd = "bitbake -e %s" % image_name
     rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd)
     if rc != 0:
-        print "Couldn't get '%s' output, exiting." % bitbake_env_cmd
-        sys.exit(1)
+        print "Couldn't get '%s' output." % bitbake_env_cmd
+        return None
+
+    return bitbake_env_lines
+
+
+def find_artifacts(image_name):
+    """
+    Gather the build artifacts for the current image (the image_name
+    e.g. core-image-minimal) for the current MACHINE set in local.conf
+    """
+    bitbake_env_lines = get_bitbake_env_lines()
 
     rootfs_dir = kernel_dir = hdddir = staging_data_dir = native_sysroot = ""
 
scripts/lib/mic/utils/oe/misc.py +16 -0
index 097d44c..77dfe03 100644
@@ -109,6 +109,15 @@ def add_wks_var(key, val):
 
 BOOTDD_EXTRA_SPACE = 16384
 
+__bitbake_env_lines = ""
+
+def set_bitbake_env_lines(bitbake_env_lines):
+    global __bitbake_env_lines
+    __bitbake_env_lines = bitbake_env_lines
+
+def get_bitbake_env_lines():
+    return __bitbake_env_lines
+
 def get_line_val(line, key):
     """
     Extract the value from the VAR="val" string
@@ -118,3 +127,10 @@ def get_line_val(line, key):
         stripped_line = stripped_line.replace('\"', '')
         return stripped_line
     return None
+
+def get_bitbake_var(key):
+    for line in __bitbake_env_lines.split('\n'):
+        if (get_line_val(line, key)):
+            val = get_line_val(line, key)
+            return val
+    return None
scripts/wic +6 -0
index b6fd16c..4ea5569 100755
@@ -98,6 +98,12 @@ def wic_create_subcommand(args, usage_str):
 
     print "Creating image(s)...\n"
 
+    bitbake_env_lines = find_bitbake_env_lines(options.image_name)
+    if not bitbake_env_lines:
+        print "Couldn't get bitbake environment, exiting."
+        sys.exit(1)
+    set_bitbake_env_lines(bitbake_env_lines)
+
     bootimg_dir = staging_data_dir = hdddir = ""
 
     if options.image_name:
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/7 wic: Add wic-specific bootloader subclass

In reply to Tom Zanussi

Add a new wic-specific bootloader subclass so we can add a --source param to hang non-partition plugin off of.

By default, the bootloader gets the /boot partition source plugin, but this can be overridden by the --source bootloader param if needed.

---
 scripts/lib/mic/imager/direct.py                   |  6 +++
 scripts/lib/mic/kickstart/__init__.py              |  4 +-
 .../lib/mic/kickstart/custom_commands/wicboot.py   | 57 ++++++++++++++++++++++
 3 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 scripts/lib/mic/kickstart/custom_commands/wicboot.py
scripts/lib/mic/imager/direct.py +6 -0
index d24bc68..3827eb8 100644
@@ -225,6 +225,12 @@ class DirectImageCreator(BaseImageCreator):
 
         fstab = self.__write_fstab()
 
+        for p in parts:
+            # as a convenience, set source to the boot partition source
+            # instead of forcing it to be set via bootloader --source
+            if not self.ks.handler.bootloader.source and p.mountpoint == "/boot":
+                self.ks.handler.bootloader.source = p.source
+
         self.boot_type = self.get_boot_type()
 
         if not self.bootimg_dir:
scripts/lib/mic/kickstart/__init__.py +2 -2
index 7e645ca..72f3ca6 100644
@@ -32,7 +32,7 @@ from pykickstart.handlers.control import dataMap
 
 from mic import msger
 from mic.utils import errors, misc, runner, fs_related as fs
-from custom_commands import desktop, micrepo, micboot, partition, installerfw
+from custom_commands import desktop, micrepo, wicboot, partition, installerfw
 
 
 AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)"
@@ -98,7 +98,7 @@ def read_kickstart(path):
     using_version = ksversion.DEVEL
     commandMap[using_version]["desktop"] = desktop.Mic_Desktop
     commandMap[using_version]["repo"] = micrepo.Mic_Repo
-    commandMap[using_version]["bootloader"] = micboot.Mic_Bootloader
+    commandMap[using_version]["bootloader"] = wicboot.Wic_Bootloader
     commandMap[using_version]["part"] = partition.Wic_Partition
     commandMap[using_version]["partition"] = partition.Wic_Partition
     commandMap[using_version]["installerfw"] = installerfw.Mic_installerfw
scripts/lib/mic/kickstart/custom_commands/wicboot.py new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 4/7 wic: Add SourcePlugin class

In reply to Tom Zanussi

Define the SourcePlugin class, which is the class that should be subclassed to create a 'source' plugin.

'Source' plugins provide a mechanism to customize various aspects of the image generation process in wic, mainly the contents of partitions.

The initial version of wic defined a --source param for partitions, which was in the first revision hard-coded to two possible values:
rootfs and bootimg.

This patch essentially removes the hard-coded --bootimg param and replaces it with a plugin system that maps the value specified as --source to a particular 'source' plugin instead.

A 'source' plugin is created as a subclass of SourcePlugin and the plugin file containing it is added to scriptsl/lib/mic/plugins/source/ to make the plugin implementation available to the wic implementation.

When the wic implementation needs to invoke a partition-specific implementation, it looks for the plugin that has the same name as the --source param given to that partition. For example, if the partition is set up like this:

part /boot --source bootimg-pcbios ...

then the methods defined as class members of the plugin having the matching .name class member would be used.

To be more concrete, here's the plugin definition that would match a '--source bootimg-pcbios' usage, along with an example method that would be called by the wic implementation when it needed to invoke an implementation-specific partition-preparation function:

class BootimgPcbiosPlugin(SourcePlugin):
name = 'bootimg-pcbios'

@classmethod
def do_prepare_partition(self, part, ...)

If the subclass itself doesn't implement a function, a 'default' version in a superclass will be located and used, which is why all plugins must be derived from SourcePlugin.

This scheme is extensible - adding more hooks is a simple matter of adding more plugin methods to SourcePlugin and derived classes. The code that then needs to call the plugin methods the uses plugin.get_source_plugin_methods() to find the method(s) needed by the call; this is done by filling up a dict with keys containing the methon names of interest - on success, these will be filled in with the actual methods. fPlease see the implementation for examples and details.

Note that a source plugin need not restrict itself to methods that apply directly to partitions - methods can also be defined for higher level processing such as at the 'disk' level. The get_default_source_plugin() of DirectImageCreator allows the default source plugin to be retrieved; by default this is set to be the same plugin used for the /boot partition, but that can be overridden by specifying a different --source and therefore different plugin on the 'bootloader' line. This isn't ideal, but it avoids forcing a new high-level object to be defined for that purpose.

Note that the '--source rootfs' param remains as its current hard-coded value, which is just the rootfs to be used to populate the partition - by default, that's just the value of the bitbake ROOTFS_DIR variable (or whatever was passed in using the -r param). Note that this also could also be overridden by creating a source plugin using a different name; at this point, unlike with bootimg, there's been no need to do so.

---
 scripts/lib/mic/plugin.py     | 23 ++++++++++++++++--
 scripts/lib/mic/pluginbase.py | 55 ++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 75 insertions(+), 3 deletions(-)
scripts/lib/mic/plugin.py +21 -2
index 7c296e9..df03c15 100644
@@ -19,13 +19,12 @@ import os, sys
 
 from mic import msger
 from mic import pluginbase
-from mic.conf import configmgr
 from mic.utils import errors
 
 
 __ALL__ = ['PluginMgr', 'pluginmgr']
 
-PLUGIN_TYPES = ["imager", "backend"] # TODO  "hook"
+PLUGIN_TYPES = ["imager", "source"] # TODO  "hook"
 
 
 class PluginMgr(object):
@@ -99,4 +98,24 @@ class PluginMgr(object):
 
         return pluginbase.get_plugins(ptype)
 
+    def get_source_plugin_methods(self, source_name, methods):
+        """
+        The methods param is a dict with the method names to find.  On
+        return, the dict values will be filled in with pointers to the
+        corresponding methods.  If one or more methods are not found,
+        None is returned.
+        """
+        return_methods = None
+        for _source_name, klass in self.get_plugins('source').iteritems():
+            if _source_name == source_name:
+                for _method_name in methods.keys():
+                    if not hasattr(klass, _method_name):
+                        msger.warning("Unimplemented %s source interface for: %s"\
+                                      % (_method_name, _source_name))
+                        return None
+                    func = getattr(klass, _method_name)
+                    methods[_method_name] = func
+                    return_methods = methods
+        return return_methods
+
 pluginmgr = PluginMgr()
scripts/lib/mic/pluginbase.py +54 -1

64 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 5/7 wic: Add BootimgEFIPlugin and BootimgPcbiosPlugin

In reply to Tom Zanussi

Implement the BootimgPcbiosPlugin and BootimgEFIPlugin SourcePlugin classes. The configure/prepare_partition() methods are implemented using code derived from similar code in the Wic_PartData class.

These classes have the corresponding names 'bootimg-pcbios' and 'bootimg-efi', which are the names that should be used in the --source parameters of the .wks partition commands.

---
 scripts/lib/mic/plugins/source/bootimg-efi.py    | 161 +++++++++++++++++++
 scripts/lib/mic/plugins/source/bootimg-pcbios.py | 187 +++++++++++++++++++++++
 2 files changed, 348 insertions(+)
 create mode 100644 scripts/lib/mic/plugins/source/bootimg-efi.py
 create mode 100644 scripts/lib/mic/plugins/source/bootimg-pcbios.py
scripts/lib/mic/plugins/source/bootimg-efi.py new file +161 -0
new file mode 100644
index 0000000..f2bd071
@@ -0,0 +1,161 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (c) 2014, Intel Corporation.
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# DESCRIPTION
+# This implements the 'bootimg-efi' source plugin class for 'wic'
+#
+# AUTHORS
+# Tom Zanussi <tom.zanussi (at] linux.intel.com>
+#
+
+import os
+import shutil
+import re
+import tempfile
+
+from mic import kickstart, chroot, msger
+from mic.utils import misc, fs_related, errors, runner, cmdln
+from mic.conf import configmgr
+from mic.plugin import pluginmgr
+from mic.utils.partitionedfs import PartitionedMount
+import mic.imager.direct as direct
+from mic.pluginbase import SourcePlugin
+from mic.utils.oe.misc import *
+from mic.imager.direct import DirectImageCreator
+
+class BootimgEFIPlugin(SourcePlugin):
+    name = 'bootimg-efi'
+
+    @classmethod
+    def do_configure_partition(self, part, cr, cr_workdir, oe_builddir,
+                               bootimg_dir, kernel_dir, native_sysroot):
+        """
+        Called before do_prepare_partition(), creates grubefi config
+        """
+        hdddir = "%s/hdd/boot" % cr_workdir
+        rm_cmd = "rm -rf %s" % cr_workdir
+        exec_cmd(rm_cmd)
+
+        install_cmd = "install -d %s/EFI/BOOT" % hdddir
+        tmp = exec_cmd(install_cmd)
+
+        splash = os.path.join(cr_workdir, "/EFI/boot/splash.jpg")
+        if os.path.exists(splash):
+            splashline = "menu background splash.jpg"
+        else:
+            splashline = ""
+
+        (rootdev, root_part_uuid) = cr._get_boot_config()
+        options = cr.ks.handler.bootloader.appendLine
+
+        grubefi_conf = ""
+        grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
+        grubefi_conf += "default=boot\n"
+        timeout = kickstart.get_timeout(cr.ks)
+        if not timeout:
+            timeout = 0
+        grubefi_conf += "timeout=%s\n" % timeout
+        grubefi_conf += "menuentry 'boot'{\n"
+
+        kernel = "/vmlinuz"
+
+        if cr._ptable_format == 'msdos':
+            rootstr = rootdev
+        else:
+            if not root_part_uuid:
+                raise MountError("Cannot find the root GPT partition UUID")
+            rootstr = "PARTUUID=%s" % root_part_uuid
+
+        grubefi_conf += "linux %s root=%s rootwait %s\n" \
+            % (kernel, rootstr, options)
+        grubefi_conf += "}\n"
+        if splashline:
+            syslinux_conf += "%s\n" % splashline
+
+        msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \
+                        % cr_workdir)
+        cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w")
+        cfg.write(grubefi_conf)
+        cfg.close()
+
+    @classmethod
+    def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
+                             kernel_dir, native_sysroot):
+        """
+        Called to do the actual content population for a partition i.e. it
+        'prepares' the partition to be incorporated into the image.
+        In this case, prepare content for an EFI (grub) boot partition.
+        """
+        if not bootimg_dir:
+            bootimg_dir = get_bitbake_var("HDDDIR")
+            if not bootimg_dir:
+                msger.error("Couldn't find HDDDIR, exiting\n")
+            # just so the result notes display it
+            cr.bootimg_dir = bootimg_dir
+
+        staging_kernel_dir = kernel_dir
+        staging_data_dir = bootimg_dir
+
+        hdddir = "%s/hdd" % cr_workdir
+
+        install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \
+            (staging_kernel_dir, hdddir)
+        tmp = exec_cmd(install_cmd)
+
+        shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
+                        "%s/grub.cfg" % cr_workdir)
+
+        cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (staging_data_dir, hdddir)
+        exec_cmd(cp_cmd, True)
+
+        shutil.move("%s/grub.cfg" % cr_workdir,
+                    "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
+
+        du_cmd = "du -bks %s" % hdddir
+        rc, out = exec_cmd(du_cmd)
+        blocks = int(out.split()[0])
+
+        blocks += BOOTDD_EXTRA_SPACE
+
+        # Ensure total sectors is an integral number of sectors per
+        # track or mcopy will complain. Sectors are 512 bytes, and we
+        # generate images with 32 sectors per track. This calculation is
+        # done in blocks, thus the mod by 16 instead of 32.
+        blocks += (16 - (blocks % 16))
+
+        # dosfs image, created by mkdosfs
+        bootimg = "%s/boot.img" % cr_workdir
+
+        dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks)
+        exec_native_cmd(dosfs_cmd, native_sysroot)
+
+        mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
+        exec_native_cmd(mcopy_cmd, native_sysroot)
+
+        chmod_cmd = "chmod 644 %s" % bootimg
+        exec_cmd(chmod_cmd)
+
+        du_cmd = "du -Lbms %s" % bootimg
+        rc, out = exec_cmd(du_cmd)
+        bootimg_size = out.split()[0]
+
+        part.size = bootimg_size
+        part.source_file = bootimg
+
+
scripts/lib/mic/plugins/source/bootimg-pcbios.py new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 6/7 wic: Hook up BootimgEFIPlugin and BootimgPcbiosPlugin plugins

In reply to Tom Zanussi

Remove all the Wic_PartData and DirectImageCreator code now implemented by the BootimgEFIPlugin and BootimgPcbiosPlugin plugins, as well as all the special-cased boot_type code, significantly cleaning up the code.

Replace the calling code with general-purpose plugin invocations, in essence calling the appropriate implementations at run-time based on the --source value in effect.

Change the directdisk.wks and mkefidisk.wks scripts to make use of the new plugins.

---
 scripts/lib/image/canned-wks/directdisk.wks        |   2 +-
 scripts/lib/image/canned-wks/mkefidisk.wks         |   2 +-
 scripts/lib/mic/imager/direct.py                   | 194 +++++----------------
 .../lib/mic/kickstart/custom_commands/partition.py | 155 +++++-----------
 scripts/lib/mic/plugins/source/bootimg-efi.py      |   6 +-
 scripts/lib/mic/plugins/source/bootimg-pcbios.py   |   6 +-
 6 files changed, 86 insertions(+), 279 deletions(-)
scripts/lib/image/canned-wks/directdisk.wks +1 -1
index d54b382..397a929 100644
@@ -3,7 +3,7 @@
 # can directly dd to boot media.
 
 
-part /boot --source bootimg --ondisk sda --fstype=msdos --label boot --active --align 1024
+part /boot --source bootimg-pcbios --ondisk sda --fstype=msdos --label boot --active --align 1024
 part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024
 
 bootloader  --timeout=0  --append="rootwait rootfstype=ext3 video=vesafb vga=0x318 console=tty0"
scripts/lib/image/canned-wks/mkefidisk.wks +1 -1
index 8a3e1f6..e976bc8 100644
@@ -2,7 +2,7 @@
 # long-description: Creates a partitioned EFI disk image that the user
 # can directly dd to boot media.
 
-part /boot --source bootimg --ondisk sda --fstype=efi --label msdos --active --align 1024
+part /boot --source bootimg-efi --ondisk sda --fstype=msdos --label msdos --active --align 1024
 
 part / --source rootfs --ondisk sda --fstype=ext3 --label platform --align 1024
 
scripts/lib/mic/imager/direct.py +39 -155

249 lines not on this page · raw message

scripts/lib/mic/kickstart/custom_commands/partition.py +39 -116

176 lines not on this page · raw message

scripts/lib/mic/plugins/source/bootimg-efi.py +3 -3
index f2bd071..3e0997b 100644
@@ -107,7 +107,7 @@ class BootimgEFIPlugin(SourcePlugin):
             if not bootimg_dir:
                 msger.error("Couldn't find HDDDIR, exiting\n")
             # just so the result notes display it
-            cr.bootimg_dir = bootimg_dir
+            cr.set_bootimg_dir(bootimg_dir)
 
         staging_kernel_dir = kernel_dir
         staging_data_dir = bootimg_dir
@@ -155,7 +155,7 @@ class BootimgEFIPlugin(SourcePlugin):
         rc, out = exec_cmd(du_cmd)
         bootimg_size = out.split()[0]
 
-        part.size = bootimg_size
-        part.source_file = bootimg
+        part.set_size(bootimg_size)
+        part.set_source_file(bootimg)
 
 
scripts/lib/mic/plugins/source/bootimg-pcbios.py +3 -3
index 1da2a41..3cd446f 100644
@@ -135,7 +135,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
             if not bootimg_dir:
                 msger.error("Couldn't find STAGING_DATADIR, exiting\n")
             # just so the result notes display it
-            cr.bootimg_dir = bootimg_dir
+            cr.set_bootimg_dir(bootimg_dir)
 
         staging_kernel_dir = kernel_dir
         staging_data_dir = bootimg_dir
@@ -181,7 +181,7 @@ class BootimgPcbiosPlugin(SourcePlugin):
         rc, out = exec_cmd(du_cmd)
         bootimg_size = out.split()[0]
 
-        part.size = bootimg_size
-        part.source_file = bootimg
+        part.set_size(bootimg_size)
+        part.set_source_file(bootimg)
 
 
Signature · 1 line
1.8.3.1
#7 lore raw

PATCH 7/7 wic: Hook up --debug option

In reply to Tom Zanussi

Hook up the existing --debug option to toggle the wic debug loglevel, which is indispensible when things go wrong, and make it easy to use from the command-line.

---
 scripts/lib/image/engine.py |  5 ++++-
 scripts/wic                 | 11 +++--------
 2 files changed, 7 insertions(+), 9 deletions(-)
scripts/lib/image/engine.py +4 -1
index 2dd98b9..6cf6169 100644
@@ -175,7 +175,7 @@ def list_canned_image_help(scripts_path, fullpath):
 
 def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
                native_sysroot, hdddir, staging_data_dir, scripts_path,
-               image_output_dir, properties_file, properties=None):
+               image_output_dir, debug, properties_file, properties=None):
     """
     Create image
 
@@ -235,6 +235,9 @@ def wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
     direct_args.insert(0, staging_data_dir)
     direct_args.insert(0, "direct")
 
+    if debug:
+        msger.set_loglevel('debug')
+
     cr = creator.Creator()
 
     cr.main(direct_args)
scripts/wic +3 -8
index 4ea5569..824acae 100755
@@ -69,6 +69,8 @@ def wic_create_subcommand(args, usage_str):
                       action = "store", help = "path to the native sysroot containing the tools to use to build the image")
     parser.add_option("-p", "--skip-build-check", dest = "build_check",
                       action = "store_false", default = True, help = "skip the build check")
+    parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
+                      default = False, help = "output debug information")
 
     (options, args) = parser.parse_args(args)
 
@@ -162,7 +164,7 @@ def wic_create_subcommand(args, usage_str):
 
     wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
                native_sysroot, hdddir, staging_data_dir, scripts_path,
-               image_output_dir, options.properties_file)
+               image_output_dir, options.debug, options.properties_file)
 
 
 def wic_list_subcommand(args, usage_str):
@@ -203,16 +205,9 @@ def main():
                                    usage = wic_usage)
 
     parser.disable_interspersed_args()
-    parser.add_option("-D", "--debug", dest = "debug", action = "store_true",
-                      default = False, help = "output debug information")
 
     (options, args) = parser.parse_args()
 
-    loglevel = logging.INFO
-    if options.debug:
-        loglevel = logging.DEBUG
-    start_logging(loglevel)
-
     if len(args):
         if args[0] == "help":
             if len(args) == 1:
Signature · 1 line
1.8.3.1