wic:allow wic compile as an individual package
v2 cover wic:allow wic compile as an individual package
[V2]
Rebase patch to latest oe-core commmit.
[V1 log]
This patch set intend to allow wic compile as an individual package, then it can run both on host & target side.
On host, it invoke by image_type_wic.bbclass to as a native tool to generate wic image.
Patch 1-4 make wic compile as a native tool.
On trarget, it parse wks file, and use current rootfs & /boot folder to generated a new wic image on target.
Patch 5-6 fix a few minor issue on target.
The patch is validate with mkefidisk.wks from oe-core layer on intel x86 platform.
Assume /dev/sda2 is root device, then with following command, use could generate a new wic image
$mount /dev/sda2 /tmp/sda
$wic create /root/mkefidisk.wks -k /boot -r /tmp/sda -o /tmp/
The generated image is under /tmp with name mkefidisk-xxx-sda.direct. Then user may dump this file into another booting deivce.
Thanks
Jiang Lu
PATCH v2 1/7 wic:enable wic compile as individual package
Enable wic compile as an individual package.
--- meta/recipes-support/wic/files/setup.py | 18 ++++++++++++++++++ meta/recipes-support/wic/wic_0.2.0.bb | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 meta/recipes-support/wic/files/setup.py create mode 100644 meta/recipes-support/wic/wic_0.2.0.bb
meta/recipes-support/wic/files/setup.py new file +18 -0
@@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +import os +from distutils.core import setup + +packages = [ + "wic", + "wic/plugins/imager", + "wic/plugins/source", + ] + +setup(name = "wic", + version="0.2.0", + description="wic' is the OpenEmbedded Image Creator", + author="Tom Zanussi", + author_email="[email protected]", + packages=packages +)
meta/recipes-support/wic/wic_0.2.0.bb new file +24 -0
@@ -0,0 +1,24 @@ +SUMMARY = "Wic installer script" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +RDEPENDS_${PN} += "mtools" + +SRC_URI = " \ + file://wic.py \ + file://setup.py \ + file://wic \ +" + +FILESEXTRAPATHS_prepend := "${THISDIR}:${THISDIR}/files:" + +S = "${WORKDIR}/" + +inherit setuptools3 + +do_install_append() { + install -d 0755 ${D}/${bindir} + install -m 0755 ${S}/wic.py ${D}${bindir}/wic +} + +BBCLASSEXTEND = "native"
Signature · 1 line
2.7.4
PATCH v2 2/7 wic:move wic src into meta/receipt-support/wic
In reply to Jiang LuMove wic src into package directory.
--- meta/recipes-support/wic/files/wic.py | 542 ++++++++++ meta/recipes-support/wic/files/wic/__init__.py | 20 + meta/recipes-support/wic/files/wic/engine.py | 578 +++++++++++ meta/recipes-support/wic/files/wic/filemap.py | 600 +++++++++++ meta/recipes-support/wic/files/wic/help.py | 1055 ++++++++++++++++++++ meta/recipes-support/wic/files/wic/ksparser.py | 235 +++++ meta/recipes-support/wic/files/wic/misc.py | 263 +++++ meta/recipes-support/wic/files/wic/partition.py | 424 ++++++++ meta/recipes-support/wic/files/wic/pluginbase.py | 149 +++ .../wic/files/wic/plugins/imager/direct.py | 611 ++++++++++++ .../wic/files/wic/plugins/source/bootimg-efi.py | 274 +++++ .../files/wic/plugins/source/bootimg-partition.py | 207 ++++ .../wic/files/wic/plugins/source/bootimg-pcbios.py | 207 ++++ .../files/wic/plugins/source/isoimage-isohybrid.py | 443 ++++++++ .../wic/files/wic/plugins/source/rawcopy.py | 91 ++ .../wic/files/wic/plugins/source/rootfs.py | 126 +++ scripts/lib/wic/__init__.py | 20 - scripts/lib/wic/engine.py | 578 ----------- scripts/lib/wic/filemap.py | 600 ----------- scripts/lib/wic/help.py | 1055 -------------------- scripts/lib/wic/ksparser.py | 235 ----- scripts/lib/wic/misc.py | 263 ----- scripts/lib/wic/partition.py | 424 -------- scripts/lib/wic/pluginbase.py | 149 --- scripts/lib/wic/plugins/imager/direct.py | 611 ------------ scripts/lib/wic/plugins/source/bootimg-efi.py | 274 ----- .../lib/wic/plugins/source/bootimg-partition.py | 207 ---- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 207 ---- .../lib/wic/plugins/source/isoimage-isohybrid.py | 443 -------- scripts/lib/wic/plugins/source/rawcopy.py | 91 -- scripts/lib/wic/plugins/source/rootfs.py | 126 --- scripts/wic | 542 ---------- 32 files changed, 5825 insertions(+), 5825 deletions(-) create mode 100755 meta/recipes-support/wic/files/wic.py create mode 100644 meta/recipes-support/wic/files/wic/__init__.py create mode 100644 meta/recipes-support/wic/files/wic/engine.py create mode 100644 meta/recipes-support/wic/files/wic/filemap.py create mode 100644 meta/recipes-support/wic/files/wic/help.py create mode 100644 meta/recipes-support/wic/files/wic/ksparser.py create mode 100644 meta/recipes-support/wic/files/wic/misc.py create mode 100644 meta/recipes-support/wic/files/wic/partition.py create mode 100644 meta/recipes-support/wic/files/wic/pluginbase.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/imager/direct.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/bootimg-partition.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/bootimg-pcbios.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/isoimage-isohybrid.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/rawcopy.py create mode 100644 meta/recipes-support/wic/files/wic/plugins/source/rootfs.py delete mode 100644 scripts/lib/wic/__init__.py delete mode 100644 scripts/lib/wic/engine.py delete mode 100644 scripts/lib/wic/filemap.py delete mode 100644 scripts/lib/wic/help.py delete mode 100644 scripts/lib/wic/ksparser.py delete mode 100644 scripts/lib/wic/misc.py delete mode 100644 scripts/lib/wic/partition.py delete mode 100644 scripts/lib/wic/pluginbase.py delete mode 100644 scripts/lib/wic/plugins/imager/direct.py delete mode 100644 scripts/lib/wic/plugins/source/bootimg-efi.py delete mode 100644 scripts/lib/wic/plugins/source/bootimg-partition.py delete mode 100644 scripts/lib/wic/plugins/source/bootimg-pcbios.py delete mode 100644 scripts/lib/wic/plugins/source/isoimage-isohybrid.py delete mode 100644 scripts/lib/wic/plugins/source/rawcopy.py delete mode 100644 scripts/lib/wic/plugins/source/rootfs.py delete mode 100755 scripts/wic
meta/recipes-support/wic/files/wic.py new file +542 -0
@@ -0,0 +1,542 @@ +#!/usr/bin/env python3 +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# Copyright (c) 2013, 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 'wic' is the OpenEmbedded Image Creator that users can +# use to generate bootable images. Invoking it without any arguments +# will display help screens for the 'wic' command and list the +# available 'wic' subcommands. Invoking a subcommand without any +# arguments will likewise display help screens for the specified +# subcommand. Please use that interface for detailed help. +# +# AUTHORS +# Tom Zanussi <tom.zanussi (at] linux.intel.com> +# +__version__ = "0.2.0" + +# Python Standard Library modules +import os +import sys +import argparse +import logging + +from collections import namedtuple +from distutils import spawn + +# External modules +scripts_path = os.path.dirname(os.path.realpath(__file__)) +lib_path = scripts_path + '/lib' +sys.path.insert(0, lib_path) +import scriptpath +scriptpath.add_oe_lib_path() + +# Check whether wic is running within eSDK environment +sdkroot = scripts_path +if os.environ.get('SDKTARGETSYSROOT'): + while sdkroot != '' and sdkroot != os.sep: + if os.path.exists(os.path.join(sdkroot, '.devtoolbase')): + # Set BUILDDIR for wic to work within eSDK + os.environ['BUILDDIR'] = sdkroot + # .devtoolbase only exists within eSDK + # If found, initialize bitbake path for eSDK environment and append to PATH + sdkroot = os.path.join(os.path.dirname(scripts_path), 'bitbake', 'bin') + os.environ['PATH'] += ":" + sdkroot + break + sdkroot = os.path.dirname(sdkroot) + +bitbake_exe = spawn.find_executable('bitbake') +if bitbake_exe: + bitbake_path = scriptpath.add_bitbake_lib_path() + from bb import cookerdata + from bb.main import bitbake_main, BitBakeConfigParameters +else: + bitbake_main = None + +from wic import WicError +from wic.misc import get_bitbake_var, BB_VARS +from wic import engine +from wic import help as hlp + + +def wic_logger(): + """Create and convfigure wic logger.""" + logger = logging.getLogger('wic') + logger.setLevel(logging.INFO) + + handler = logging.StreamHandler() + + formatter = logging.Formatter('%(levelname)s: %(message)s') + handler.setFormatter(formatter) + + logger.addHandler(handler) + + return logger + +logger = wic_logger() + +def rootfs_dir_to_args(krootfs_dir): + """ + Get a rootfs_dir dict and serialize to string + """ + rootfs_dir = '' + for key, val in krootfs_dir.items(): + rootfs_dir += ' ' + rootfs_dir += '='.join([key, val]) + return rootfs_dir.strip() + + +class RootfsArgAction(argparse.Action): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + def __call__(self, parser, namespace, value, option_string=None): + if not "rootfs_dir" in vars(namespace) or \ + not type(namespace.__dict__['rootfs_dir']) is dict: + namespace.__dict__['rootfs_dir'] = {} + + if '=' in value: + (key, rootfs_dir) = value.split('=') + else: + key = 'ROOTFS_DIR' + rootfs_dir = value + + namespace.__dict__['rootfs_dir'][key] = rootfs_dir + + +def wic_create_subcommand(options, usage_str): + """ + Command-line handling for image creation. The real work is done + by image.engine.wic_create() + """ + if options.build_rootfs and not bitbake_main: + raise WicError("Can't build rootfs as bitbake is not in the $PATH") + + if not options.image_name: + missed = [] + for val, opt in [(options.rootfs_dir, 'rootfs-dir'), + (options.bootimg_dir, 'bootimg-dir'), + (options.kernel_dir, 'kernel-dir'), + (options.native_sysroot, 'native-sysroot')]: + if not val: + missed.append(opt) + if missed: + raise WicError("The following build artifacts are not specified: %s" % + ", ".join(missed)) + + if options.image_name: + BB_VARS.default_image = options.image_name + else: + options.build_check = False + + if options.vars_dir: + BB_VARS.vars_dir = options.vars_dir + + if options.build_check and not engine.verify_build_env(): + raise WicError("Couldn't verify build environment, exiting") + + if options.debug: + logger.setLevel(logging.DEBUG) + + if options.image_name: + if options.build_rootfs: + argv = ["bitbake", options.image_name] + if options.debug: + argv.append("--debug") + + logger.info("Building rootfs...\n") + if bitbake_main(BitBakeConfigParameters(argv), + cookerdata.CookerConfiguration()): + raise WicError("bitbake exited with error") + + rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) + kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) + bootimg_dir = get_bitbake_var("STAGING_DATADIR", options.image_name) + + native_sysroot = options.native_sysroot + if options.vars_dir and not native_sysroot: + native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", options.image_name) + else: + if options.build_rootfs: + raise WicError("Image name is not specified, exiting. " + "(Use -e/--image-name to specify it)") + native_sysroot = options.native_sysroot + + if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): + logger.info("Building wic-tools...\n") + if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), + cookerdata.CookerConfiguration()): + raise WicError("bitbake wic-tools failed") + native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") + + if not native_sysroot: + raise WicError("Unable to find the location of the native tools sysroot") + + wks_file = options.wks_file + + if not wks_file.endswith(".wks"): + wks_file = engine.find_canned_image(scripts_path, wks_file) + if not wks_file: + raise WicError("No image named %s found, exiting. (Use 'wic list images' " + "to list available images, or specify a fully-qualified OE " + "kickstart (.wks) filename)" % options.wks_file) + + if not options.image_name: + rootfs_dir = '' + if 'ROOTFS_DIR' in options.rootfs_dir: + rootfs_dir = options.rootfs_dir['ROOTFS_DIR'] + bootimg_dir = options.bootimg_dir + kernel_dir = options.kernel_dir + native_sysroot = options.native_sysroot + if rootfs_dir and not os.path.isdir(rootfs_dir): + raise WicError("--rootfs-dir (-r) not found, exiting") + if not os.path.isdir(bootimg_dir): + raise WicError("--bootimg-dir (-b) not found, exiting") + if not os.path.isdir(kernel_dir): + raise WicError("--kernel-dir (-k) not found, exiting") + if not os.path.isdir(native_sysroot): + raise WicError("--native-sysroot (-n) not found, exiting") + else: + not_found = not_found_dir = "" + if not os.path.isdir(rootfs_dir): + (not_found, not_found_dir) = ("rootfs-dir", rootfs_dir) + elif not os.path.isdir(kernel_dir): + (not_found, not_found_dir) = ("kernel-dir", kernel_dir) + elif not os.path.isdir(native_sysroot): + (not_found, not_found_dir) = ("native-sysroot", native_sysroot) + if not_found: + if not not_found_dir: + not_found_dir = "Completely missing artifact - wrong image (.wks) used?" + logger.info("Build artifacts not found, exiting.") + logger.info(" (Please check that the build artifacts for the machine") + logger.info(" selected in local.conf actually exist and that they") + logger.info(" are the correct artifacts for the image (.wks file)).\n") + raise WicError("The artifact that couldn't be found was %s:\n %s", not_found, not_found_dir) + + krootfs_dir = options.rootfs_dir + if krootfs_dir is None: + krootfs_dir = {} + krootfs_dir['ROOTFS_DIR'] = rootfs_dir + + rootfs_dir = rootfs_dir_to_args(krootfs_dir) + + logger.info("Creating image(s)...\n") + engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, + native_sysroot, options) + + +def wic_list_subcommand(args, usage_str): + """ + Command-line handling for listing available images. + The real work is done by image.engine.wic_list() + """ + if not engine.wic_list(args, scripts_path): + raise WicError("Bad list arguments, exiting") + + +def wic_ls_subcommand(args, usage_str): + """ + Command-line handling for list content of images. + The real work is done by engine.wic_ls() + """ + engine.wic_ls(args, args.native_sysroot) + +def wic_cp_subcommand(args, usage_str): + """ + Command-line handling for copying files/dirs to images. + The real work is done by engine.wic_cp() + """ + engine.wic_cp(args, args.native_sysroot) + +def wic_rm_subcommand(args, usage_str): + """ + Command-line handling for removing files/dirs from images. + The real work is done by engine.wic_rm() + """ + engine.wic_rm(args, args.native_sysroot) + +def wic_write_subcommand(args, usage_str): + """ + Command-line handling for writing images. + The real work is done by engine.wic_write() + """ + engine.wic_write(args, args.native_sysroot) + +def wic_help_subcommand(args, usage_str): + """ + Command-line handling for help subcommand to keep the current + structure of the function definitions. + """ + pass + + +def wic_help_topic_subcommand(usage_str, help_str): + """ + Display function for help 'sub-subcommands'. + """ + print(help_str) + return + + +wic_help_topic_usage = """ +""" + +helptopics = { + "plugins": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_plugins_help], + "overview": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_overview_help], + "kickstart": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_kickstart_help], + "create": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_create_help], + "ls": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_ls_help], + "cp": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_cp_help], + "rm": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_rm_help], + "write": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_write_help], + "list": [wic_help_topic_subcommand, + wic_help_topic_usage, + hlp.wic_list_help] +} + + +def wic_init_parser_create(subparser): + subparser.add_argument("wks_file") + + subparser.add_argument("-o", "--outdir", dest="outdir", default='.', + help="name of directory to create image in") + subparser.add_argument("-e", "--image-name", dest="image_name", + help="name of the image to use the artifacts from " + "e.g. core-image-sato") + subparser.add_argument("-r", "--rootfs-dir", action=RootfsArgAction, + help="path to the /rootfs dir to use as the " + ".wks rootfs source") + subparser.add_argument("-b", "--bootimg-dir", dest="bootimg_dir", + help="path to the dir containing the boot artifacts " + "(e.g. /EFI or /syslinux dirs) to use as the " + ".wks bootimg source") + subparser.add_argument("-k", "--kernel-dir", dest="kernel_dir", + help="path to the dir containing the kernel to use " + "in the .wks bootimg") + subparser.add_argument("-n", "--native-sysroot", dest="native_sysroot", + help="path to the native sysroot containing the tools " + "to use to build the image") + subparser.add_argument("-s", "--skip-build-check", dest="build_check", + action="store_false", default=True, help="skip the build check") + subparser.add_argument("-f", "--build-rootfs", action="store_true", help="build rootfs") + subparser.add_argument("-c", "--compress-with", choices=("gzip", "bzip2", "xz"), + dest='compressor', + help="compress image with specified compressor") + subparser.add_argument("-m", "--bmap", action="store_true", help="generate .bmap") + subparser.add_argument("--no-fstab-update" ,action="store_true", + help="Do not change fstab file.") + subparser.add_argument("-v", "--vars", dest='vars_dir', + help="directory with <image>.env files that store " + "bitbake variables") + subparser.add_argument("-D", "--debug", dest="debug", action="store_true", + default=False, help="output debug information") + return + + +def wic_init_parser_list(subparser): + subparser.add_argument("list_type", + help="can be 'images' or 'source-plugins' " + "to obtain a list. " + "If value is a valid .wks image file") + subparser.add_argument("help_for", default=[], nargs='*', + help="If 'list_type' is a valid .wks image file " + "this value can be 'help' to show the help information " + "defined inside the .wks file") + return + +def imgtype(arg): + """ + Custom type for ArgumentParser + Converts path spec to named tuple: (image, partition, path) + """ + image = arg + part = path = None + if ':' in image: + image, part = image.split(':') + if '/' in part: + part, path = part.split('/', 1) + if not path: + path = '/' + + if not os.path.isfile(image): + err = "%s is not a regular file or symlink" % image + raise argparse.ArgumentTypeError(err) + + return namedtuple('ImgType', 'image part path')(image, part, path) + +def wic_init_parser_ls(subparser): + subparser.add_argument("path", type=imgtype, + help="image spec: <image>[:<vfat partition>[<path>]]") + subparser.add_argument("-n", "--native-sysroot", + help="path to the native sysroot containing the tools") + +def imgpathtype(arg): + img = imgtype(arg) + if img.part is None: + raise argparse.ArgumentTypeError("partition number is not specified") + return img + +def wic_init_parser_cp(subparser): + subparser.add_argument("src", + help="source spec") + subparser.add_argument("dest", type=imgpathtype, + help="image spec: <image>:<vfat partition>[<path>]") + subparser.add_argument("-n", "--native-sysroot", + help="path to the native sysroot containing the tools") + +def wic_init_parser_rm(subparser): + subparser.add_argument("path", type=imgpathtype, + help="path: <image>:<vfat partition><path>") + subparser.add_argument("-n", "--native-sysroot", + help="path to the native sysroot containing the tools") + +def expandtype(rules): + """ + Custom type for ArgumentParser + Converts expand rules to the dictionary {<partition>: size} + """ + if rules == 'auto': + return {} + result = {} + for rule in rules.split('-'): + try: + part, size = rule.split(':') + except ValueError: + raise argparse.ArgumentTypeError("Incorrect rule format: %s" % rule) + + if not part.isdigit(): + raise argparse.ArgumentTypeError("Rule '%s': partition number must be integer" % rule) + + # validate size + multiplier = 1 + for suffix, mult in [('K', 1024), ('M', 1024 * 1024), ('G', 1024 * 1024 * 1024)]: + if size.upper().endswith(suffix): + multiplier = mult + size = size[:-1] + break + if not size.isdigit(): + raise argparse.ArgumentTypeError("Rule '%s': size must be integer" % rule) + + result[int(part)] = int(size) * multiplier + + return result + +def wic_init_parser_write(subparser): + subparser.add_argument("image", + help="path to the wic image") + subparser.add_argument("target", + help="target file or device") + subparser.add_argument("-e", "--expand", type=expandtype, + help="expand rules: auto or <partition>:<size>[,<partition>:<size>]") + subparser.add_argument("-n", "--native-sysroot", + help="path to the native sysroot containing the tools") + +def wic_init_parser_help(subparser): + helpparsers = subparser.add_subparsers(dest='help_topic', help=hlp.wic_usage) + for helptopic in helptopics: + helpparsers.add_parser(helptopic, help=helptopics[helptopic][2]) + return + + +subcommands = { + "create": [wic_create_subcommand, + hlp.wic_create_usage, + hlp.wic_create_help, + wic_init_parser_create], + "list": [wic_list_subcommand, + hlp.wic_list_usage, + hlp.wic_list_help, + wic_init_parser_list], + "ls": [wic_ls_subcommand, + hlp.wic_ls_usage, + hlp.wic_ls_help, + wic_init_parser_ls], + "cp": [wic_cp_subcommand, + hlp.wic_cp_usage, + hlp.wic_cp_help, + wic_init_parser_cp], + "rm": [wic_rm_subcommand, + hlp.wic_rm_usage, + hlp.wic_rm_help, + wic_init_parser_rm], + "write": [wic_write_subcommand, + hlp.wic_write_usage, + hlp.wic_write_help, + wic_init_parser_write], + "help": [wic_help_subcommand, + wic_help_topic_usage, + hlp.wic_help_help, + wic_init_parser_help] +} + + +def init_parser(parser): + parser.add_argument("--version", action="version", + version="%(prog)s {version}".format(version=__version__)) + subparsers = parser.add_subparsers(dest='command', help=hlp.wic_usage) + for subcmd in subcommands: + subparser = subparsers.add_parser(subcmd, help=subcommands[subcmd][2]) + subcommands[subcmd][3](subparser) + + +def main(argv): + parser = argparse.ArgumentParser( + description="wic version %s" % __version__) + + init_parser(parser) + + args = parser.parse_args(argv) + + if "command" in vars(args): + if args.command == "help": + if args.help_topic is None: + parser.print_help() + print() + print("Please specify a help topic") + elif args.help_topic in helptopics: + hlpt = helptopics[args.help_topic] + hlpt[0](hlpt[1], hlpt[2]) + return 0 + + return hlp.invoke_subcommand(args, parser, hlp.wic_help_usage, subcommands) + + +if __name__ == "__main__": + try: + sys.exit(main(sys.argv[1:])) + except WicError as err: + print() + logger.error(err) + sys.exit(1)
meta/recipes-support/wic/files/wic/__init__.py new file +20 -0
@@ -0,0 +1,20 @@ +#!/usr/bin/env python -tt +# +# Copyright (c) 2007 Red Hat, Inc. +# 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. + +class WicError(Exception): + pass
meta/recipes-support/wic/files/wic/engine.py new file +578 -0
578 lines not on this page · raw message
meta/recipes-support/wic/files/wic/filemap.py new file +600 -0
600 lines not on this page · raw message
meta/recipes-support/wic/files/wic/help.py new file +1055 -0
1,055 lines not on this page · raw message
meta/recipes-support/wic/files/wic/ksparser.py new file +235 -0
205 lines not on this page · raw message
meta/recipes-support/wic/files/wic/misc.py new file +263 -0
263 lines not on this page · raw message
meta/recipes-support/wic/files/wic/partition.py new file +424 -0
424 lines not on this page · raw message
meta/recipes-support/wic/files/wic/pluginbase.py new file +149 -0
149 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/imager/direct.py new file +611 -0
611 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py new file +274 -0
274 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/bootimg-partition.py new file +207 -0
207 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/bootimg-pcbios.py new file +207 -0
207 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/isoimage-isohybrid.py new file +443 -0
443 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/rawcopy.py new file +91 -0
91 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/source/rootfs.py new file +126 -0
126 lines not on this page · raw message
scripts/lib/wic/engine.py deleted +0 -578
578 lines not on this page · raw message
scripts/lib/wic/filemap.py deleted +0 -600
600 lines not on this page · raw message
scripts/lib/wic/help.py deleted +0 -1055
1,055 lines not on this page · raw message
scripts/lib/wic/ksparser.py deleted +0 -235
235 lines not on this page · raw message
scripts/lib/wic/misc.py deleted +0 -263
263 lines not on this page · raw message
scripts/lib/wic/partition.py deleted +0 -424
424 lines not on this page · raw message
scripts/lib/wic/pluginbase.py deleted +0 -149
149 lines not on this page · raw message
scripts/lib/wic/plugins/imager/direct.py deleted +0 -611
611 lines not on this page · raw message
scripts/lib/wic/plugins/source/bootimg-efi.py deleted +0 -274
274 lines not on this page · raw message
scripts/lib/wic/plugins/source/bootimg-partition.py deleted +0 -207
207 lines not on this page · raw message
scripts/lib/wic/plugins/source/bootimg-pcbios.py deleted +0 -207
207 lines not on this page · raw message
scripts/lib/wic/plugins/source/isoimage-isohybrid.py deleted +0 -443
443 lines not on this page · raw message
scripts/lib/wic/plugins/source/rawcopy.py deleted +0 -91
91 lines not on this page · raw message
scripts/lib/wic/plugins/source/rootfs.py deleted +0 -126
126 lines not on this page · raw message
scripts/wic deleted +0 -542
542 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.7.4
Part of the diff is not shown here. View the raw message.
Re: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
Quoted 29 lines · Jiang Lu
Move wic src into package directory.
Signed-off-by Jiang Lu <[email protected]>--- meta/recipes-support/wic/files/wic.py | 542 ++++++++++ meta/recipes-support/wic/files/wic/__init__.py | 20 + meta/recipes-support/wic/files/wic/engine.py | 578 +++++++++++ meta/recipes-support/wic/files/wic/filemap.py | 600 +++++++++++ meta/recipes-support/wic/files/wic/help.py | 1055 ++++++++++++++++++++ meta/recipes-support/wic/files/wic/ksparser.py | 235 +++++ meta/recipes-support/wic/files/wic/misc.py | 263 +++++ meta/recipes-support/wic/files/wic/partition.py | 424 ++++++++ meta/recipes-support/wic/files/wic/pluginbase.py | 149 +++ .../wic/files/wic/plugins/imager/direct.py | 611 ++++++++++++ .../wic/files/wic/plugins/source/bootimg-efi.py | 274 +++++ .../files/wic/plugins/source/bootimg-partition.py | 207 ++++ .../wic/files/wic/plugins/source/bootimg-pcbios.py | 207 ++++ .../files/wic/plugins/source/isoimage-isohybrid.py | 443 ++++++++ .../wic/files/wic/plugins/source/rawcopy.py | 91 ++ .../wic/files/wic/plugins/source/rootfs.py | 126 +++ scripts/lib/wic/__init__.py | 20 - scripts/lib/wic/engine.py | 578 ----------- scripts/lib/wic/filemap.py | 600 ----------- scripts/lib/wic/help.py | 1055 -------------------- scripts/lib/wic/ksparser.py | 235 ----- scripts/lib/wic/misc.py | 263 ----- scripts/lib/wic/partition.py | 424 -------- scripts/lib/wic/pluginbase.py | 149 --- scripts/lib/wic/plugins/imager/direct.py | 611 ------------
Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg-efi.py | 274 ----- .../lib/wic/plugins/source/bootimg-partition.py | 207 ---- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 207 ---- .../lib/wic/plugins/source/isoimage-isohybrid.py | 443 -------- scripts/lib/wic/plugins/source/rawcopy.py | 91 -- scripts/lib/wic/plugins/source/rootfs.py | 126 --- scripts/wic | 542 ---------- 32 files changed, 5825 insertions(+), 5825 deletions(-)
Please re-format this with -M so that git determines the renames and this becomes reviewable, thanks!
Signature · 1 line
Tom
Re: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
This patch simply move code from script/lib/wic into meta/recipes-support/wic/files. I didn't touch code in this patch.
Please see attachment for patch formatted with -M.
Thanks
Jiang Lu
Quoted 39 lines · Tom Rini
Quoted 29 lines · Jiang Lu
Move wic src into package directory.
Signed-off-by Jiang Lu <[email protected]>--- meta/recipes-support/wic/files/wic.py | 542 ++++++++++ meta/recipes-support/wic/files/wic/__init__.py | 20 + meta/recipes-support/wic/files/wic/engine.py | 578 +++++++++++ meta/recipes-support/wic/files/wic/filemap.py | 600 +++++++++++ meta/recipes-support/wic/files/wic/help.py | 1055 ++++++++++++++++++++ meta/recipes-support/wic/files/wic/ksparser.py | 235 +++++ meta/recipes-support/wic/files/wic/misc.py | 263 +++++ meta/recipes-support/wic/files/wic/partition.py | 424 ++++++++ meta/recipes-support/wic/files/wic/pluginbase.py | 149 +++ .../wic/files/wic/plugins/imager/direct.py | 611 ++++++++++++ .../wic/files/wic/plugins/source/bootimg-efi.py | 274 +++++ .../files/wic/plugins/source/bootimg-partition.py | 207 ++++ .../wic/files/wic/plugins/source/bootimg-pcbios.py | 207 ++++ .../files/wic/plugins/source/isoimage-isohybrid.py | 443 ++++++++ .../wic/files/wic/plugins/source/rawcopy.py | 91 ++ .../wic/files/wic/plugins/source/rootfs.py | 126 +++ scripts/lib/wic/__init__.py | 20 - scripts/lib/wic/engine.py | 578 ----------- scripts/lib/wic/filemap.py | 600 ----------- scripts/lib/wic/help.py | 1055 -------------------- scripts/lib/wic/ksparser.py | 235 ----- scripts/lib/wic/misc.py | 263 ----- scripts/lib/wic/partition.py | 424 -------- scripts/lib/wic/pluginbase.py | 149 --- scripts/lib/wic/plugins/imager/direct.py | 611 ------------Quoted 8 lines
scripts/lib/wic/plugins/source/bootimg-efi.py | 274 ----- .../lib/wic/plugins/source/bootimg-partition.py | 207 ---- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 207 ---- .../lib/wic/plugins/source/isoimage-isohybrid.py | 443 -------- scripts/lib/wic/plugins/source/rawcopy.py | 91 -- scripts/lib/wic/plugins/source/rootfs.py | 126 --- scripts/wic | 542 ---------- 32 files changed, 5825 insertions(+), 5825 deletions(-)
Quoted 3 lines
Please re-format this with -M so that git determines the renames and this becomes reviewable, thanks!
From 17fcafe4c935f88620c765a93cde6c2527ca2a58 Mon Sep 17 00:00:00 2001
From: Jiang Lu <[email protected]>
Date: Wed, 29 Aug 2018 11:39:48 +0800
Subject: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
Move wic src into package directory.
---
scripts/wic => meta/recipes-support/wic/files/wic.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/__init__.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/engine.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/filemap.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/help.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/ksparser.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/misc.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/partition.py | 0
{scripts/lib => meta/recipes-support/wic/files}/wic/pluginbase.py | 0
.../lib => meta/recipes-support/wic/files}/wic/plugins/imager/direct.py | 0
.../recipes-support/wic/files}/wic/plugins/source/bootimg-efi.py | 0
.../recipes-support/wic/files}/wic/plugins/source/bootimg-partition.py | 0
.../recipes-support/wic/files}/wic/plugins/source/bootimg-pcbios.py | 0
.../recipes-support/wic/files}/wic/plugins/source/isoimage-isohybrid.py | 0
.../lib => meta/recipes-support/wic/files}/wic/plugins/source/rawcopy.py | 0
.../lib => meta/recipes-support/wic/files}/wic/plugins/source/rootfs.py | 0
16 files changed, 0 insertions(+), 0 deletions(-)
rename scripts/wic => meta/recipes-support/wic/files/wic.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/__init__.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/engine.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/filemap.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/help.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/ksparser.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/misc.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/partition.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/pluginbase.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/imager/direct.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/bootimg-efi.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/bootimg-partition.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/bootimg-pcbios.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/isoimage-isohybrid.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/rawcopy.py (100%)
rename {scripts/lib => meta/recipes-support/wic/files}/wic/plugins/source/rootfs.py (100%)meta/recipes-support/wic/files/wic.py renamed from scripts/wic +0 -0
meta/recipes-support/wic/files/wic/__init__.py renamed from scripts/lib/wic/__init__.py +0 -0
meta/recipes-support/wic/files/wic/engine.py renamed from scripts/lib/wic/engine.py +0 -0
meta/recipes-support/wic/files/wic/filemap.py renamed from scripts/lib/wic/filemap.py +0 -0
meta/recipes-support/wic/files/wic/help.py renamed from scripts/lib/wic/help.py +0 -0
meta/recipes-support/wic/files/wic/ksparser.py renamed from scripts/lib/wic/ksparser.py +0 -0
meta/recipes-support/wic/files/wic/misc.py renamed from scripts/lib/wic/misc.py +0 -0
meta/recipes-support/wic/files/wic/partition.py renamed from scripts/lib/wic/partition.py +0 -0
meta/recipes-support/wic/files/wic/pluginbase.py renamed from scripts/lib/wic/pluginbase.py +0 -0
meta/recipes-support/wic/files/wic/plugins/imager/direct.py renamed from scripts/lib/wic/plugins/imager/direct.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py renamed from scripts/lib/wic/plugins/source/bootimg-efi.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/bootimg-partition.py renamed from scripts/lib/wic/plugins/source/bootimg-partition.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/bootimg-pcbios.py renamed from scripts/lib/wic/plugins/source/bootimg-pcbios.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/isoimage-isohybrid.py renamed from scripts/lib/wic/plugins/source/isoimage-isohybrid.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/rawcopy.py renamed from scripts/lib/wic/plugins/source/rawcopy.py +0 -0
meta/recipes-support/wic/files/wic/plugins/source/rootfs.py renamed from scripts/lib/wic/plugins/source/rootfs.py +0 -0
Signature · 1 line
2.7.4
Re: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
Quoted 4 lines · Lu.Jiang
This patch simply move code from script/lib/wic into meta/recipes-support/wic/files. I didn't touch code in this patch.
Please see attachment for patch formatted with -M.
Exactly, formatted with -M it's clear and a short patch. A follow-up question now, are there any comment paths, etc, that should be changed as part of the move?
Signature · 1 line
Tom
Re: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
Also, what is the reason for the move? What problem does it solve? Why is it better to move it?
Quoted 19 lines · Tom Rini
Quoted 4 lines · Lu.Jiang
This patch simply move code from script/lib/wic into meta/recipes-support/wic/files. I didn't touch code in this patch.
Please see attachment for patch formatted with -M.
Exactly, formatted with -M it's clear and a short patch. A follow-up question now, are there any comment paths, etc, that should be changed as part of the move?
--
Tom
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH 2/7] wic:move wic src into meta/receipt-support/wic
The patch move source code for wic from lib/script into meta/receipt-support/wic. Then wic compiled as an individual package.
When building wic image on host, imagetype-wic.bbclass invoke wic-native. This is almost same as before.
After applied those patch, wic also run on target, allow user create wic image on target board based on supplied components image or based on a running system.
BTW, I checked code moved in this patch, didn't found reference path in code.
Thanks
Jiang Lu
Quoted 23 lines · Tim Orling
Also, what is the reason for the move? What problem does it solve? Why is it better to move it? On Sun, Sep 2, 2018 at 7:51 PM Tom Rini <[email protected] <mailto:[email protected]>> wrote:
On Mon, Sep 03, 2018 at 09:58:01AM +0800, Lu.Jiang wrote:
> This patch simply move code from script/lib/wic into
> meta/recipes-support/wic/files. I didn't touch code in this patch. >
> Please see attachment for patch formatted with -M.Exactly, formatted with -M it's clear and a short patch. A follow-up question now, are there any comment paths, etc, that should be changed as part of the move?
--
Tom
--
_______________________________________________
Openembedded-core mailing list [email protected] <mailto:[email protected]>
http://lists.openembedded.org/mailman/listinfo/openembedded-core
PATCH v2 3/7 image_type_wic:add wic-native into depend
In reply to Jiang LuAdd wic-native into depend list.
--- meta/classes/image_types_wic.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/image_types_wic.bbclass +1 -1
@@ -44,7 +44,7 @@ do_image_wic[depends] += "${@' '.join('%s-native:do_populate_sysroot' % r for r # We ensure all artfacts are deployed (e.g virtual/bootloader) do_image_wic[recrdeptask] += "do_deploy" -WKS_FILE_DEPENDS_DEFAULT = "syslinux-native bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native" +WKS_FILE_DEPENDS_DEFAULT = "syslinux-native bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native wic-native" WKS_FILE_DEPENDS_BOOTLOADERS = "" WKS_FILE_DEPENDS_BOOTLOADERS_x86 = "syslinux grub-efi systemd-boot" WKS_FILE_DEPENDS_BOOTLOADERS_x86-64 = "syslinux grub-efi systemd-boot"
Signature · 1 line
2.7.4
PATCH v2 4/7 wic:allow wic run outof bb enviroment.
In reply to Jiang Lu1.Export copyhardlinktree() into misc.py 2.Skip enviroment checkding when there is no bitbake.
--- meta/recipes-support/wic/files/wic.py | 34 ++++++++++++------ meta/recipes-support/wic/files/wic/engine.py | 3 ++ meta/recipes-support/wic/files/wic/misc.py | 42 ++++++++++++++++++++++ .../wic/files/wic/plugins/imager/direct.py | 2 +- .../wic/files/wic/plugins/source/rootfs.py | 2 +- 5 files changed, 70 insertions(+), 13 deletions(-)
meta/recipes-support/wic/files/wic.py +23 -11
@@ -43,8 +43,11 @@ from distutils import spawn scripts_path = os.path.dirname(os.path.realpath(__file__)) lib_path = scripts_path + '/lib' sys.path.insert(0, lib_path) -import scriptpath -scriptpath.add_oe_lib_path() +try: + import scriptpath + scriptpath.add_oe_lib_path() +except: + pass # Check whether wic is running within eSDK environment sdkroot = scripts_path
@@ -61,12 +64,14 @@ if os.environ.get('SDKTARGETSYSROOT'): sdkroot = os.path.dirname(sdkroot) bitbake_exe = spawn.find_executable('bitbake') +""" if bitbake_exe: bitbake_path = scriptpath.add_bitbake_lib_path() from bb import cookerdata from bb.main import bitbake_main, BitBakeConfigParameters else: bitbake_main = None +""" from wic import WicError from wic.misc import get_bitbake_var, BB_VARS
@@ -124,10 +129,10 @@ def wic_create_subcommand(options, usage_str): Command-line handling for image creation. The real work is done by image.engine.wic_create() """ - if options.build_rootfs and not bitbake_main: + if options.build_rootfs and not bitbake_exe: raise WicError("Can't build rootfs as bitbake is not in the $PATH") - if not options.image_name: + if bitbake_exe and not options.image_name: missed = [] for val, opt in [(options.rootfs_dir, 'rootfs-dir'), (options.bootimg_dir, 'bootimg-dir'),
@@ -147,7 +152,7 @@ def wic_create_subcommand(options, usage_str): if options.vars_dir: BB_VARS.vars_dir = options.vars_dir - if options.build_check and not engine.verify_build_env(): + if bitbake_exe and options.build_check and not engine.verify_build_env(): raise WicError("Couldn't verify build environment, exiting") if options.debug:
@@ -158,12 +163,12 @@ def wic_create_subcommand(options, usage_str): argv = ["bitbake", options.image_name] if options.debug: argv.append("--debug") - + """ logger.info("Building rootfs...\n") if bitbake_main(BitBakeConfigParameters(argv), cookerdata.CookerConfiguration()): raise WicError("bitbake exited with error") - + """ rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", options.image_name) kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE", options.image_name) bootimg_dir = get_bitbake_var("STAGING_DATADIR", options.image_name)
@@ -177,14 +182,16 @@ def wic_create_subcommand(options, usage_str): "(Use -e/--image-name to specify it)") native_sysroot = options.native_sysroot - if not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): + if bitbake_exe and not options.vars_dir and (not native_sysroot or not os.path.isdir(native_sysroot)): + """ logger.info("Building wic-tools...\n") if bitbake_main(BitBakeConfigParameters("bitbake wic-tools".split()), cookerdata.CookerConfiguration()): raise WicError("bitbake wic-tools failed") + """ native_sysroot = get_bitbake_var("RECIPE_SYSROOT_NATIVE", "wic-tools") - if not native_sysroot: + if bitbake_exe and not native_sysroot: raise WicError("Unable to find the location of the native tools sysroot") wks_file = options.wks_file
@@ -196,7 +203,7 @@ def wic_create_subcommand(options, usage_str): "to list available images, or specify a fully-qualified OE " "kickstart (.wks) filename)" % options.wks_file) - if not options.image_name: + if bitbake_exe and not options.image_name: rootfs_dir = '' if 'ROOTFS_DIR' in options.rootfs_dir: rootfs_dir = options.rootfs_dir['ROOTFS_DIR']
@@ -211,7 +218,7 @@ def wic_create_subcommand(options, usage_str): raise WicError("--kernel-dir (-k) not found, exiting") if not os.path.isdir(native_sysroot): raise WicError("--native-sysroot (-n) not found, exiting") - else: + elif bitbake_exe: not_found = not_found_dir = "" if not os.path.isdir(rootfs_dir): (not_found, not_found_dir) = ("rootfs-dir", rootfs_dir)
@@ -227,6 +234,11 @@ def wic_create_subcommand(options, usage_str): logger.info(" selected in local.conf actually exist and that they") logger.info(" are the correct artifacts for the image (.wks file)).\n") raise WicError("The artifact that couldn't be found was %s:\n %s", not_found, not_found_dir) + else: + kernel_dir = options.kernel_dir + rootfs_dir = "/" + native_sysroot = "/" + bootimg_dir = "/" krootfs_dir = options.rootfs_dir if krootfs_dir is None:
meta/recipes-support/wic/files/wic/engine.py +3 -0
@@ -186,7 +186,10 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, try: oe_builddir = os.environ["BUILDDIR"] except KeyError: + ''' raise WicError("BUILDDIR not found, exiting. (Did you forget to source oe-init-build-env?)") + ''' + oe_builddir = "" if not os.path.exists(options.outdir): os.makedirs(options.outdir)
meta/recipes-support/wic/files/wic/misc.py +42 -0
50 lines not on this page · raw message
meta/recipes-support/wic/files/wic/plugins/imager/direct.py +1 -1
@@ -33,7 +33,7 @@ import uuid from time import strftime -from oe.path import copyhardlinktree +from wic.misc import copyhardlinktree from wic import WicError from wic.filemap import sparse_copy
meta/recipes-support/wic/files/wic/plugins/source/rootfs.py +1 -1
@@ -30,7 +30,7 @@ import os import shutil import sys -from oe.path import copyhardlinktree +from wic.misc import copyhardlinktree from wic import WicError from wic.pluginbase import SourcePlugin
Signature · 1 line
2.7.4
PATCH v2 5/7 wic:direct:remove same entry when updating fstab
In reply to Jiang LuRemove same mountpoint entry when updating fstab.
--- meta/recipes-support/wic/files/wic/plugins/imager/direct.py | 3 +++ 1 file changed, 3 insertions(+)
meta/recipes-support/wic/files/wic/plugins/imager/direct.py +3 -0
@@ -163,6 +163,9 @@ class DirectPlugin(ImagerPlugin): opts = part.fsopts if part.fsopts else "defaults" line = "\t".join([device_name, part.mountpoint, part.fstype, opts, "0", "0"]) + "\n" + for tmpline in fstab_lines: + if part.mountpoint in tmpline: + fstab_lines.remove(tmpline) fstab_lines.append(line) updated = True
Signature · 1 line
2.7.4
Re: [PATCH 5/7] wic:direct:remove same entry when updating fstab
Quoted 12 lines · Jiang Lu
Remove same mountpoint entry when updating fstab.
Signed-off-by Jiang Lu <[email protected]>--- meta/recipes-support/wic/files/wic/plugins/imager/direct.py | 3 +++ 1 file changed, 3 insertions(+)meta/recipes-support/wic/files/wic/plugins/imager/direct.py +0
-0
meta/recipes-support/wic/files/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 171
Quoted 9 lines
meta/recipes-support/wic/files/wic/plugins/imager/direct.py +3
-0@@ -163,6 +163,9 @@ class DirectPlugin(ImagerPlugin): opts = part.fsopts if part.fsopts else "defaults" line = "\t".join([device_name, part.mountpoint, part.fstype, opts, "0", "0"]) + "\n" + for tmpline in fstab_lines: + if part.mountpoint in tmpline: + fstab_lines.remove(tmpline) fstab_lines.append(line) updated = True
Can you explain how this happens?
Signature · 1 line
Tom
Re: [PATCH 5/7] wic:direct:remove same entry when updating fstab
Quoted 21 lines · Tom Rini
Quoted 19 lines · Jiang Lu
Remove same mountpoint entry when updating fstab.
Signed-off-by Jiang Lu <[email protected]>--- meta/recipes-support/wic/files/wic/plugins/imager/direct.py | 3 +++ 1 file changed, 3 insertions(+)meta/recipes-support/wic/files/wic/plugins/imager/direct.py +3
-0@@ -163,6 +163,9 @@ class DirectPlugin(ImagerPlugin): opts = part.fsopts if part.fsopts else "defaults" line = "\t".join([device_name, part.mountpoint, part.fstype, opts, "0", "0"]) + "\n" + for tmpline in fstab_lines: + if part.mountpoint in tmpline: + fstab_lines.remove(tmpline)
Quoted 4 lines
meta/recipes-support/wic/files/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 171
Quoted 2 lines
meta/recipes-support/wic/files/wic/plugins/imager/direct.py +0
-0fstab_lines.append(line) updated = TrueCan you explain how this happens?
The patch intend to fix a issue when running wic on target.
On target, I'd like wic create a new image based on current running rootfs. Then the fstab from running system need remove duplicated entry.
Thanks
Jiang Lu
Re: [PATCH 5/7] wic:direct:remove same entry when updating fstab
Quoted 25 lines · Lu.Jiang
Quoted 9 lines · Tom Rini
Quoted 7 lines · Jiang Lu
Remove same mountpoint entry when updating fstab.
Signed-off-by Jiang Lu <[email protected]>--- meta/recipes-support/wic/files/wic/plugins/imager/direct.py | 3 +++ 1 file changed, 3 insertions(+)Quoted 15 lines
meta/recipes-support/wic/files/wic/plugins/imager/direct.py class DirectPlugin(ImagerPlugin): · line 170
Quoted 13 lines
meta/recipes-support/wic/files/wic/plugins/imager/direct.py +3
-0@@ -163,6 +163,9 @@ class DirectPlugin(ImagerPlugin): opts = part.fsopts if part.fsopts else "defaults" line = "\t".join([device_name, part.mountpoint, part.fstype, opts, "0", "0"]) + "\n" + for tmpline in fstab_lines: + if part.mountpoint in tmpline: + fstab_lines.remove(tmpline) fstab_lines.append(line) updated = TrueCan you explain how this happens?
Quoted 4 lines
The patch intend to fix a issue when running wic on target.
On target, I'd like wic create a new image based on current running rootfs. Then the fstab from running system need remove duplicated entry.
Please put something about this in the commit message, thanks.
Signature · 1 line
Tom
PATCH v2 6/7 wic:bootimg-efi:try other place for efi
In reply to Jiang LuWhen there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
--- .../wic/files/wic/plugins/source/bootimg-efi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +12 -0
@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) + os.listdir("%s/EFI/BOOT/" % hdddir) + found_efi = False + for x in os.listdir("%s/EFI/BOOT/" % hdddir) : + if x.endswith(".efi"): + found_efi = True + break; + if not found_efi: + cp_cmd = "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir) + try: + exec_cmd(cp_cmd, True) + except: + pass except KeyError: raise WicError("bootimg-efi requires a loader, none specified")
Signature · 1 line
2.7.4
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 20 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>--- .../wic/files/wic/plugins/source/bootimg-efi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +4
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) + os.listdir("%s/EFI/BOOT/" % hdddir) + found_efi = False + for x in os.listdir("%s/EFI/BOOT/" % hdddir) : + if x.endswith(".efi"):
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py class BootimgEFIPlugin(SourcePlugin): · line 247
Quoted 10 lines
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +8
-0+ found_efi = True + break; + if not found_efi: + cp_cmd = "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir) + try: + exec_cmd(cp_cmd, True) + except: + pass except KeyError: raise WicError("bootimg-efi requires a loader, none specified")
I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Signature · 1 line
Tom
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 29 lines · Tom Rini
Quoted 27 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>--- .../wic/files/wic/plugins/source/bootimg-efi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +11
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader']) + os.listdir("%s/EFI/BOOT/" % hdddir) + found_efi = False + for x in os.listdir("%s/EFI/BOOT/" % hdddir) : + if x.endswith(".efi"): + found_efi = True + break; + if not found_efi: + cp_cmd = "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir) + try: + exec_cmd(cp_cmd, True) + except:
Quoted 9 lines
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py class BootimgEFIPlugin(SourcePlugin): · line 247
Quoted 3 lines
meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +1
-0+ pass except KeyError: raise WicError("bootimg-efi requires a loader, none specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and
IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
I will take a look about bootimage-partition. Thanks for remind.
Thanks
Jiang Lu
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 32 lines · Lu.Jiang
Quoted 31 lines · Tom Rini
Quoted 29 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>---
.../wic/files/wic/plugins/source/bootimg-efi.py| 12 ++++++++++++1 file changed, 12 insertions(+)meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin):else:
raiseWicError("unrecognized bootimg-efi loader: %s" % source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
except KeyError:
raiseWicError("bootimg-efi requires a loader, none specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Hi Tom,
By indicating IMAGE_BOOT_FILES for bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.
I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
Thanks
Jiang Lu
Quoted 7 lines
I will take a look about bootimage-partition. Thanks for remind.
Thanks
Jiang Lu
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 47 lines · Lu.Jiang
Quoted 36 lines · Lu.Jiang
Quoted 35 lines · Tom Rini
Quoted 33 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>---
.../wic/files/wic/plugins/source/bootimg-efi.py| 12 ++++++++++++1 file changed, 12 insertions(+)diff --git
a/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyb/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyindex 0eb86a0..d435268 100644meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin):else:
raise WicError("unrecognized bootimg-efi loader: %s" %
source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
except KeyError:Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
raise
WicError("bootimg-efi requires a loader, none specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Quoted 7 lines
Hi Tom,
By indicating
IMAGE_BOOT_FILESfor bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
I'm still not seeing why we need this, sorry.
If we need files in the ESP in EFI/BOOT/ then in our root filesystem they're already in as /boot/efi/EFI/BOOT and we say that we populate things from /boot/efi and this also gets us things like /boot/efi/EFI/vendor and so forth populated and matches other Linux distributions.
If we need something more complex, we have IMAGE_BOOT_FILES available and can and should be populating the deploy directory like other architectures and loaders do.
Signature · 1 line
Tom
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 61 lines · Tom Rini
Quoted 45 lines · Lu.Jiang
Quoted 36 lines · Lu.Jiang
Quoted 35 lines · Tom Rini
Quoted 33 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>--- .../wic/files/wic/plugins/source/bootimg-efi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)diff --git
a/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyb/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyindex 0eb86a0..d435268 100644meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("unrecognized bootimg-efi loader: %s"%
source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
except KeyError:Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
raise WicError("bootimg-efi requires a loader, none
specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Quoted 7 lines
Hi Tom,
By indicating
IMAGE_BOOT_FILESfor bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
I'm still not seeing why we need this, sorry.
If we need files in the ESP in EFI/BOOT/ then in our root filesystem they're already in as
/boot/efi/EFI/BOOTand we say that we populate things from/boot/efiand this also gets us things like/boot/efi/EFI/vendorand so forth populated and matches other Linux distributions.
Quoted 4 lines
If we need something more complex, we have
IMAGE_BOOT_FILESavailable and can and should be populating the deploy directory like other architectures and loaders do.
bootimg-efi performed following for grub boot partition:
1.copy grub-efi-* from $KERNEL_DIR into $/boot/EFI/BOOT/
2.copy bzImage from $KERNEL_DIR into $/boot/
3.generate grub.cfg based select booting device.
On target system, if we select booting device from running system as source for booting-efi will meet issue. Because the *.efi & bzImage is not in the same directory.
As you suggested, we may invoke booting-partition by feeding $IMAGE_BOOT_FILES to indicating file need copy, this could done work 1 & 2. While we still need generated grub.cfg.
Thanks
Jiang Lu
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 74 lines · Lu.Jiang
Quoted 61 lines · Tom Rini
Quoted 45 lines · Lu.Jiang
Quoted 36 lines · Lu.Jiang
Quoted 35 lines · Tom Rini
Quoted 33 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>---
.../wic/files/wic/plugins/source/bootimg-efi.py| 12 ++++++++++++1 file changed, 12 insertions(+)diff --git
a/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyb/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyindex 0eb86a0..d435268 100644meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin):else:
raise WicError("unrecognized bootimg-efi loader: %s" %
source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
except KeyError:Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
raise
WicError("bootimg-efi requires a loader, none specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Quoted 7 lines
Hi Tom,
By indicating
IMAGE_BOOT_FILESfor bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
I'm still not seeing why we need this, sorry.
If we need files in the ESP in EFI/BOOT/ then in our root filesystem they're already in as
/boot/efi/EFI/BOOTand we say that we populate things from/boot/efiand this also gets us things like/boot/efi/EFI/vendorand so forth populated and matches other Linux distributions.Quoted 4 lines
If we need something more complex, we have
IMAGE_BOOT_FILESavailable and can and should be populating the deploy directory like other architectures and loaders do.bootimg-efi performed following for grub boot partition:
1.copy grub-efi-* from $KERNEL_DIR into $/boot/EFI/BOOT/
2.copy bzImage from $KERNEL_DIR into $/boot/
3.generate grub.cfg based select booting device.
Quoted 7 lines
On target system, if we select booting device from running system as source for booting-efi will meet issue. Because the *.efi & bzImage is not in the same directory.
As you suggested, we may invoke booting-partition by feeding $IMAGE_BOOT_FILES to indicating file need copy, this could done work 1 & 2. While we still need generated grub.cfg.
One of the great strengths of wic is that it can cover a lot of different fairly complex use cases automatically, and still provide an expert "out" for when you're doing something fairly different but still want to leverage wic. While I don't understand the use case of turning a live system into a wic image, it sounds like what you're looking for is the case of "and we provide our own loader config file". You should be including grub.cfg into the IMAGE_BOOT_FILES list and generate this however you need it. Since you've already booted you should already have a correct EFI/ directory to look at (we ought to stop having top-level bzImage, that's not right, but that's orthogonal to this thread).
All that said, I'm also not sure why, roughly, this doesn't work for the use case:IMAGE_BOOT_FILE = "\
/boot/efi/EFI/BOOT/bootx64.efi;EFI/BOOT/bootx64.efi \
...
/boot/bzImage;EFI/yocto/bzImage \
"
And you may want to address that we don't package our default grub binary, or have the script that's running wic make your grub.efi binary. I kind of lean towards the former being something we should be doing and aren't. There's I think a lot of stuff that could be made more consistent with other architectures and loaders but isn't currently. That too is somewhat orthogonal to this series I'll admit.
Signature · 1 line
Tom
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 82 lines · Tom Rini
Quoted 74 lines · Lu.Jiang
Quoted 61 lines · Tom Rini
Quoted 45 lines · Lu.Jiang
Quoted 36 lines · Lu.Jiang
Quoted 35 lines · Tom Rini
Quoted 33 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>--- .../wic/files/wic/plugins/source/bootimg-efi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)diff --git
a/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyb/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyindex 0eb86a0..d435268 100644meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin): else: raise WicError("unrecognized bootimg-efi loader: %s"%
source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
except KeyError:Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
raise WicError("bootimg-efi requires a loader, none
specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Quoted 7 lines
Hi Tom,
By indicating
IMAGE_BOOT_FILESfor bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
I'm still not seeing why we need this, sorry.
If we need files in the ESP in EFI/BOOT/ then in our root filesystem they're already in as
/boot/efi/EFI/BOOTand we say that we populate things from/boot/efiand this also gets us things like/boot/efi/EFI/vendorand so forth populated and matches other Linux distributions.Quoted 4 lines
If we need something more complex, we have
IMAGE_BOOT_FILESavailable and can and should be populating the deploy directory like other architectures and loaders do.bootimg-efi performed following for grub boot partition:
1.copy grub-efi-* from $KERNEL_DIR into $/boot/EFI/BOOT/
2.copy bzImage from $KERNEL_DIR into $/boot/
3.generate grub.cfg based select booting device.
Quoted 7 lines
On target system, if we select booting device from running system as source for booting-efi will meet issue. Because the *.efi & bzImage is not in the same directory.
As you suggested, we may invoke booting-partition by feeding $IMAGE_BOOT_FILES to indicating file need copy, this could done work 1 & 2. While we still need generated grub.cfg.
Quoted 11 lines
One of the great strengths of wic is that it can cover a lot of different fairly complex use cases automatically, and still provide an expert "out" for when you're doing something fairly different but still want to leverage wic. While I don't understand the use case of turning a live system into a wic image, it sounds like what you're looking for is the case of "and we provide our own loader config file". You should be including grub.cfg into the
IMAGE_BOOT_FILESlist and generate this however you need it. Since you've already booted you should already have a correct EFI/ directory to look at (we ought to stop having top-level bzImage, that's not right, but that's orthogonal to this thread).
The grub.cfg is generated in bootimg-efi.py. At least, it need include the new generated uuid info for rootfs partition. So we still need a piece of code from bootimg-efi.py to generate grub.cfg at runtime.
The issue this patch try to fix is bootimg-efi assume bzImage & grub-*.efi located at top level of $KERNEL_DIR. This is true for bitbake's deploy dir. However, it didn't apply to target. We need provide a way for adding search path for *.efi.
I believe wic is a powerful tool not only working under oe environment, it can be a simply implement tool on target. So try to add a few patch to make it working on target.
Thanks
Jiang Lu
Quoted 16 lines
All that said, I'm also not sure why, roughly, this doesn't work for the use case:
IMAGE_BOOT_FILE = "\ /boot/efi/EFI/BOOT/bootx64.efi;EFI/BOOT/bootx64.efi \ ... /boot/bzImage;EFI/yocto/bzImage \ "And you may want to address that we don't package our default grub binary, or have the script that's running wic make your grub.efi binary. I kind of lean towards the former being something we should be doing and aren't. There's I think a lot of stuff that could be made more consistent with other architectures and loaders but isn't currently. That too is somewhat orthogonal to this series I'll admit.
Re: [PATCH 6/7] wic:bootimg-efi:try other place for efi
Quoted 95 lines · Lu.Jiang
Quoted 82 lines · Tom Rini
Quoted 74 lines · Lu.Jiang
Quoted 61 lines · Tom Rini
Quoted 45 lines · Lu.Jiang
Quoted 36 lines · Lu.Jiang
Quoted 35 lines · Tom Rini
Quoted 33 lines · Jiang Lu
When there is no useful efi in $kerneldir, try copy all efi from EFI/BOOT into boot image.
Signed-off-by Jiang Lu <[email protected]>---
.../wic/files/wic/plugins/source/bootimg-efi.py| 12 ++++++++++++1 file changed, 12 insertions(+)diff --git
a/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyb/meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.pyindex 0eb86a0..d435268 100644meta/recipes-support/wic/files/wic/plugins/source/bootimg-efi.py +0
-0@@ -231,6 +231,18 @@ class BootimgEFIPlugin(SourcePlugin):else:
raise WicError("unrecognized bootimg-efi loader: %s" %
source_params['loader'])
+os.listdir("%s/EFI/BOOT/" % hdddir)
+found_efi= False
+ for x inos.listdir("%s/EFI/BOOT/" % hdddir):
+ ifx.endswith(".efi"):
+found_efi= True
+ break;
+ if notfound_efi:
+cp_cmd= "cp %s/EFI/BOOT/*.efi %s/EFI/BOOT/" % (kernel_dir, hdddir)
+ try:
+exec_cmd(cp_cmd, True)
+ except:
+ pass
except KeyError:Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
raise
WicError("bootimg-efi requires a loader, none specified")I'm not sure this is the right approach. If you don't have things set up for automagic finding you should use bootimg-partition and IMAGE_BOOT_FILES. I'm doing this right now for some EFI projects because it's also bad form to dump everything into EFI/BOOT and some things should end up in EFI/vendorname or similar.
Quoted 7 lines
Hi Tom,
By indicating
IMAGE_BOOT_FILESfor bootimg-partition, can perform copy file work. While we still need the code in bootimg-efi to re-generate grub.cfg.I prefer use bootimg-efi for this case, but we can add a new parameter to distinguish kernel dir & bootloader dir(for efi files)
I'm still not seeing why we need this, sorry.
If we need files in the ESP in EFI/BOOT/ then in our root filesystem they're already in as
/boot/efi/EFI/BOOTand we say that we populate things from/boot/efiand this also gets us things like/boot/efi/EFI/vendorand so forth populated and matches other Linux distributions.Quoted 4 lines
If we need something more complex, we have
IMAGE_BOOT_FILESavailable and can and should be populating the deploy directory like other architectures and loaders do.bootimg-efi performed following for grub boot partition:
1.copy grub-efi-* from $KERNEL_DIR into $/boot/EFI/BOOT/
2.copy bzImage from $KERNEL_DIR into $/boot/
3.generate grub.cfg based select booting device.
Quoted 7 lines
On target system, if we select booting device from running system as source for booting-efi will meet issue. Because the *.efi & bzImage is not in the same directory.
As you suggested, we may invoke booting-partition by feeding $IMAGE_BOOT_FILES to indicating file need copy, this could done work 1 & 2. While we still need generated grub.cfg.
Quoted 11 lines
One of the great strengths of wic is that it can cover a lot of different fairly complex use cases automatically, and still provide an expert "out" for when you're doing something fairly different but still want to leverage wic. While I don't understand the use case of turning a live system into a wic image, it sounds like what you're looking for is the case of "and we provide our own loader config file". You should be including grub.cfg into the
IMAGE_BOOT_FILESlist and generate this however you need it. Since you've already booted you should already have a correct EFI/ directory to look at (we ought to stop having top-level bzImage, that's not right, but that's orthogonal to this thread).
Quoted 2 lines
The grub.cfg is generated in
bootimg-efi.py. At least, it need include the new generated uuid info for rootfs partition.
Or, you generate the grub.cfg outside of wic and tell wic what newly generated UUIDs to use, and just use bootimg-partition.py and IMAGE_BOOT_FILES.
Quoted 5 lines
So we still need a piece of code from
bootimg-efi.pyto generate grub.cfg at runtime.The issue this patch try to fix is bootimg-efi assume bzImage & grub-*.efi located at top level of $KERNEL_DIR.
(aside, OE $DEPLOY_DIR_IMAGE becomes do_prepare_partition() kernel_dir) Yes, this particular bit of code very much assumes an OE environment as you don't normally see grub-efi-*.efi nor systemd-*.efi like that on the system, and a real problem is that we don't package and ship those files (I know for grub, I guess but didn't check systemd).
Quoted 2 lines
This is true for bitbake's deploy dir. However, it didn't apply to target. We need provide a way for adding search path for *.efi.
I disagree that we need to because in this case you only need to because the EFI binaries don't exist on the target in a normal way.
All of that said, perhaps a different way to look at this would be that we could try doing both of:
- packaging and shipping grub-efi-*.efi (and systemd-boot equivalents)
- Similar to how plugins/imager/direct.py can fiddle with /etc/fstab add some option to fiddle the various known loader config files to whack 'root=PARTUUID=well-formatted-uuid' to the new UUID.
Then you shouldn't need to generate a new grub.cfg and should be able to use IMAGE_BOOT_FILES to map things to where you want them to go and still get your grub.cfg file updated.
Signature · 1 line
Tom
PATCH v2 7/7 wic:mkefidisk:add use-uuid for all partitions
In reply to Jiang LuAdd use-uuid for all partitions on mkefidisk.wks.
--- scripts/lib/wic/canned-wks/mkefidisk.wks | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lib/wic/canned-wks/mkefidisk.wks +2 -2
@@ -2,10 +2,10 @@ # long-description: Creates a partitioned EFI disk image that the user # can directly dd to boot media. -part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 +part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 --use-uuid part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid -part swap --ondisk sda --size 44 --label swap1 --fstype=swap +part swap --ondisk sda --size 44 --label swap1 --fstype=swap --use-uuid bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
Signature · 1 line
2.7.4
Re: [PATCH 7/7] wic:mkefidisk:add use-uuid for all partitions
Quoted 14 lines · Jiang Lu
Add use-uuid for all partitions on mkefidisk.wks.
Signed-off-by Jiang Lu <[email protected]>--- scripts/lib/wic/canned-wks/mkefidisk.wks | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)scripts/lib/wic/canned-wks/mkefidisk.wks +0
-0@@ -2,10 +2,10 @@ # long-description: Creates a partitioned EFI disk image that the user # can directly dd to boot media.
scripts/lib/wic/canned-wks/mkefidisk.wks line 11
Quoted 10 lines
scripts/lib/wic/canned-wks/mkefidisk.wks +2
-2-part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 +part /boot --source bootimg-efi --sourceparams="loader=grub-efi" --ondisk sda --label msdos --active --align 1024 --use-uuid part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid -part swap --ondisk sda --size 44 --label swap1 --fstype=swap +part swap --ondisk sda --size 44 --label swap1 --fstype=swap --use-uuid bootloader --ptable gpt --timeout=5 --append="rootfstype=ext4 console=ttyS0,115200 console=tty0"
Please drop the ondisk lines as they're really not useful when using uuid, which is good and I'm glad to see happen.
Signature · 1 line
Tom
Hi all,
Thanks Tom help me review this patch.
The patch intend to bring wic into target, allow it generate new image at runtime.
For example, most x86 board can boot from USB or SATA, then wic enable uuid for partition to distinguish different device. If we use same image for all device, uuid will be same. It is better to generate a new image based on running system at runtime. Then wic is best choice.
In this patch set, patch 1-4 intend to bring wic into a individual package and allow it running out of OE environment.
However, to allow wic running on target, we need hack current implementation to fit target environment. This is patch 6 try to fix, while Tom think the workround implementation isn't good. The patch can not provide a good reason. I agree.
I'd like introduce a new image plugin in next review request. The new plugin used to overcome the different between OE environment & target environment, and allow wic to generate image direct on a block device to save disk space usage on runtime. Please give your option about this, Tom.
BTW, for patch 7(use uuid for all partition in mkefi.wks), which is irrelevant with this issue. I will send a separated RR.
Thanks
Jiang Lu
Quoted 27 lines · Jiang Lu
[V2]
Rebase patch to latest oe-core commmit.[V1 log]
This patch set intend to allow wic compile as an individual package, then it can run both on host & target side.On host, it invoke by image_type_wic.bbclass to as a native tool to generate wic image.
Patch 1-4 make wic compile as a native tool.
On trarget, it parse wks file, and use current rootfs & /boot folder to generated a new wic image on target.
Patch 5-6 fix a few minor issue on target.
The patch is validate with mkefidisk.wks from oe-core layer on intel x86 platform.
Assume
/dev/sda2is root device, then with following command, use could generate a new wic image$mount
/dev/sda2/tmp/sda
$wic create/root/mkefidisk.wks-k /boot -r/tmp/sda-o/tmp/The generated image is under /tmp with name mkefidisk-xxx-sda.direct. Then user may dump this file into another booting deivce.
Thanks
Jiang Lu
Quoted 10 lines · Lu.Jiang
Hi all,
Thanks Tom help me review this patch.
The patch intend to bring wic into target, allow it generate new image at runtime.
For example, most x86 board can boot from USB or SATA, then wic enable uuid for partition to distinguish different device. If we use same image for all device, uuid will be same. It is better to generate a new image based on running system at runtime. Then wic is best choice.
Ah, this is an interesting problem. But, I wouldn't involve wic in solving "how do I take one image and get multiple unique partition/filesystem UUIDs". Generally this problem (since you see it with clonezilla and other things of that nature) is to script up using sfdisk to change the partition UUIDs, tune2fs to change the filesystem UUIDs and correct the files that care.
Signature · 1 line
Tom