mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
wic: use wic logger in core modules
Replaced msger with wic logger in the core wic modules. (From OE-Core rev: cdd6675951b74075c9b9159f7465a88f83775bac) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
58ff06f1e7
commit
fe2d602240
@@ -28,6 +28,7 @@
|
|||||||
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
|
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ from wic import msger
|
|||||||
from wic.plugin import pluginmgr
|
from wic.plugin import pluginmgr
|
||||||
from wic.utils.misc import get_bitbake_var
|
from wic.utils.misc import get_bitbake_var
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
def verify_build_env():
|
def verify_build_env():
|
||||||
"""
|
"""
|
||||||
@@ -43,7 +45,7 @@ def verify_build_env():
|
|||||||
Returns True if it is, false otherwise
|
Returns True if it is, false otherwise
|
||||||
"""
|
"""
|
||||||
if not os.environ.get("BUILDDIR"):
|
if not os.environ.get("BUILDDIR"):
|
||||||
print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
|
logger.error("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -179,7 +181,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
|||||||
try:
|
try:
|
||||||
oe_builddir = os.environ["BUILDDIR"]
|
oe_builddir = os.environ["BUILDDIR"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
|
logger.error("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if options.debug:
|
if options.debug:
|
||||||
@@ -191,14 +193,15 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
|||||||
pname = 'direct'
|
pname = 'direct'
|
||||||
plugin_class = pluginmgr.get_plugins('imager').get(pname)
|
plugin_class = pluginmgr.get_plugins('imager').get(pname)
|
||||||
if not plugin_class:
|
if not plugin_class:
|
||||||
msger.error('Unknown plugin: %s' % pname)
|
logger.error('Unknown plugin: %s', pname)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
plugin = plugin_class(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
plugin = plugin_class(wks_file, rootfs_dir, bootimg_dir, kernel_dir,
|
||||||
native_sysroot, oe_builddir, options)
|
native_sysroot, oe_builddir, options)
|
||||||
|
|
||||||
plugin.do_create()
|
plugin.do_create()
|
||||||
|
|
||||||
print("\nThe image(s) were created using OE kickstart file:\n %s" % wks_file)
|
logger.info("The image(s) were created using OE kickstart file:\n %s", wks_file)
|
||||||
|
|
||||||
|
|
||||||
def wic_list(args, scripts_path):
|
def wic_list(args, scripts_path):
|
||||||
@@ -218,10 +221,10 @@ def wic_list(args, scripts_path):
|
|||||||
wks_file = args[0]
|
wks_file = args[0]
|
||||||
fullpath = find_canned_image(scripts_path, wks_file)
|
fullpath = find_canned_image(scripts_path, wks_file)
|
||||||
if not fullpath:
|
if not fullpath:
|
||||||
print("No image named %s found, exiting. "\
|
logger.error("No image named %s found, exiting. "
|
||||||
"(Use 'wic list images' to list available images, or "\
|
"(Use 'wic list images' to list available images, or "
|
||||||
"specify a fully-qualified OE kickstart (.wks) "\
|
"specify a fully-qualified OE kickstart (.wks) "
|
||||||
"filename)\n" % wks_file)
|
"filename)\n", wks_file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
list_canned_image_help(scripts_path, fullpath)
|
list_canned_image_help(scripts_path, fullpath)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ import logging
|
|||||||
|
|
||||||
from wic.plugin import pluginmgr, PLUGIN_TYPES
|
from wic.plugin import pluginmgr, PLUGIN_TYPES
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
def subcommand_error(args):
|
def subcommand_error(args):
|
||||||
logging.info("invalid subcommand %s", args[0])
|
logger.info("invalid subcommand %s", args[0])
|
||||||
|
|
||||||
|
|
||||||
def display_help(subcommand, subcommands):
|
def display_help(subcommand, subcommands):
|
||||||
@@ -81,13 +83,13 @@ def invoke_subcommand(args, parser, main_command_usage, subcommands):
|
|||||||
Should use argparse, but has to work in 2.6.
|
Should use argparse, but has to work in 2.6.
|
||||||
"""
|
"""
|
||||||
if not args:
|
if not args:
|
||||||
logging.error("No subcommand specified, exiting")
|
logger.error("No subcommand specified, exiting")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
elif args[0] == "help":
|
elif args[0] == "help":
|
||||||
wic_help(args, main_command_usage, subcommands)
|
wic_help(args, main_command_usage, subcommands)
|
||||||
elif args[0] not in subcommands:
|
elif args[0] not in subcommands:
|
||||||
logging.error("Unsupported subcommand %s, exiting\n", args[0])
|
logger.error("Unsupported subcommand %s, exiting\n", args[0])
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -27,12 +27,15 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
import logging
|
||||||
|
|
||||||
from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
|
from argparse import ArgumentParser, ArgumentError, ArgumentTypeError
|
||||||
|
|
||||||
from wic import msger
|
|
||||||
from wic.engine import find_canned
|
from wic.engine import find_canned
|
||||||
from wic.partition import Partition
|
from wic.partition import Partition
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
class KickStartError(Exception):
|
class KickStartError(Exception):
|
||||||
"""Custom exception."""
|
"""Custom exception."""
|
||||||
pass
|
pass
|
||||||
@@ -168,7 +171,7 @@ class KickStart():
|
|||||||
|
|
||||||
self._parse(parser, confpath)
|
self._parse(parser, confpath)
|
||||||
if not self.bootloader:
|
if not self.bootloader:
|
||||||
msger.warning('bootloader config not specified, using defaults')
|
logger.warning('bootloader config not specified, using defaults\n')
|
||||||
self.bootloader = bootloader.parse_args([])
|
self.bootloader = bootloader.parse_args([])
|
||||||
|
|
||||||
def _parse(self, parser, confpath):
|
def _parse(self, parser, confpath):
|
||||||
|
|||||||
@@ -24,13 +24,16 @@
|
|||||||
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
|
# Tom Zanussi <tom.zanussi (at] linux.intel.com>
|
||||||
# Ed Bartosh <ed.bartosh> (at] linux.intel.com>
|
# Ed Bartosh <ed.bartosh> (at] linux.intel.com>
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from wic import msger
|
|
||||||
from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var
|
from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var
|
||||||
from wic.plugin import pluginmgr
|
from wic.plugin import pluginmgr
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
class Partition():
|
class Partition():
|
||||||
|
|
||||||
def __init__(self, args, lineno):
|
def __init__(self, args, lineno):
|
||||||
@@ -69,16 +72,16 @@ class Partition():
|
|||||||
number of (1k) blocks we need to add to get to --size, 0 if
|
number of (1k) blocks we need to add to get to --size, 0 if
|
||||||
we're already there or beyond.
|
we're already there or beyond.
|
||||||
"""
|
"""
|
||||||
msger.debug("Requested partition size for %s: %d" % \
|
logger.debug("Requested partition size for %s: %d",
|
||||||
(self.mountpoint, self.size))
|
self.mountpoint, self.size)
|
||||||
|
|
||||||
if not self.size:
|
if not self.size:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
requested_blocks = self.size
|
requested_blocks = self.size
|
||||||
|
|
||||||
msger.debug("Requested blocks %d, current_blocks %d" % \
|
logger.debug("Requested blocks %d, current_blocks %d",
|
||||||
(requested_blocks, current_blocks))
|
requested_blocks, current_blocks)
|
||||||
|
|
||||||
if requested_blocks > current_blocks:
|
if requested_blocks > current_blocks:
|
||||||
return requested_blocks - current_blocks
|
return requested_blocks - current_blocks
|
||||||
@@ -96,8 +99,9 @@ class Partition():
|
|||||||
if self.fixed_size:
|
if self.fixed_size:
|
||||||
rootfs_size = self.fixed_size
|
rootfs_size = self.fixed_size
|
||||||
if actual_rootfs_size > rootfs_size:
|
if actual_rootfs_size > rootfs_size:
|
||||||
msger.error("Actual rootfs size (%d kB) is larger than allowed size %d kB" \
|
logger.error("Actual rootfs size (%d kB) is larger than allowed size %d kB",
|
||||||
%(actual_rootfs_size, rootfs_size))
|
actual_rootfs_size, rootfs_size)
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
|
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
|
||||||
if extra_blocks < self.extra_space:
|
if extra_blocks < self.extra_space:
|
||||||
@@ -106,8 +110,8 @@ class Partition():
|
|||||||
rootfs_size = actual_rootfs_size + extra_blocks
|
rootfs_size = actual_rootfs_size + extra_blocks
|
||||||
rootfs_size *= self.overhead_factor
|
rootfs_size *= self.overhead_factor
|
||||||
|
|
||||||
msger.debug("Added %d extra blocks to %s to get to %d total blocks" % \
|
logger.debug("Added %d extra blocks to %s to get to %d total blocks",
|
||||||
(extra_blocks, self.mountpoint, rootfs_size))
|
extra_blocks, self.mountpoint, rootfs_size)
|
||||||
|
|
||||||
return rootfs_size
|
return rootfs_size
|
||||||
|
|
||||||
@@ -128,9 +132,10 @@ class Partition():
|
|||||||
"""
|
"""
|
||||||
if not self.source:
|
if not self.source:
|
||||||
if not self.size and not self.fixed_size:
|
if not self.size and not self.fixed_size:
|
||||||
msger.error("The %s partition has a size of zero. Please "
|
logger.error("The %s partition has a size of zero. Please "
|
||||||
"specify a non-zero --size/--fixed-size for that partition." % \
|
"specify a non-zero --size/--fixed-size for that "
|
||||||
self.mountpoint)
|
"partition.", self.mountpoint)
|
||||||
|
sys.exit(1)
|
||||||
if self.fstype and self.fstype == "swap":
|
if self.fstype and self.fstype == "swap":
|
||||||
self.prepare_swap_partition(cr_workdir, oe_builddir,
|
self.prepare_swap_partition(cr_workdir, oe_builddir,
|
||||||
native_sysroot)
|
native_sysroot)
|
||||||
@@ -152,11 +157,12 @@ class Partition():
|
|||||||
plugins = pluginmgr.get_source_plugins()
|
plugins = pluginmgr.get_source_plugins()
|
||||||
|
|
||||||
if self.source not in plugins:
|
if self.source not in plugins:
|
||||||
msger.error("The '%s' --source specified for %s doesn't exist.\n\t"
|
logger.error("The '%s' --source specified for %s doesn't exist.\n\t"
|
||||||
"See 'wic list source-plugins' for a list of available"
|
"See 'wic list source-plugins' for a list of available"
|
||||||
" --sources.\n\tSee 'wic help source-plugins' for "
|
" --sources.\n\tSee 'wic help source-plugins' for "
|
||||||
"details on adding a new source plugin." % \
|
"details on adding a new source plugin.",
|
||||||
(self.source, self.mountpoint))
|
self.source, self.mountpoint)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
srcparams_dict = {}
|
srcparams_dict = {}
|
||||||
if self.sourceparams:
|
if self.sourceparams:
|
||||||
@@ -186,15 +192,16 @@ class Partition():
|
|||||||
# further processing required Partition.size to be an integer, make
|
# further processing required Partition.size to be an integer, make
|
||||||
# sure that it is one
|
# sure that it is one
|
||||||
if not isinstance(self.size, int):
|
if not isinstance(self.size, int):
|
||||||
msger.error("Partition %s internal size is not an integer. " \
|
logger.error("Partition %s internal size is not an integer. "
|
||||||
"This a bug in source plugin %s and needs to be fixed." \
|
"This a bug in source plugin %s and needs to be fixed.",
|
||||||
% (self.mountpoint, self.source))
|
self.mountpoint, self.source)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if self.fixed_size and self.size > self.fixed_size:
|
if self.fixed_size and self.size > self.fixed_size:
|
||||||
msger.error("File system image of partition %s is larger (%d kB) than its"\
|
logger.error("File system image of partition %s is larger (%d kB) "
|
||||||
"allowed size %d kB" % (self.mountpoint,
|
"than its allowed size %d kB",
|
||||||
self.size, self.fixed_size))
|
self.mountpoint, self.size, self.fixed_size)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir,
|
def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir,
|
||||||
rootfs_dir):
|
rootfs_dir):
|
||||||
@@ -234,8 +241,9 @@ class Partition():
|
|||||||
os.remove(rootfs)
|
os.remove(rootfs)
|
||||||
|
|
||||||
if not self.fstype:
|
if not self.fstype:
|
||||||
msger.error("File system for partition %s not specified in kickstart, " \
|
logger.error("File system for partition %s not specified in kickstart, "
|
||||||
"use --fstype option" % (self.mountpoint))
|
"use --fstype option", self.mountpoint)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Get rootfs size from bitbake variable if it's not set in .ks file
|
# Get rootfs size from bitbake variable if it's not set in .ks file
|
||||||
if not self.size:
|
if not self.size:
|
||||||
@@ -245,10 +253,10 @@ class Partition():
|
|||||||
# IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE
|
# IMAGE_OVERHEAD_FACTOR and IMAGE_ROOTFS_EXTRA_SPACE
|
||||||
rsize_bb = get_bitbake_var('ROOTFS_SIZE')
|
rsize_bb = get_bitbake_var('ROOTFS_SIZE')
|
||||||
if rsize_bb:
|
if rsize_bb:
|
||||||
msger.warning('overhead-factor was specified, but size was not,'
|
logger.warning('overhead-factor was specified, but size was not,'
|
||||||
' so bitbake variables will be used for the size.'
|
' so bitbake variables will be used for the size.'
|
||||||
' In this case both IMAGE_OVERHEAD_FACTOR and '
|
' In this case both IMAGE_OVERHEAD_FACTOR and '
|
||||||
'--overhead-factor will be applied')
|
'--overhead-factor will be applied')
|
||||||
self.size = int(round(float(rsize_bb)))
|
self.size = int(round(float(rsize_bb)))
|
||||||
|
|
||||||
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
|
for prefix in ("ext", "btrfs", "vfat", "squashfs"):
|
||||||
@@ -404,8 +412,8 @@ class Partition():
|
|||||||
"""
|
"""
|
||||||
Prepare an empty squashfs partition.
|
Prepare an empty squashfs partition.
|
||||||
"""
|
"""
|
||||||
msger.warning("Creating of an empty squashfs %s partition was attempted. " \
|
logger.warning("Creating of an empty squashfs %s partition was attempted. "
|
||||||
"Proceeding as requested." % self.mountpoint)
|
"Proceeding as requested.", self.mountpoint)
|
||||||
|
|
||||||
path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
|
path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
from wic import msger
|
|
||||||
from wic import pluginbase
|
from wic import pluginbase
|
||||||
from wic.utils import errors
|
from wic.utils import errors
|
||||||
from wic.utils.misc import get_bitbake_var
|
from wic.utils.misc import get_bitbake_var
|
||||||
@@ -30,6 +30,8 @@ PLUGIN_TYPES = ["imager", "source"]
|
|||||||
PLUGIN_DIR = "/lib/wic/plugins" # relative to scripts
|
PLUGIN_DIR = "/lib/wic/plugins" # relative to scripts
|
||||||
SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR
|
SCRIPTS_PLUGIN_DIR = "scripts" + PLUGIN_DIR
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
class PluginMgr():
|
class PluginMgr():
|
||||||
plugin_dirs = {}
|
plugin_dirs = {}
|
||||||
|
|
||||||
@@ -91,17 +93,16 @@ class PluginMgr():
|
|||||||
if mod and mod != '__init__':
|
if mod and mod != '__init__':
|
||||||
if mod in sys.modules:
|
if mod in sys.modules:
|
||||||
#self.plugin_dirs[pdir] = True
|
#self.plugin_dirs[pdir] = True
|
||||||
msger.warning("Module %s already exists, skip" % mod)
|
logger.warning("Module %s already exists, skip", mod)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
pymod = __import__(mod)
|
pymod = __import__(mod)
|
||||||
self.plugin_dirs[pdir] = True
|
self.plugin_dirs[pdir] = True
|
||||||
msger.debug("Plugin module %s:%s imported"\
|
logger.debug("Plugin module %s:%s imported",
|
||||||
% (mod, pymod.__file__))
|
mod, pymod.__file__)
|
||||||
except ImportError as err:
|
except ImportError as err:
|
||||||
msg = 'Failed to load plugin %s/%s: %s' \
|
logger.warning('Failed to load plugin %s/%s: %s',
|
||||||
% (os.path.basename(pdir), mod, err)
|
os.path.basename(pdir), mod, err)
|
||||||
msger.warning(msg)
|
|
||||||
|
|
||||||
del sys.path[0]
|
del sys.path[0]
|
||||||
|
|
||||||
@@ -140,8 +141,8 @@ class PluginMgr():
|
|||||||
if _source_name == source_name:
|
if _source_name == source_name:
|
||||||
for _method_name in methods:
|
for _method_name in methods:
|
||||||
if not hasattr(klass, _method_name):
|
if not hasattr(klass, _method_name):
|
||||||
msger.warning("Unimplemented %s source interface for: %s"\
|
logger.warning("Unimplemented %s source interface for: %s",
|
||||||
% (_method_name, _source_name))
|
_method_name, _source_name)
|
||||||
return None
|
return None
|
||||||
func = getattr(klass, _method_name)
|
func = getattr(klass, _method_name)
|
||||||
methods[_method_name] = func
|
methods[_method_name] = func
|
||||||
|
|||||||
@@ -17,9 +17,11 @@
|
|||||||
|
|
||||||
__all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins']
|
__all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins']
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from wic import msger
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
class PluginMeta(type):
|
class PluginMeta(type):
|
||||||
plugins = defaultdict(dict)
|
plugins = defaultdict(dict)
|
||||||
@@ -49,7 +51,7 @@ class SourcePlugin(PluginMeta("Plugin", (), {})):
|
|||||||
disk image. This provides a hook to allow finalization of a
|
disk image. This provides a hook to allow finalization of a
|
||||||
disk image e.g. to write an MBR to it.
|
disk image e.g. to write an MBR to it.
|
||||||
"""
|
"""
|
||||||
msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name)
|
logger.debug("SourcePlugin: do_install_disk: disk: %s", disk_name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_stage_partition(cls, part, source_params, creator, cr_workdir,
|
def do_stage_partition(cls, part, source_params, creator, cr_workdir,
|
||||||
@@ -66,7 +68,7 @@ class SourcePlugin(PluginMeta("Plugin", (), {})):
|
|||||||
Not that get_bitbake_var() allows you to acces non-standard
|
Not that get_bitbake_var() allows you to acces non-standard
|
||||||
variables that you might want to use for this.
|
variables that you might want to use for this.
|
||||||
"""
|
"""
|
||||||
msger.debug("SourcePlugin: do_stage_partition: part: %s" % part)
|
logger.debug("SourcePlugin: do_stage_partition: part: %s", part)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_configure_partition(cls, part, source_params, creator, cr_workdir,
|
def do_configure_partition(cls, part, source_params, creator, cr_workdir,
|
||||||
@@ -77,7 +79,7 @@ class SourcePlugin(PluginMeta("Plugin", (), {})):
|
|||||||
custom configuration files for a partition, for example
|
custom configuration files for a partition, for example
|
||||||
syslinux or grub config files.
|
syslinux or grub config files.
|
||||||
"""
|
"""
|
||||||
msger.debug("SourcePlugin: do_configure_partition: part: %s" % part)
|
logger.debug("SourcePlugin: do_configure_partition: part: %s", part)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
|
def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
|
||||||
@@ -87,7 +89,7 @@ class SourcePlugin(PluginMeta("Plugin", (), {})):
|
|||||||
Called to do the actual content population for a partition i.e. it
|
Called to do the actual content population for a partition i.e. it
|
||||||
'prepares' the partition to be incorporated into the image.
|
'prepares' the partition to be incorporated into the image.
|
||||||
"""
|
"""
|
||||||
msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part)
|
logger.debug("SourcePlugin: do_prepare_partition: part: %s", part)
|
||||||
|
|
||||||
def get_plugins(typen):
|
def get_plugins(typen):
|
||||||
return PluginMeta.plugins.get(typen)
|
return PluginMeta.plugins.get(typen)
|
||||||
|
|||||||
@@ -26,14 +26,17 @@
|
|||||||
#
|
#
|
||||||
"""Miscellaneous functions."""
|
"""Miscellaneous functions."""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from distutils import spawn
|
from distutils import spawn
|
||||||
|
|
||||||
from wic import msger
|
|
||||||
from wic.utils import runner
|
from wic.utils import runner
|
||||||
|
|
||||||
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
# executable -> recipe pairs for exec_native_cmd
|
# executable -> recipe pairs for exec_native_cmd
|
||||||
NATIVE_RECIPES = {"bmaptool": "bmap-tools",
|
NATIVE_RECIPES = {"bmaptool": "bmap-tools",
|
||||||
"grub-mkimage": "grub-efi",
|
"grub-mkimage": "grub-efi",
|
||||||
@@ -61,9 +64,9 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
|
|||||||
|
|
||||||
Need to execute as_shell if the command uses wildcards
|
Need to execute as_shell if the command uses wildcards
|
||||||
"""
|
"""
|
||||||
msger.debug("_exec_cmd: %s" % cmd_and_args)
|
logger.debug("_exec_cmd: %s", cmd_and_args)
|
||||||
args = cmd_and_args.split()
|
args = cmd_and_args.split()
|
||||||
msger.debug(args)
|
logger.debug(args)
|
||||||
|
|
||||||
if as_shell:
|
if as_shell:
|
||||||
ret, out = runner.runtool(cmd_and_args, catch)
|
ret, out = runner.runtool(cmd_and_args, catch)
|
||||||
@@ -71,11 +74,12 @@ def _exec_cmd(cmd_and_args, as_shell=False, catch=3):
|
|||||||
ret, out = runner.runtool(args, catch)
|
ret, out = runner.runtool(args, catch)
|
||||||
out = out.strip()
|
out = out.strip()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
msger.error("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \
|
logger.error("_exec_cmd: %s returned '%s' instead of 0\noutput: %s" % \
|
||||||
(cmd_and_args, ret, out))
|
(cmd_and_args, ret, out))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
msger.debug("_exec_cmd: output for %s (rc = %d): %s" % \
|
logger.debug("_exec_cmd: output for %s (rc = %d): %s",
|
||||||
(cmd_and_args, ret, out))
|
cmd_and_args, ret, out)
|
||||||
|
|
||||||
return ret, out
|
return ret, out
|
||||||
|
|
||||||
@@ -97,7 +101,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
|
|||||||
"""
|
"""
|
||||||
# The reason -1 is used is because there may be "export" commands.
|
# The reason -1 is used is because there may be "export" commands.
|
||||||
args = cmd_and_args.split(';')[-1].split()
|
args = cmd_and_args.split(';')[-1].split()
|
||||||
msger.debug(args)
|
logger.debug(args)
|
||||||
|
|
||||||
if pseudo:
|
if pseudo:
|
||||||
cmd_and_args = pseudo + cmd_and_args
|
cmd_and_args = pseudo + cmd_and_args
|
||||||
@@ -106,7 +110,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
|
|||||||
(native_sysroot, native_sysroot, native_sysroot)
|
(native_sysroot, native_sysroot, native_sysroot)
|
||||||
native_cmd_and_args = "export PATH=%s:$PATH;%s" % \
|
native_cmd_and_args = "export PATH=%s:$PATH;%s" % \
|
||||||
(native_paths, cmd_and_args)
|
(native_paths, cmd_and_args)
|
||||||
msger.debug("exec_native_cmd: %s" % cmd_and_args)
|
logger.debug("exec_native_cmd: %s", cmd_and_args)
|
||||||
|
|
||||||
# If the command isn't in the native sysroot say we failed.
|
# If the command isn't in the native sysroot say we failed.
|
||||||
if spawn.find_executable(args[0], native_paths):
|
if spawn.find_executable(args[0], native_paths):
|
||||||
@@ -127,7 +131,7 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
|
|||||||
else:
|
else:
|
||||||
msg += "Wic failed to find a recipe to build native %s. Please "\
|
msg += "Wic failed to find a recipe to build native %s. Please "\
|
||||||
"file a bug against wic.\n" % prog
|
"file a bug against wic.\n" % prog
|
||||||
msger.error(msg)
|
logger.error(msg)
|
||||||
|
|
||||||
return ret, out
|
return ret, out
|
||||||
|
|
||||||
@@ -184,14 +188,14 @@ class BitbakeVars(defaultdict):
|
|||||||
if image:
|
if image:
|
||||||
cmd += " %s" % image
|
cmd += " %s" % image
|
||||||
|
|
||||||
log_level = msger.get_loglevel()
|
log_level = logger.getEffectiveLevel()
|
||||||
msger.set_loglevel('normal')
|
logger.setLevel(logging.INFO)
|
||||||
ret, lines = _exec_cmd(cmd)
|
ret, lines = _exec_cmd(cmd)
|
||||||
msger.set_loglevel(log_level)
|
logger.setLevel(log_level)
|
||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
print("Couldn't get '%s' output." % cmd)
|
logger.error("Couldn't get '%s' output.", cmd)
|
||||||
print("Bitbake failed with error:\n%s\n" % lines)
|
logger.error("Bitbake failed with error:\n%s\n", lines)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Parse bitbake -e output
|
# Parse bitbake -e output
|
||||||
|
|||||||
@@ -15,10 +15,12 @@
|
|||||||
# with this program; if not, write to the Free Software Foundation, Inc., 59
|
# with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||||
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from wic import msger
|
logger = logging.getLogger('wic')
|
||||||
|
|
||||||
def runtool(cmdln_or_args, catch=1):
|
def runtool(cmdln_or_args, catch=1):
|
||||||
""" wrapper for most of the subprocess calls
|
""" wrapper for most of the subprocess calls
|
||||||
@@ -70,7 +72,8 @@ def runtool(cmdln_or_args, catch=1):
|
|||||||
except OSError as err:
|
except OSError as err:
|
||||||
if err.errno == 2:
|
if err.errno == 2:
|
||||||
# [Errno 2] No such file or directory
|
# [Errno 2] No such file or directory
|
||||||
msger.error('Cannot run command: %s, lost dependency?' % cmd)
|
logger.error('Cannot run command: %s, lost dependency?', cmd)
|
||||||
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
raise # relay
|
raise # relay
|
||||||
finally:
|
finally:
|
||||||
@@ -80,7 +83,7 @@ def runtool(cmdln_or_args, catch=1):
|
|||||||
return (process.returncode, out)
|
return (process.returncode, out)
|
||||||
|
|
||||||
def show(cmdln_or_args):
|
def show(cmdln_or_args):
|
||||||
# show all the message using msger.verbose
|
"""Show all messages using logger.debug."""
|
||||||
|
|
||||||
rcode, out = runtool(cmdln_or_args, catch=3)
|
rcode, out = runtool(cmdln_or_args, catch=3)
|
||||||
|
|
||||||
@@ -99,7 +102,8 @@ def show(cmdln_or_args):
|
|||||||
msg += '\n | %s' % line
|
msg += '\n | %s' % line
|
||||||
msg += '\n +----------------'
|
msg += '\n +----------------'
|
||||||
|
|
||||||
msger.verbose(msg)
|
logger.debug(msg)
|
||||||
|
|
||||||
return rcode
|
return rcode
|
||||||
|
|
||||||
def outs(cmdln_or_args, catch=1):
|
def outs(cmdln_or_args, catch=1):
|
||||||
|
|||||||
Reference in New Issue
Block a user