#10619: refactor wic codebase (start)
cover #10619: refactor wic codebase (start)
Hi,
This patchset consolidates wic APIs in a more maintainable way, removes unused APIs and cleans up wic code.
This is a first series of a refactoring work. The changes in this patchset are relatively simple. They're a preparation for upcoming heavy work on making wic codebase less complex and more maintainable.
The following changes since commit ec3d83f9a90288403b96be25da855fa280aadd8d:
xmlto: Don't hardcode the path to tail (2017-01-31 23:47:33 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib ed/wic/refactoring-10619
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/wic/refactoring-10619
Ed Bartosh (18):
wic: creator: stop using config manager
wic: direct_plugin: stop using config manager
wic: removed conf.py and empty config file.
wic: moved content of direct.py to direct_plugin
wic: get rid of __rootfs_dir_to_dict method
wic: improve naming in direct_plugin classes
wic: pylinted direct_plugin
wic: simplified code of direct_plugin
wic: renamd direct_plugin.py -> direct.py
wic: removed test file
wic: partition: simlify calling plugin methods
wci: misc: removed build_name API
wic: move 2 APIs to wic.engine
wic: move oe/misc.py one level up
wic: removed code from __init__.py
wic: msger.py: remove unused APIs
wic: code cleanup
wic: remove syslinux.py
scripts/lib/wic/__init__.py | 4 -
scripts/lib/wic/__version__.py | 1 -
scripts/lib/wic/conf.py | 103 --------
scripts/lib/wic/config/wic.conf | 6 -
scripts/lib/wic/creator.py | 19 --
scripts/lib/wic/engine.py | 39 ++-
scripts/lib/wic/help.py | 4 +-
scripts/lib/wic/imager/__init__.py | 0
scripts/lib/wic/ksparser.py | 2 +-
scripts/lib/wic/msger.py | 26 --
scripts/lib/wic/partition.py | 66 ++---
scripts/lib/wic/plugin.py | 5 +-
scripts/lib/wic/pluginbase.py | 1 -
scripts/lib/wic/{ => plugins}/imager/direct.py | 139 ++++++-----
scripts/lib/wic/plugins/imager/direct_plugin.py | 103 --------
scripts/lib/wic/plugins/source/bootimg-efi.py | 20 +-
.../lib/wic/plugins/source/bootimg-partition.py | 6 +-
scripts/lib/wic/plugins/source/bootimg-pcbios.py | 12 +-
scripts/lib/wic/plugins/source/fsimage.py | 2 +-
.../lib/wic/plugins/source/isoimage-isohybrid.py | 15 +-
scripts/lib/wic/plugins/source/rawcopy.py | 3 +-
scripts/lib/wic/plugins/source/rootfs.py | 6 +-
.../lib/wic/plugins/source/rootfs_pcbios_ext.py | 46 +++-
scripts/lib/wic/test | 1 -
scripts/lib/wic/utils/misc.py | 274 +++++++++++++++------
scripts/lib/wic/utils/oe/misc.py | 247 -------------------
scripts/lib/wic/utils/partitionedfs.py | 7 +-
scripts/lib/wic/utils/syslinux.py | 58 -----
scripts/wic | 2 +-
29 files changed, 426 insertions(+), 791 deletions(-)
delete mode 100644 scripts/lib/wic/__version__.py
delete mode 100644 scripts/lib/wic/conf.py
delete mode 100644 scripts/lib/wic/config/wic.conf
delete mode 100644 scripts/lib/wic/imager/__init__.py
rename scripts/lib/wic/{ => plugins}/imager/direct.py (80%)
delete mode 100644 scripts/lib/wic/plugins/imager/direct_plugin.py
delete mode 100644 scripts/lib/wic/test
delete mode 100644 scripts/lib/wic/utils/oe/misc.py
delete mode 100644 scripts/lib/wic/utils/syslinux.pySignature · 1 line
2.1.4
PATCH 1/18 wic: creator: stop using config manager
This is a preparation to removing conf.py and config/wic.conf from the codebase.
confmgr object is complicated for no reason and almost useless as all configuration info comes from command line and bitbake variables. It's used it creator.py to store information about output directory, logs and some never used functionality like tmpfs for future use, which doesn't actually happen.
[YOCTO #10619]
--- scripts/lib/wic/creator.py | 19 ------------------- 1 file changed, 19 deletions(-)
scripts/lib/wic/creator.py +0 -19
@@ -20,10 +20,8 @@ from optparse import OptionParser, SUPPRESS_HELP from wic import msger from wic.utils import errors -from wic.conf import configmgr from wic.plugin import pluginmgr - class Creator(): """${name}: create an image
@@ -89,23 +87,6 @@ class Creator(): os.makedirs(os.path.dirname(logfile_abs_path)) msger.set_interactive(False) msger.set_logfile(logfile_abs_path) - configmgr.create['logfile'] = options.logfile - - if options.config: - configmgr.reset() - configmgr._siteconf = options.config - - if options.outdir is not None: - configmgr.create['outdir'] = abspath(options.outdir) - - cdir = 'outdir' - if os.path.exists(configmgr.create[cdir]) \ - and not os.path.isdir(configmgr.create[cdir]): - msger.error('Invalid directory specified: %s' \ - % configmgr.create[cdir]) - - if options.enabletmpfs: - configmgr.create['enabletmpfs'] = options.enabletmpfs def main(self, argv=None): if argv is None:
Signature · 1 line
2.1.4
PATCH 2/18 wic: direct_plugin: stop using config manager
In reply to Ed BartoshThis 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]
--- scripts/lib/wic/imager/direct.py | 10 +++++----- scripts/lib/wic/plugins/imager/direct_plugin.py | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-)
scripts/lib/wic/imager/direct.py +5 -5
@@ -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 = {}
scripts/lib/wic/plugins/imager/direct_plugin.py +15 -7
@@ -24,8 +24,12 @@ # 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()
Signature · 1 line
2.1.4
PATCH 3/18 wic: removed conf.py and empty config file.
In reply to Ed BartoshRemoved as they're not used anymore in wic code.
--- scripts/lib/wic/conf.py | 103 ---------------------------------------- scripts/lib/wic/config/wic.conf | 6 --- 2 files changed, 109 deletions(-) delete mode 100644 scripts/lib/wic/conf.py delete mode 100644 scripts/lib/wic/config/wic.conf
scripts/lib/wic/conf.py deleted +0 -103
@@ -1,103 +0,0 @@ -#!/usr/bin/env python -tt -# -# Copyright (c) 2011 Intel, Inc. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; version 2 of the License -# -# 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., 59 -# Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -import os - -from wic.ksparser import KickStart, KickStartError -from wic import msger -from wic.utils import misc - - -def get_siteconf(): - wic_path = os.path.dirname(__file__) - eos = wic_path.find('scripts') + len('scripts') - scripts_path = wic_path[:eos] - - return scripts_path + "/lib/image/config/wic.conf" - -class ConfigMgr(object): - DEFAULTS = { - 'common': { - "distro_name": "Default Distribution", - "plugin_dir": "/usr/lib/wic/plugins"}, # TODO use prefix also? - 'create': { - "tmpdir": '/var/tmp/wic', - "outdir": './wic-output', - "release": None, - "logfile": None, - "name_prefix": None, - "name_suffix": None} - } - - # make the manager class as singleton - _instance = None - def __new__(cls, *args, **kwargs): - if not cls._instance: - cls._instance = super(ConfigMgr, cls).__new__(cls, *args, **kwargs) - - return cls._instance - - def __init__(self, ksconf=None, siteconf=None): - # reset config options - self.reset() - - if not siteconf: - siteconf = get_siteconf() - - # initial options from siteconf - self._siteconf = siteconf - - if ksconf: - self._ksconf = ksconf - - def reset(self): - self.__ksconf = None - self.__siteconf = None - self.create = {} - - # initialize the values with defaults - for sec, vals in self.DEFAULTS.items(): - setattr(self, sec, vals) - - def __set_ksconf(self, ksconf): - if not os.path.isfile(ksconf): - msger.error('Cannot find ks file: %s' % ksconf) - - self.__ksconf = ksconf - self._parse_kickstart(ksconf) - def __get_ksconf(self): - return self.__ksconf - _ksconf = property(__get_ksconf, __set_ksconf) - - def _parse_kickstart(self, ksconf=None): - if not ksconf: - return - - try: - ksobj = KickStart(ksconf) - except KickStartError as err: - msger.error(str(err)) - - self.create['ks'] = ksobj - self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0] - - self.create['name'] = misc.build_name(ksconf, - self.create['release'], - self.create['name_prefix'], - self.create['name_suffix']) - -configmgr = ConfigMgr()
scripts/lib/wic/config/wic.conf deleted +0 -6
@@ -1,6 +0,0 @@ -[common] -; general settings -distro_name = OpenEmbedded - -[create] -; settings for create subcommand
Signature · 1 line
2.1.4
PATCH 4/18 wic: moved content of direct.py to direct_plugin
In reply to Ed BartoshThis move simplifies directory structure and makes further refactoring easier. The code from direct.py was used only in direct_plugin, so it's safe to move it there.
[YOCTO #10619]
--- scripts/lib/wic/imager/__init__.py | 0 scripts/lib/wic/imager/direct.py | 402 ------------------------ scripts/lib/wic/plugins/imager/direct_plugin.py | 396 ++++++++++++++++++++++- 3 files changed, 380 insertions(+), 418 deletions(-) delete mode 100644 scripts/lib/wic/imager/__init__.py delete mode 100644 scripts/lib/wic/imager/direct.py
scripts/lib/wic/imager/__init__.py deleted +0 -0
scripts/lib/wic/imager/direct.py deleted +0 -402
402 lines not on this page · raw message
scripts/lib/wic/plugins/imager/direct_plugin.py +380 -16
416 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 5/18 wic: get rid of __rootfs_dir_to_dict method
In reply to Ed BartoshReplaced class method __rootfs_dir_to_dict with a list comprehension.
[YOCTO #10619]
--- scripts/lib/wic/plugins/imager/direct_plugin.py | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)
scripts/lib/wic/plugins/imager/direct_plugin.py +5 -16
@@ -53,21 +53,8 @@ class DirectPlugin(ImagerPlugin): name = 'direct' - @classmethod - def __rootfs_dir_to_dict(cls, rootfs_dirs): - """ - Gets a string that contain 'connection=dir' splitted by - space and return a dict - """ - krootfs_dir = {} - for rootfs_dir in rootfs_dirs.split(' '): - key, val = rootfs_dir.split('=') - krootfs_dir[key] = val - - return krootfs_dir - - @classmethod - def do_create(cls, opts, *args): + @staticmethod + def do_create(opts, *args): """ Create direct image, called from creator as 'direct' cmd """
@@ -92,7 +79,9 @@ class DirectPlugin(ImagerPlugin): image_name = "%s-%s" % (splitext(basename(ksconf))[0], strftime("%Y%m%d%H%M")) - krootfs_dir = cls.__rootfs_dir_to_dict(rootfs_dir) + + # parse possible 'rootfs=name' items + krootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) creator = DirectImageCreator(image_name, ksobj, oe_builddir, image_output_dir, krootfs_dir,
Signature · 1 line
2.1.4
PATCH 6/18 wic: improve naming in direct_plugin classes
In reply to Ed BartoshSynchronized attribure names in DirectImageCreator and DirectPlugin for better readability. Simplified code, removed unneeded global variable disk_methods.
--- scripts/lib/wic/plugins/imager/direct_plugin.py | 62 +++++++++---------------- 1 file changed, 22 insertions(+), 40 deletions(-)
scripts/lib/wic/plugins/imager/direct_plugin.py +22 -40
@@ -58,50 +58,33 @@ class DirectPlugin(ImagerPlugin): """ Create direct image, called from creator as 'direct' cmd """ - if len(args) != 8: - raise errors.Usage("Extra arguments given") - - native_sysroot = args[0] - kernel_dir = args[1] - bootimg_dir = args[2] - rootfs_dir = args[3] - - ksconf = args[4] - - image_output_dir = args[5] - oe_builddir = args[6] - compressor = args[7] + native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, ksconf, \ + outdir, oe_builddir, compressor = args try: ksobj = KickStart(ksconf) except KickStartError as err: msger.error(str(err)) - image_name = "%s-%s" % (splitext(basename(ksconf))[0], + name = "%s-%s" % (splitext(basename(ksconf))[0], strftime("%Y%m%d%H%M")) # parse possible 'rootfs=name' items krootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) - creator = DirectImageCreator(image_name, ksobj, oe_builddir, - image_output_dir, krootfs_dir, - bootimg_dir, kernel_dir, native_sysroot, - compressor, opts.bmap) + creator = DirectImageCreator(name, ksobj, oe_builddir, outdir, + krootfs_dir, bootimg_dir, kernel_dir, + native_sysroot, compressor, opts.bmap) try: creator.create() creator.assemble() creator.finalize() - creator.print_outimage_info() - + creator.print_info() except errors.CreatorError: raise finally: creator.cleanup() -disk_methods = { - "do_install_disk":None, -} - class DiskImage(): """ A Disk backed by a file.
@@ -134,22 +117,22 @@ class DirectImageCreator: media and used on actual hardware. """ - def __init__(self, image_name, ksobj, oe_builddir, image_output_dir, - rootfs_dir, bootimg_dir, kernel_dir, native_sysroot, - compressor, bmap=False): + def __init__(self, name, ksobj, oe_builddir, outdir, + 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 = image_name - self.outdir = image_output_dir + self.name = name + self.outdir = outdir self.workdir = tempfile.mktemp(prefix='wic') self.ks = ksobj - self.__image = None - self.__disks = {} - self.__disk_format = "direct" + self._image = None + self._disks = {} + self._disk_format = "direct" self._disk_names = [] self.ptable_format = self.ks.bootloader.ptable
@@ -372,14 +355,13 @@ class DirectImageCreator: """ source_plugin = self.get_default_source_plugin() if source_plugin: - self._source_methods = pluginmgr.get_source_plugin_methods(source_plugin, disk_methods) + name = "do_install_disk" + methods = pluginmgr.get_source_plugin_methods(source_plugin, + {name: None}) for disk_name, disk in self._image.disks.items(): - self._source_methods["do_install_disk"](disk, disk_name, self, - self.workdir, - self.oe_builddir, - self.bootimg_dir, - self.kernel_dir, - self.native_sysroot) + methods["do_install_disk"](disk, disk_name, self, self.workdir, + self.oe_builddir, self.bootimg_dir, + self.kernel_dir, self.native_sysroot) for disk_name, disk in self._image.disks.items(): full_path = self._full_path(self.workdir, disk_name, "direct")
@@ -393,7 +375,7 @@ class DirectImageCreator: msger.debug("Compressing disk %s with %s" % (disk_name, self.compressor)) exec_cmd("%s %s" % (self.compressor, full_path)) - def print_outimage_info(self): + def print_info(self): """ Print the image(s) and artifacts used, for the user. """
Signature · 1 line
2.1.4
PATCH 7/18 wic: pylinted direct_plugin
In reply to Ed BartoshFixed wrong continued indentation, unused import and trailing new line pyling warnings.
[YOCTO #10619]
--- scripts/lib/wic/plugins/imager/direct_plugin.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
scripts/lib/wic/plugins/imager/direct_plugin.py +7 -15
@@ -27,7 +27,6 @@ import os import shutil import uuid import tempfile -import time from time import strftime from os.path import basename, splitext
@@ -307,19 +306,13 @@ class DirectImageCreator: self.bootimg_dir, self.kernel_dir, self.native_sysroot) - self._image.add_partition(part.disk_size, - part.disk, - part.mountpoint, - part.source_file, - part.fstype, - part.label, - fsopts=part.fsopts, - boot=part.active, - align=part.align, - no_table=part.no_table, - part_type=part.part_type, - uuid=part.uuid, - system_id=part.system_id) + self._image.add_partition(part.disk_size, part.disk, + part.mountpoint, part.source_file, + part.fstype, part.label, + fsopts=part.fsopts, boot=part.active, + align=part.align, no_table=part.no_table, + part_type=part.part_type, uuid=part.uuid, + system_id=part.system_id) if fstab_path: shutil.move(fstab_path + ".orig", fstab_path)
@@ -443,4 +436,3 @@ class DirectImageCreator: # remove work directory shutil.rmtree(self.workdir, ignore_errors=True) -
Signature · 1 line
2.1.4
PATCH 8/18 wic: simplified code of direct_plugin
In reply to Ed BartoshRemoved unused methods.
Got rid of get_default_source_plugin and _full_name methods.
[YOCTO #10619]
--- scripts/lib/wic/plugins/imager/direct_plugin.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
scripts/lib/wic/plugins/imager/direct_plugin.py +2 -22
@@ -93,9 +93,6 @@ class DiskImage(): self.device = device self.created = False - def exists(self): - return os.path.exists(self.device) - def create(self): if self.created: return
@@ -229,26 +226,9 @@ class DirectImageCreator: # partitions list from kickstart file return self.ks.partitions - def _full_name(self, name, extention): - """ Construct full file name for a file we generate. """ - return "%s-%s.%s" % (self.name, name, extention) - def _full_path(self, path, name, extention): """ Construct full file path to a file we generate. """ - return os.path.join(path, self._full_name(name, extention)) - - def get_default_source_plugin(self): - """ - The default source plugin i.e. the plugin that's consulted for - overall image generation tasks outside of any particular - partition. For convenience, we just hang it off the - bootloader handler since it's the one non-partition object in - any setup. By default the default plugin is set to the same - plugin as the /boot partition; since we hang it off the - bootloader object, the default can be explicitly set using the - --source bootloader param. - """ - return self.ks.bootloader.source + return os.path.join(path, "%s-%s.%s" % (self.name, name, extention)) # # Actual implemention
@@ -346,7 +326,7 @@ class DirectImageCreator: For example, prepare the image to be bootable by e.g. creating and installing a bootloader configuration. """ - source_plugin = self.get_default_source_plugin() + source_plugin = self.ks.bootloader.source if source_plugin: name = "do_install_disk" methods = pluginmgr.get_source_plugin_methods(source_plugin,
Signature · 1 line
2.1.4
PATCH 9/18 wic: renamd direct_plugin.py -> direct.py
In reply to Ed BartoshAs this files is located in plugins/imager subdirectory it's obvious that it's an imager plugin. Renamed to direct.py to be consistent with plugin naming scheme.
[YOCTO #10619]
---
scripts/lib/wic/plugins/imager/{direct_plugin.py => direct.py} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename scripts/lib/wic/plugins/imager/{direct_plugin.py => direct.py} (100%)scripts/lib/wic/plugins/imager/direct.py renamed from scripts/lib/wic/plugins/imager/direct_plugin.py +0 -0
Signature · 1 line
2.1.4
PATCH 10/18 wic: removed test file
In reply to Ed BartoshThis file is not used anywhere in the wic code.
[YOCTO #10619]
--- scripts/lib/wic/test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 scripts/lib/wic/test
scripts/lib/wic/test deleted +0 -1
@@ -1 +0,0 @@ -test
Signature · 1 line
2.1.4
PATCH 11/18 wic: partition: simlify calling plugin methods
In reply to Ed BartoshReplaced parse_sourceparams function with list comprehension. Used local variables instead of attributes.
Moved global variable to the local scope.
[YOCTO #10619]
--- scripts/lib/wic/partition.py | 53 +++++++++++++++++++--------------------- scripts/lib/wic/utils/oe/misc.py | 23 ----------------- 2 files changed, 25 insertions(+), 51 deletions(-)
scripts/lib/wic/partition.py +25 -28
@@ -27,16 +27,10 @@ import os import tempfile -from wic.utils.oe.misc import msger, parse_sourceparams +from wic.utils.oe.misc import msger from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.plugin import pluginmgr -partition_methods = { - "do_stage_partition":None, - "do_prepare_partition":None, - "do_configure_partition":None, -} - class Partition(): def __init__(self, args, lineno):
@@ -129,9 +123,6 @@ class Partition(): Prepare content for individual partitions, depending on partition command parameters. """ - if self.sourceparams: - self.sourceparams_dict = parse_sourceparams(self.sourceparams) - if not self.source: if not self.size and not self.fixed_size: msger.error("The %s partition has a size of zero. Please "
@@ -164,24 +155,30 @@ class Partition(): "details on adding a new source plugin." % \ (self.source, self.mountpoint)) - self._source_methods = pluginmgr.get_source_plugin_methods(\ - self.source, partition_methods) - self._source_methods["do_configure_partition"](self, self.sourceparams_dict, - creator, cr_workdir, - oe_builddir, - bootimg_dir, - kernel_dir, - native_sysroot) - self._source_methods["do_stage_partition"](self, self.sourceparams_dict, - creator, cr_workdir, - oe_builddir, - bootimg_dir, kernel_dir, - native_sysroot) - self._source_methods["do_prepare_partition"](self, self.sourceparams_dict, - creator, cr_workdir, - oe_builddir, - bootimg_dir, kernel_dir, rootfs_dir, - native_sysroot) + srcparams_dict = {} + if self.sourceparams: + # Split sourceparams string of the form key1=val1[,key2=val2,...] + # into a dict. Also accepts valueless keys i.e. without = + splitted = self.sourceparams.split(',') + srcparams_dict = dict(par.split('=') for par in splitted if par) + + partition_methods = { + "do_stage_partition": None, + "do_prepare_partition": None, + "do_configure_partition": None + } + + methods = pluginmgr.get_source_plugin_methods(self.source, + partition_methods) + methods["do_configure_partition"](self, srcparams_dict, creator, + cr_workdir, oe_builddir, bootimg_dir, + kernel_dir, native_sysroot) + methods["do_stage_partition"](self, srcparams_dict, creator, + cr_workdir, oe_builddir, bootimg_dir, + kernel_dir, native_sysroot) + methods["do_prepare_partition"](self, srcparams_dict, creator, + cr_workdir, oe_builddir, bootimg_dir, + kernel_dir, rootfs_dir, native_sysroot) # further processing required Partition.size to be an integer, make # sure that it is one
scripts/lib/wic/utils/oe/misc.py +0 -23
@@ -222,26 +222,3 @@ def get_bitbake_var(var, image=None, cache=True): get_var method of BB_VARS singleton. """ return BB_VARS.get_var(var, image, cache) - -def parse_sourceparams(sourceparams): - """ - Split sourceparams string of the form key1=val1[,key2=val2,...] - into a dict. Also accepts valueless keys i.e. without =. - - Returns dict of param key/val pairs (note that val may be None). - """ - params_dict = {} - - params = sourceparams.split(',') - if params: - for par in params: - if not par: - continue - if not '=' in par: - key = par - val = None - else: - key, val = par.split('=') - params_dict[key] = val - - return params_dict
Signature · 1 line
2.1.4
PATCH 12/18 wci: misc: removed build_name API
In reply to Ed BartoshThis API is not used in wic code.
[YOCTO #10619]
--- scripts/lib/wic/utils/misc.py | 39 --------------------------------------- 1 file changed, 39 deletions(-)
scripts/lib/wic/utils/misc.py +0 -39
@@ -19,45 +19,6 @@ import os import time import wic.engine -def build_name(kscfg, release=None, prefix=None, suffix=None): - """Construct and return an image name string. - - This is a utility function to help create sensible name and fslabel - strings. The name is constructed using the sans-prefix-and-extension - kickstart filename and the supplied prefix and suffix. - - kscfg -- a path to a kickstart file - release -- a replacement to suffix for image release - prefix -- a prefix to prepend to the name; defaults to None, which causes - no prefix to be used - suffix -- a suffix to append to the name; defaults to None, which causes - a YYYYMMDDHHMM suffix to be used - - Note, if maxlen is less then the len(suffix), you get to keep both pieces. - - """ - name = os.path.basename(kscfg) - idx = name.rfind('.') - if idx >= 0: - name = name[:idx] - - if release is not None: - suffix = "" - if prefix is None: - prefix = "" - if suffix is None: - suffix = time.strftime("%Y%m%d%H%M") - - if name.startswith(prefix): - name = name[len(prefix):] - - prefix = "%s-" % prefix if prefix else "" - suffix = "-%s" % suffix if suffix else "" - - ret = prefix + name + suffix - - return ret - def find_canned(scripts_path, file_name): """ Find a file either by its path or by name in the canned files dir.
Signature · 1 line
2.1.4
PATCH 13/18 wic: move 2 APIs to wic.engine
In reply to Ed BartoshMoved find_canned and get_custom_config APIs to engine module. Removed empty wic.utils.misc module.
[YOCTO #10619]
--- scripts/lib/wic/engine.py | 33 ++++++++++++- scripts/lib/wic/ksparser.py | 2 +- scripts/lib/wic/plugins/source/bootimg-efi.py | 2 +- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 4 +- .../lib/wic/plugins/source/isoimage-isohybrid.py | 2 +- scripts/lib/wic/utils/misc.py | 56 ---------------------- 6 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 scripts/lib/wic/utils/misc.py
scripts/lib/wic/engine.py +32 -1
@@ -32,7 +32,6 @@ import os import sys from wic import msger, creator -from wic.utils import misc from wic.plugin import pluginmgr from wic.utils.oe import misc
@@ -226,3 +225,35 @@ def wic_list(args, scripts_path): return True return False + +def find_canned(scripts_path, file_name): + """ + Find a file either by its path or by name in the canned files dir. + + Return None if not found + """ + if os.path.exists(file_name): + return file_name + + layers_canned_wks_dir = build_canned_image_list(scripts_path) + for canned_wks_dir in layers_canned_wks_dir: + for root, dirs, files in os.walk(canned_wks_dir): + for fname in files: + if fname == file_name: + fullpath = os.path.join(canned_wks_dir, fname) + return fullpath + +def get_custom_config(boot_file): + """ + Get the custom configuration to be used for the bootloader. + + Return None if the file can't be found. + """ + # Get the scripts path of poky + scripts_path = os.path.abspath("%s/../.." % os.path.dirname(__file__)) + + cfg_file = find_canned(scripts_path, boot_file) + if cfg_file: + with open(cfg_file, "r") as f: + config = f.read() + return config
scripts/lib/wic/ksparser.py +1 -1
@@ -30,8 +30,8 @@ import shlex from argparse import ArgumentParser, ArgumentError, ArgumentTypeError from wic import msger +from wic.engine import find_canned from wic.partition import Partition -from wic.utils.misc import find_canned class KickStartError(Exception): """Custom exception."""
scripts/lib/wic/plugins/source/bootimg-efi.py +1 -1
@@ -28,8 +28,8 @@ import os import shutil from wic import msger +from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.misc import get_custom_config from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ BOOTDD_EXTRA_SPACE
scripts/lib/wic/plugins/source/bootimg-pcbios.py +2 -2
@@ -26,10 +26,10 @@ import os -from wic.utils.errors import ImageError from wic import msger +from wic.engine import get_custom_config from wic.utils import runner -from wic.utils.misc import get_custom_config +from wic.utils.errors import ImageError from wic.pluginbase import SourcePlugin from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \ get_bitbake_var, BOOTDD_EXTRA_SPACE
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +1 -1
@@ -26,8 +26,8 @@ import shutil import glob from wic import msger +from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.misc import get_custom_config from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var class IsoImagePlugin(SourcePlugin):
scripts/lib/wic/utils/misc.py deleted +0 -56
56 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 14/18 wic: move oe/misc.py one level up
In reply to Ed BartoshFlattened directory structure:
moved wic/utils/oe/misc.py -> wic/utils/misc.py
[YOCTO #10619]
---
scripts/lib/wic/engine.py | 4 ++--
scripts/lib/wic/partition.py | 4 ++--
scripts/lib/wic/plugin.py | 2 +-
scripts/lib/wic/plugins/imager/direct.py | 2 +-
scripts/lib/wic/plugins/source/bootimg-efi.py | 4 ++--
scripts/lib/wic/plugins/source/bootimg-partition.py | 2 +-
scripts/lib/wic/plugins/source/bootimg-pcbios.py | 4 ++--
scripts/lib/wic/plugins/source/fsimage.py | 2 +-
scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 2 +-
scripts/lib/wic/plugins/source/rawcopy.py | 2 +-
scripts/lib/wic/plugins/source/rootfs.py | 2 +-
scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 8 ++++----
scripts/lib/wic/utils/{oe => }/misc.py | 0
scripts/lib/wic/utils/partitionedfs.py | 2 +-
scripts/wic | 2 +-
15 files changed, 21 insertions(+), 21 deletions(-)
rename scripts/lib/wic/utils/{oe => }/misc.py (100%)scripts/lib/wic/engine.py +2 -2
@@ -33,7 +33,7 @@ import sys from wic import msger, creator from wic.plugin import pluginmgr -from wic.utils.oe import misc +from wic.utils.misc import get_bitbake_var def verify_build_env():
@@ -54,7 +54,7 @@ SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR WIC_DIR = "wic" def build_canned_image_list(path): - layers_path = misc.get_bitbake_var("BBLAYERS") + layers_path = get_bitbake_var("BBLAYERS") canned_wks_layer_dirs = [] if layers_path is not None:
scripts/lib/wic/partition.py +2 -2
@@ -27,8 +27,8 @@ import os import tempfile -from wic.utils.oe.misc import msger -from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var +from wic import msger +from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.plugin import pluginmgr class Partition():
scripts/lib/wic/plugin.py +1 -1
@@ -20,7 +20,7 @@ import os, sys from wic import msger from wic import pluginbase from wic.utils import errors -from wic.utils.oe.misc import get_bitbake_var +from wic.utils.misc import get_bitbake_var __ALL__ = ['PluginMgr', 'pluginmgr']
scripts/lib/wic/plugins/imager/direct.py +1 -1
@@ -37,7 +37,7 @@ from wic.plugin import pluginmgr from wic.pluginbase import ImagerPlugin from wic.utils import errors from wic.utils.errors import CreatorError, ImageError -from wic.utils.oe.misc import get_bitbake_var, exec_cmd, exec_native_cmd +from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd from wic.utils.partitionedfs import Image class DirectPlugin(ImagerPlugin):
scripts/lib/wic/plugins/source/bootimg-efi.py +2 -2
@@ -30,8 +30,8 @@ import shutil from wic import msger from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var, \ - BOOTDD_EXTRA_SPACE +from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var, + BOOTDD_EXTRA_SPACE) class BootimgEFIPlugin(SourcePlugin): """
scripts/lib/wic/plugins/source/bootimg-partition.py +1 -1
@@ -28,7 +28,7 @@ import re from wic import msger from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import exec_cmd, get_bitbake_var +from wic.utils.misc import exec_cmd, get_bitbake_var from glob import glob class BootimgPartitionPlugin(SourcePlugin):
scripts/lib/wic/plugins/source/bootimg-pcbios.py +2 -2
@@ -31,8 +31,8 @@ from wic.engine import get_custom_config from wic.utils import runner from wic.utils.errors import ImageError from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import exec_cmd, exec_native_cmd, \ - get_bitbake_var, BOOTDD_EXTRA_SPACE +from wic.utils.misc import (exec_cmd, exec_native_cmd, + get_bitbake_var, BOOTDD_EXTRA_SPACE) class BootimgPcbiosPlugin(SourcePlugin): """
scripts/lib/wic/plugins/source/fsimage.py +1 -1
@@ -19,7 +19,7 @@ import os from wic import msger from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import get_bitbake_var +from wic.utils.misc import get_bitbake_var class FSImagePlugin(SourcePlugin): """
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +1 -1
@@ -28,7 +28,7 @@ import glob from wic import msger from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import exec_cmd, exec_native_cmd, get_bitbake_var +from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var class IsoImagePlugin(SourcePlugin): """
scripts/lib/wic/plugins/source/rawcopy.py +1 -1
@@ -19,7 +19,7 @@ import os from wic import msger from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import exec_cmd, get_bitbake_var +from wic.utils.misc import exec_cmd, get_bitbake_var from wic.filemap import sparse_copy class RawCopyPlugin(SourcePlugin):
scripts/lib/wic/plugins/source/rootfs.py +1 -1
@@ -29,7 +29,7 @@ import os from wic import msger from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import get_bitbake_var +from wic.utils.misc import get_bitbake_var class RootfsPlugin(SourcePlugin): """
scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +4 -4
@@ -22,7 +22,7 @@ import os from wic import msger from wic.utils import syslinux from wic.utils import runner -from wic.utils.oe import misc +from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd from wic.utils.errors import ImageError from wic.pluginbase import SourcePlugin
@@ -58,7 +58,7 @@ class RootfsPlugin(SourcePlugin): if os.path.isdir(rootfs_dir): return rootfs_dir - image_rootfs_dir = misc.get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) + image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) if not os.path.isdir(image_rootfs_dir): msg = "No valid artifact IMAGE_ROOTFS from image named" msg += " %s has been found at %s, exiting.\n" % \
@@ -119,7 +119,7 @@ class RootfsPlugin(SourcePlugin): native_syslinux_nomtools = os.path.join(native_sysroot, "usr/bin/syslinux-nomtools") if not is_exe(native_syslinux_nomtools): msger.info("building syslinux-native...") - misc.exec_cmd("bitbake syslinux-native") + exec_cmd("bitbake syslinux-native") if not is_exe(native_syslinux_nomtools): msger.error("Couldn't find syslinux-nomtools (%s), exiting\n" % native_syslinux_nomtools)
@@ -145,7 +145,7 @@ class RootfsPlugin(SourcePlugin): # install syslinux into rootfs partition syslinux_cmd = "syslinux-nomtools -d /boot -i %s" % part.source_file - misc.exec_native_cmd(syslinux_cmd, native_sysroot) + exec_native_cmd(syslinux_cmd, native_sysroot) @classmethod def do_install_disk(cls, disk, disk_name, image_creator, workdir, oe_builddir,
scripts/lib/wic/utils/misc.py renamed from scripts/lib/wic/utils/oe/misc.py +0 -0
scripts/lib/wic/utils/partitionedfs.py +1 -1
@@ -21,7 +21,7 @@ import os from wic import msger from wic.utils.errors import ImageError -from wic.utils.oe.misc import exec_cmd, exec_native_cmd +from wic.utils.misc import exec_cmd, exec_native_cmd from wic.filemap import sparse_copy # Overhead of the MBR partitioning scheme (just one sector)
scripts/wic +1 -1
@@ -51,7 +51,7 @@ if bitbake_exe: else: bitbake_main = None -from wic.utils.oe.misc import get_bitbake_var, BB_VARS +from wic.utils.misc import get_bitbake_var, BB_VARS from wic.utils.errors import WicError from wic import engine from wic import help as hlp
Signature · 1 line
2.1.4
PATCH 15/18 wic: removed code from __init__.py
In reply to Ed BartoshThe code deals with non-existing directory
and can be removed.
[YOCTO #10619]
--- scripts/lib/wic/__init__.py | 4 ---- 1 file changed, 4 deletions(-)
scripts/lib/wic/__init__.py +0 -4
@@ -1,4 +0,0 @@ -import os, sys - -cur_path = os.path.dirname(__file__) or '.' -sys.path.insert(0, cur_path + '/3rdparty')
Signature · 1 line
2.1.4
PATCH 16/18 wic: msger.py: remove unused APIs
In reply to Ed BartoshRemoved unused enable_logstderr and disable_logstderr APIs.
[YOCTO #10619]
--- scripts/lib/wic/msger.py | 26 -------------------------- 1 file changed, 26 deletions(-)
scripts/lib/wic/msger.py +0 -26
@@ -207,29 +207,3 @@ def set_logfile(fpath): import atexit atexit.register(_savelogf) - -def enable_logstderr(fpath): - global CATCHERR_BUFFILE_FD - global CATCHERR_BUFFILE_PATH - global CATCHERR_SAVED_2 - - if os.path.exists(fpath): - os.remove(fpath) - CATCHERR_BUFFILE_PATH = fpath - CATCHERR_BUFFILE_FD = os.open(CATCHERR_BUFFILE_PATH, os.O_RDWR|os.O_CREAT) - CATCHERR_SAVED_2 = os.dup(2) - os.dup2(CATCHERR_BUFFILE_FD, 2) - -def disable_logstderr(): - global CATCHERR_BUFFILE_FD - global CATCHERR_BUFFILE_PATH - global CATCHERR_SAVED_2 - - raw(msg=None) # flush message buffer and print it. - os.dup2(CATCHERR_SAVED_2, 2) - os.close(CATCHERR_SAVED_2) - os.close(CATCHERR_BUFFILE_FD) - os.unlink(CATCHERR_BUFFILE_PATH) - CATCHERR_BUFFILE_FD = -1 - CATCHERR_BUFFILE_PATH = None - CATCHERR_SAVED_2 = -1
Signature · 1 line
2.1.4
PATCH 17/18 wic: code cleanup
In reply to Ed BartoshFixed indentation, unused imports, trailing lines etc.
[YOCTO #10619]
--- scripts/lib/wic/__version__.py | 1 - scripts/lib/wic/engine.py | 2 +- scripts/lib/wic/help.py | 4 ++-- scripts/lib/wic/partition.py | 11 +++++++---- scripts/lib/wic/plugin.py | 3 ++- scripts/lib/wic/pluginbase.py | 1 - scripts/lib/wic/plugins/imager/direct.py | 3 +-- scripts/lib/wic/plugins/source/bootimg-efi.py | 14 +++++++------- scripts/lib/wic/plugins/source/bootimg-partition.py | 4 ++-- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 4 +--- scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 11 +++++------ scripts/lib/wic/plugins/source/rawcopy.py | 1 - scripts/lib/wic/plugins/source/rootfs.py | 4 ++-- scripts/lib/wic/utils/misc.py | 9 +++------ scripts/lib/wic/utils/partitionedfs.py | 7 +++---- 15 files changed, 36 insertions(+), 43 deletions(-) delete mode 100644 scripts/lib/wic/__version__.py
scripts/lib/wic/__version__.py deleted +0 -1
@@ -1 +0,0 @@ -VERSION = "2.00"
scripts/lib/wic/engine.py +1 -1
@@ -190,7 +190,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, crobj = creator.Creator() cmdline = ["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, - wks_file, image_output_dir, oe_builddir, compressor or ""] + wks_file, image_output_dir, oe_builddir, compressor or ""] if bmap: cmdline.append('--bmap')
scripts/lib/wic/help.py +2 -2
@@ -31,7 +31,7 @@ import logging from wic.plugin import pluginmgr, PLUGIN_TYPES def subcommand_error(args): - logging.info("invalid subcommand %s" % args[0]) + logging.info("invalid subcommand %s", args[0]) def display_help(subcommand, subcommands):
@@ -87,7 +87,7 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands): elif args[0] == "help": wic_help(args, main_command_usage, subcommands) elif args[0] not in subcommands: - logging.error("Unsupported subcommand %s, exiting\n" % (args[0])) + logging.error("Unsupported subcommand %s, exiting\n", args[0]) parser.print_help() return 1 else:
scripts/lib/wic/partition.py +7 -4
@@ -182,7 +182,7 @@ class Partition(): # further processing required Partition.size to be an integer, make # sure that it is one - if type(self.size) is not int: + if not isinstance(self.size, int): msger.error("Partition %s internal size is not an integer. " \ "This a bug in source plugin %s and needs to be fixed." \ % (self.mountpoint, self.source))
@@ -242,7 +242,10 @@ class Partition(): # IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE rsize_bb = get_bitbake_var('ROOTFS_SIZE') if rsize_bb: - msger.warning('overhead-factor was specified, but size was not, so bitbake variables will be used for the size. In this case both IMAGE_OVERHEAD_FACTOR and --overhead-factor will be applied') + msger.warning('overhead-factor was specified, but size was not,' + ' so bitbake variables will be used for the size.' + ' In this case both IMAGE_OVERHEAD_FACTOR and ' + '--overhead-factor will be applied') self.size = int(round(float(rsize_bb))) for prefix in ("ext", "btrfs", "vfat", "squashfs"):
@@ -402,7 +405,8 @@ class Partition(): "Proceeding as requested." % self.mountpoint) path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) - os.path.isfile(path) and os.remove(path) + if os.path.isfile(path): + os.remove(path) # it is not possible to create a squashfs without source data, # thus prepare an empty temp dir that is used as source
@@ -436,4 +440,3 @@ class Partition(): label_str = "-L %s" % self.label mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path) exec_native_cmd(mkswap_cmd, native_sysroot) -
scripts/lib/wic/plugin.py +2 -1
@@ -15,7 +15,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import os, sys +import os +import sys from wic import msger from wic import pluginbase
scripts/lib/wic/pluginbase.py +0 -1
@@ -17,7 +17,6 @@ __all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins'] -import sys from collections import defaultdict from wic import msger
scripts/lib/wic/plugins/imager/direct.py +1 -2
@@ -29,7 +29,6 @@ import uuid import tempfile from time import strftime -from os.path import basename, splitext from wic import msger from wic.ksparser import KickStart, KickStartError
@@ -65,7 +64,7 @@ class DirectPlugin(ImagerPlugin): except KickStartError as err: msger.error(str(err)) - name = "%s-%s" % (splitext(basename(ksconf))[0], + name = "%s-%s" % (os.path.splitext(os.path.basename(ksconf))[0], strftime("%Y%m%d%H%M")) # parse possible 'rootfs=name' items
scripts/lib/wic/plugins/source/bootimg-efi.py +7 -7
@@ -42,7 +42,7 @@ class BootimgEFIPlugin(SourcePlugin): name = 'bootimg-efi' @classmethod - def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params): + def do_configure_grubefi(cls, creator, cr_workdir): """ Create loader-specific (grub-efi) config """
@@ -54,10 +54,10 @@ class BootimgEFIPlugin(SourcePlugin): # Use a custom configuration for grub grubefi_conf = custom_cfg msger.debug("Using custom configuration file " - "%s for grub.cfg" % configfile) + "%s for grub.cfg" % configfile) else: msger.error("configfile is specified but failed to " - "get it from %s." % configfile) + "get it from %s." % configfile) if not custom_cfg: # Create grub configuration using parameters from wks file
@@ -125,10 +125,10 @@ class BootimgEFIPlugin(SourcePlugin): # Use a custom configuration for systemd-boot boot_conf = custom_cfg msger.debug("Using custom configuration file " - "%s for systemd-boots's boot.conf" % configfile) + "%s for systemd-boots's boot.conf" % configfile) else: msger.error("configfile is specified but failed to " - "get it from %s." % configfile) + "get it from %s." % configfile) if not custom_cfg: # Create systemd-boot configuration using parameters from wks file
@@ -164,7 +164,7 @@ class BootimgEFIPlugin(SourcePlugin): try: if source_params['loader'] == 'grub-efi': - cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params) + cls.do_configure_grubefi(creator, cr_workdir) elif source_params['loader'] == 'systemd-boot': cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params) else:
@@ -185,7 +185,7 @@ class BootimgEFIPlugin(SourcePlugin): if not bootimg_dir: bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") if not bootimg_dir: - msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") + msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") # just so the result notes display it creator.set_bootimg_dir(bootimg_dir)
scripts/lib/wic/plugins/source/bootimg-partition.py +2 -2
@@ -26,10 +26,11 @@ import os import re +from glob import glob + from wic import msger from wic.pluginbase import SourcePlugin from wic.utils.misc import exec_cmd, get_bitbake_var -from glob import glob class BootimgPartitionPlugin(SourcePlugin): """
@@ -137,4 +138,3 @@ class BootimgPartitionPlugin(SourcePlugin): msger.debug('Prepare boot partition using rootfs in %s' % (hdddir)) part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, native_sysroot) -
scripts/lib/wic/plugins/source/bootimg-pcbios.py +1 -3
@@ -198,7 +198,5 @@ class BootimgPcbiosPlugin(SourcePlugin): out = exec_cmd(du_cmd) bootimg_size = out.split()[0] - part.size = int(out.split()[0]) + part.size = int(bootimg_size) part.source_file = bootimg - -
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +5 -6
@@ -100,10 +100,10 @@ class IsoImagePlugin(SourcePlugin): grubefi_conf = get_custom_config(configfile) if grubefi_conf: msger.debug("Using custom configuration file " - "%s for grub.cfg" % configfile) + "%s for grub.cfg" % configfile) else: msger.error("configfile is specified but failed to " - "get it from %s." % configfile) + "get it from %s." % configfile) else: splash = os.path.join(cr_workdir, "EFI/boot/splash.jpg") if os.path.exists(splash):
@@ -285,6 +285,7 @@ class IsoImagePlugin(SourcePlugin): if not deploy_dir: msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir) + exec_cmd(cp_cmd) else: # Prepare initial ramdisk initrd = "%s/initrd" % deploy_dir
@@ -293,8 +294,7 @@ class IsoImagePlugin(SourcePlugin): if not os.path.isfile(initrd): initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir) - install_cmd = "install -m 0644 %s %s/initrd" \ - % (initrd, isodir) + install_cmd = "install -m 0644 %s %s/initrd" % (initrd, isodir) exec_cmd(install_cmd) # Remove the temporary file created by _build_initramfs_path function
@@ -303,7 +303,7 @@ class IsoImagePlugin(SourcePlugin): # Install bzImage install_cmd = "install -m 0644 %s/bzImage %s/bzImage" % \ - (kernel_dir, isodir) + (kernel_dir, isodir) exec_cmd(install_cmd) #Create bootloader for efi boot
@@ -362,7 +362,6 @@ class IsoImagePlugin(SourcePlugin): exec_native_cmd(grub_cmd, native_sysroot) else: - # TODO: insert gummiboot stuff msger.error("unrecognized bootimg-efi loader: %s" \ % source_params['loader']) except KeyError:
scripts/lib/wic/plugins/source/rawcopy.py +0 -1
@@ -84,4 +84,3 @@ class RawCopyPlugin(SourcePlugin): part.size = filesize part.source_file = dst -
scripts/lib/wic/plugins/source/rootfs.py +2 -2
@@ -79,5 +79,5 @@ class RootfsPlugin(SourcePlugin): real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) part.rootfs_dir = real_rootfs_dir - part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot) - + part.prepare_rootfs(cr_workdir, oe_builddir, + real_rootfs_dir, native_sysroot)
scripts/lib/wic/utils/misc.py +3 -6
@@ -77,18 +77,15 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3): msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \ (cmd_and_args, ret, out)) - return (ret, out) + return ret, out def exec_cmd(cmd_and_args, as_shell=False, catch=3): """ - Execute command, catching stderr, stdout - - Exits if rc non-zero + Execute command, return output """ - ret, out = _exec_cmd(cmd_and_args, as_shell, catch) + return _exec_cmd(cmd_and_args, as_shell, catch)[1] - return out def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""): """
scripts/lib/wic/utils/partitionedfs.py +3 -4
@@ -21,7 +21,7 @@ import os from wic import msger from wic.utils.errors import ImageError -from wic.utils.misc import exec_cmd, exec_native_cmd +from wic.utils.misc import exec_native_cmd from wic.filemap import sparse_copy # Overhead of the MBR partitioning scheme (just one sector)
@@ -350,10 +350,9 @@ class Image(): if self.disks: for dev in self.disks: disk = self.disks[dev] - try: + if hasattr(disk['disk'], 'cleanup'): disk['disk'].cleanup() - except: - pass + # remove partition images for image in self.partimages: if os.path.isfile(image):
Signature · 1 line
2.1.4
PATCH 18/18 wic: remove syslinux.py
In reply to Ed BartoshThis module contains singe function serial_console_form_kargs, which is used only by rootfs_pcbios_ext plugin. Moved it there and removed syslinux module to make it easy to find and mainain plugin code.
[YOCTO #10619]
--- .../lib/wic/plugins/source/rootfs_pcbios_ext.py | 38 +++++++++++++- scripts/lib/wic/utils/syslinux.py | 58 ---------------------- 2 files changed, 37 insertions(+), 59 deletions(-) delete mode 100644 scripts/lib/wic/utils/syslinux.py
scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +37 -1
@@ -19,13 +19,49 @@ # import os +import re + from wic import msger -from wic.utils import syslinux from wic.utils import runner from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd from wic.utils.errors import ImageError from wic.pluginbase import SourcePlugin +def serial_console_form_kargs(kernel_args): + """ + Create SERIAL... line from kernel parameters + + syslinux needs a line SERIAL port [baudrate [flowcontrol]] + in the syslinux.cfg file. The config line is generated based + on kernel boot parameters. The the parameters of the first + ttyS console are considered for syslinux config. + @param kernel_args kernel command line + @return line for syslinux config file e.g. "SERIAL 0 115200" + """ + syslinux_conf = "" + for param in kernel_args.split(): + param_match = re.match("console=ttyS([0-9]+),?([0-9]*)([noe]?)([0-9]?)(r?)", param) + if param_match: + syslinux_conf += "SERIAL " + param_match.group(1) + # baudrate + if param_match.group(2): + syslinux_conf += " " + param_match.group(2) + # parity + if param_match.group(3) and param_match.group(3) != 'n': + msger.warning("syslinux does not support parity for console. {} is ignored." + .format(param_match.group(3))) + # number of bits + if param_match.group(4) and param_match.group(4) != '8': + msger.warning("syslinux supports 8 bit console configuration only. {} is ignored." + .format(param_match.group(4))) + # flow control + if param_match.group(5) and param_match.group(5) != '': + msger.warning("syslinux console flowcontrol configuration. {} is ignored." + .format(param_match.group(5))) + break + + return syslinux_conf + # pylint: disable=no-init class RootfsPlugin(SourcePlugin):
scripts/lib/wic/utils/syslinux.py deleted +0 -58
58 lines not on this page · raw message
Signature · 1 line
2.1.4