From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6517147827419742208 X-Received: by 10.28.247.5 with SMTP id v5mr3376065wmh.12.1517391723834; Wed, 31 Jan 2018 01:42:03 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.206.133 with SMTP id e127ls967697wmg.10.canary-gmail; Wed, 31 Jan 2018 01:42:03 -0800 (PST) X-Google-Smtp-Source: AH8x227ZVuR0nkZGRo9lW8grBMURC//UDjXPDgnrin2JBjZZ99scfEhTMnmvss7uZuPMUKfSdV5R X-Received: by 10.28.3.11 with SMTP id 11mr3463948wmd.4.1517391723367; Wed, 31 Jan 2018 01:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517391723; cv=none; d=google.com; s=arc-20160816; b=olJPm8087ZIRi7FN5GOjgbkysblLLdrZHwF4Sg1bounIGGvwLooHuNqbXNojPCOKdW hjH5NuVsDbXqIHhmtTHm5cafxa21RMC1MsufuHYvr+Rbt96rVDwjTdyS9Iu02WIC5mPP zjkX+q47cVL5olKm/jmrZ7GJl/bEBjOruE/slhZZt3f/cBcZ4AKW+CIHd4LVEdtH0dAe rUit+EiShc0wM2dDbw3s+jFcoxjBhn1riOYNlTcD8JA9YoSFxkqdbTfXyELm0lz5zwmr XG5am92r2GwqUDiakfGkrMErqDaBiaVertLyZfEdZ8B/LNI076Ezs2IIxwPMCq9oCd5E K19w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=A1hXW8hvxgCGkMhQzjT+evFnZeda1IKBFwQeZvq2COE=; b=o1M4R5L+lVrGS+DejM7NQM1xLg+wWcddB3BfPA3Do0ATSC2s/hcDUtsEp9wk/2kl6/ YqVKDmU8/UZi8e/dIDqDT9cdGH3oXczdu6V4jWb5cfPojGk0Ly6x0k0i6pqLw04vtA/n Lcyksk+vFsLoTYyM5doLcbvSpiVPk+mR0G5+pFb8HxDQeIVq4OmAW4faV+WqFXkpsJBg yC58JDW9uEsDgvp80kvYx5GFBC/MLkuHBMITp/Co+nX/l3tWXgzjinNJHB9z3NX4vjZS 1Et4aNkCfKeGqSEs30xfsVMNjbjQb2iMKL1lh82QEpuY5QGtK777h3MB4x1fjveCjf9g vvfQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from goliath.siemens.de (goliath.siemens.de. [192.35.17.28]) by gmr-mx.google.com with ESMTPS id f8si1131782wmc.2.2018.01.31.01.42.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 01:42:03 -0800 (PST) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) client-ip=192.35.17.28; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.28 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w0V9g2M6028858 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 31 Jan 2018 10:42:02 +0100 Received: from md1pvb1c.ad001.siemens.net (md1pvb1c.ad001.siemens.net [139.25.68.40] (may be forged)) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id w0V9g1ac008484; Wed, 31 Jan 2018 10:42:02 +0100 From: Henning Schild To: isar-users@googlegroups.com Cc: Henning Schild Subject: [PATCH 8/9] Revert "wic: Remove sysroot support" Date: Wed, 31 Jan 2018 10:41:59 +0100 Message-Id: <019be23d52b965a764b534b930ab9a47c5d57b41.1517390790.git.henning.schild@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: X-TUID: UeKR7ne3eeJU This reverts commit dd109de433577a55f26e8a76f04dfb39e6ed95a5. --- scripts/lib/wic/engine.py | 7 ++- scripts/lib/wic/partition.py | 59 +++++++++++++--------- scripts/lib/wic/pluginbase.py | 11 ++-- scripts/lib/wic/plugins/imager/direct.py | 49 ++++++++++-------- scripts/lib/wic/plugins/source/bootimg-efi.py | 13 +++-- .../lib/wic/plugins/source/bootimg-partition.py | 6 ++- scripts/lib/wic/plugins/source/bootimg-pcbios.py | 19 ++++--- .../lib/wic/plugins/source/isoimage-isohybrid.py | 25 +++++---- scripts/lib/wic/plugins/source/rawcopy.py | 2 +- scripts/lib/wic/plugins/source/rootfs.py | 4 +- scripts/wic | 27 +++++++++- 11 files changed, 140 insertions(+), 82 deletions(-) diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index 15826f2..f59821f 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py @@ -145,7 +145,8 @@ def list_source_plugins(): print(" %s" % plugin) -def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, options): +def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, + native_sysroot, options): """ Create image @@ -153,6 +154,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, options): rootfs_dir - absolute path to the build's /rootfs dir bootimg_dir - absolute path to the build's boot artifacts directory kernel_dir - absolute path to the build's kernel directory + native_sysroot - absolute path to the build's native sysroots dir image_output_dir - dirname to create for image options - wic command line options (debug, bmap, etc) @@ -164,6 +166,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, options): rootfs_dir: IMAGE_ROOTFS kernel_dir: DEPLOY_DIR_IMAGE + native_sysroot: STAGING_DIR_NATIVE In the above case, bootimg_dir remains unset and the plugin-specific image creation code is responsible for finding the @@ -187,7 +190,7 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, options): raise WicError('Unknown plugin: %s' % pname) plugin = plugin_class(wks_file, rootfs_dir, bootimg_dir, kernel_dir, - oe_builddir, options) + native_sysroot, oe_builddir, options) plugin.do_create() diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index 20bc4a2..939e667 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py @@ -29,7 +29,7 @@ import os import tempfile from wic import WicError -from wic.utils.misc import exec_cmd, get_bitbake_var +from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var from wic.pluginbase import PluginMgr logger = logging.getLogger('wic') @@ -125,7 +125,7 @@ class Partition(): return self.fixed_size if self.fixed_size else self.size def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, - bootimg_dir, kernel_dir): + bootimg_dir, kernel_dir, native_sysroot): """ Prepare content for individual partitions, depending on partition command parameters. @@ -137,7 +137,8 @@ class Partition(): "partition." % self.mountpoint) if self.fstype == "swap": - self.prepare_swap_partition(cr_workdir, oe_builddir) + self.prepare_swap_partition(cr_workdir, oe_builddir, + native_sysroot) self.source_file = "%s/fs.%s" % (cr_workdir, self.fstype) else: if self.fstype == 'squashfs': @@ -151,7 +152,7 @@ class Partition(): prefix = "ext" if self.fstype.startswith("ext") else self.fstype method = getattr(self, "prepare_empty_partition_" + prefix) - method(rootfs, oe_builddir) + method(rootfs, oe_builddir, native_sysroot) self.source_file = rootfs return @@ -174,13 +175,13 @@ class Partition(): plugin = PluginMgr.get_plugins('source')[self.source] plugin.do_configure_partition(self, srcparams_dict, creator, cr_workdir, oe_builddir, bootimg_dir, - kernel_dir) + kernel_dir, native_sysroot) plugin.do_stage_partition(self, srcparams_dict, creator, cr_workdir, oe_builddir, bootimg_dir, - kernel_dir) + kernel_dir, native_sysroot) plugin.do_prepare_partition(self, srcparams_dict, creator, cr_workdir, oe_builddir, bootimg_dir, - kernel_dir, rootfs_dir) + kernel_dir, rootfs_dir, native_sysroot) # further processing required Partition.size to be an integer, make # sure that it is one @@ -194,7 +195,8 @@ class Partition(): "larger (%d kB) than its allowed size %d kB" % (self.mountpoint, self.size, self.fixed_size)) - def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir): + def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, + native_sysroot): """ Prepare content for a rootfs partition i.e. create a partition and fill it from a /rootfs dir. @@ -233,7 +235,7 @@ class Partition(): prefix = "ext" if self.fstype.startswith("ext") else self.fstype method = getattr(self, "prepare_rootfs_" + prefix) - method(rootfs, oe_builddir, rootfs_dir) + method(rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo) self.source_file = rootfs # get the rootfs size in the right units for kickstart (kB) @@ -241,7 +243,8 @@ class Partition(): out = exec_cmd(du_cmd) self.size = int(out.split()[0]) - def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir): + def prepare_rootfs_ext(self, rootfs, oe_builddir, rootfs_dir, + native_sysroot, pseudo): """ Prepare content for an ext2/3/4 rootfs partition. """ @@ -262,12 +265,13 @@ class Partition(): mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \ (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir) - exec_cmd(mkfs_cmd) + exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) - def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir): + def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, + native_sysroot, pseudo): """ Prepare content for a btrfs rootfs partition. @@ -288,9 +292,10 @@ class Partition(): mkfs_cmd = "mkfs.%s -b %d -r %s %s %s" % \ (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, rootfs) - exec_cmd(mkfs_cmd) + exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) - def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir): + def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir, + native_sysroot, pseudo): """ Prepare content for a msdos/vfat rootfs partition. """ @@ -310,7 +315,7 @@ class Partition(): dosfs_cmd = "mkdosfs %s -S 512 %s -C %s %d" % (label_str, size_str, rootfs, rootfs_size) - exec_cmd(dosfs_cmd) + exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir) exec_native_cmd(mcopy_cmd, native_sysroot) @@ -320,15 +325,17 @@ class Partition(): prepare_rootfs_vfat = prepare_rootfs_msdos - def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir): + def prepare_rootfs_squashfs(self, rootfs, oe_builddir, rootfs_dir, + native_sysroot, pseudo): """ Prepare content for a squashfs rootfs partition. """ squashfs_cmd = "mksquashfs %s %s -noappend" % \ (rootfs_dir, rootfs) - exec_cmd(squashfs_cmd) + exec_native_cmd(squashfs_cmd, native_sysroot, pseudo=pseudo) - def prepare_empty_partition_ext(self, rootfs, oe_builddir): + def prepare_empty_partition_ext(self, rootfs, oe_builddir, + native_sysroot): """ Prepare an empty ext2/3/4 partition. """ @@ -344,9 +351,10 @@ class Partition(): mkfs_cmd = "mkfs.%s -F %s %s %s" % \ (self.fstype, extra_imagecmd, label_str, rootfs) - exec_cmd(mkfs_cmd) + exec_native_cmd(mkfs_cmd, native_sysroot) - def prepare_empty_partition_btrfs(self, rootfs, oe_builddir): + def prepare_empty_partition_btrfs(self, rootfs, oe_builddir, + native_sysroot): """ Prepare an empty btrfs partition. """ @@ -360,9 +368,10 @@ class Partition(): mkfs_cmd = "mkfs.%s -b %d %s %s" % \ (self.fstype, self.size * 1024, label_str, rootfs) - exec_cmd(mkfs_cmd) + exec_native_cmd(mkfs_cmd, native_sysroot) - def prepare_empty_partition_msdos(self, rootfs, oe_builddir): + def prepare_empty_partition_msdos(self, rootfs, oe_builddir, + native_sysroot): """ Prepare an empty vfat partition. """ @@ -378,14 +387,14 @@ class Partition(): dosfs_cmd = "mkdosfs %s -S 512 %s -C %s %d" % (label_str, size_str, rootfs, blocks) - exec_cmd(dosfs_cmd) + exec_native_cmd(dosfs_cmd, native_sysroot) chmod_cmd = "chmod 644 %s" % rootfs exec_cmd(chmod_cmd) prepare_empty_partition_vfat = prepare_empty_partition_msdos - def prepare_swap_partition(self, cr_workdir, oe_builddir): + def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot): """ Prepare a swap partition. """ @@ -399,4 +408,4 @@ class Partition(): if self.label: label_str = "-L %s" % self.label mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path) - exec_cmd(mkswap_cmd) + exec_native_cmd(mkswap_cmd, native_sysroot) diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py index 86d4a6d..fb3d179 100644 --- a/scripts/lib/wic/pluginbase.py +++ b/scripts/lib/wic/pluginbase.py @@ -92,7 +92,7 @@ class SourcePlugin(metaclass=PluginMeta): @classmethod def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir): + bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a disk image. This provides a hook to allow finalization of a @@ -102,7 +102,8 @@ class SourcePlugin(metaclass=PluginMeta): @classmethod def do_stage_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir): + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Special content staging hook called before do_prepare_partition(), normally empty. @@ -118,7 +119,8 @@ class SourcePlugin(metaclass=PluginMeta): @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir): + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Called before do_prepare_partition(), typically used to create custom configuration files for a partition, for example @@ -128,7 +130,8 @@ class SourcePlugin(metaclass=PluginMeta): @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, rootfs_dir): + oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, + native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 2e587b5..f2e6127 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py @@ -36,7 +36,7 @@ from wic import WicError from wic.filemap import sparse_copy from wic.ksparser import KickStart, KickStartError from wic.pluginbase import PluginMgr, ImagerPlugin -from wic.utils.misc import get_bitbake_var, exec_cmd +from wic.utils.misc import get_bitbake_var, exec_cmd, exec_native_cmd logger = logging.getLogger('wic') @@ -52,7 +52,7 @@ class DirectPlugin(ImagerPlugin): name = 'direct' def __init__(self, wks_file, rootfs_dir, bootimg_dir, kernel_dir, - oe_builddir, options): + native_sysroot, oe_builddir, options): try: self.ks = KickStart(wks_file) except KickStartError as err: @@ -62,6 +62,7 @@ class DirectPlugin(ImagerPlugin): self.rootfs_dir = dict(rdir.split('=') for rdir in rootfs_dir.split(' ')) self.bootimg_dir = bootimg_dir self.kernel_dir = kernel_dir + self.native_sysroot = native_sysroot self.oe_builddir = oe_builddir self.outdir = options.outdir @@ -84,7 +85,7 @@ class DirectPlugin(ImagerPlugin): image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") self._image = PartitionedImage(image_path, self.ptable_format, - self.parts) + self.parts, self.native_sysroot) def do_create(self): """ @@ -198,13 +199,14 @@ class DirectPlugin(ImagerPlugin): plugin = PluginMgr.get_plugins('source')[source_plugin] plugin.do_install_disk(self._image, disk_name, self, self.workdir, self.oe_builddir, self.bootimg_dir, - self.kernel_dir) + self.kernel_dir, self.native_sysroot) full_path = self._image.path # Generate .bmap if self.bmap: logger.debug("Generating bmap file for %s", disk_name) - exec_cmd("bmaptool create %s -o %s.bmap" % (full_path, full_path)) + exec_native_cmd("bmaptool create %s -o %s.bmap" % (full_path, full_path), + self.native_sysroot) # Compress the image if self.compressor: logger.debug("Compressing disk %s with %s", disk_name, self.compressor) @@ -235,6 +237,7 @@ class DirectPlugin(ImagerPlugin): msg += ' BOOTIMG_DIR: %s\n' % self.bootimg_dir msg += ' KERNEL_DIR: %s\n' % self.kernel_dir + msg += ' NATIVE_SYSROOT: %s\n' % self.native_sysroot logger.info(msg) @@ -284,7 +287,7 @@ class PartitionedImage(): Partitioned image in a file. """ - def __init__(self, path, ptable_format, partitions): + def __init__(self, path, ptable_format, partitions, native_sysroot=None): self.path = path # Path to the image file self.numpart = 0 # Number of allocated partitions self.realpart = 0 # Number of partitions in the partition table @@ -299,6 +302,7 @@ class PartitionedImage(): self.partimages = [] # Size of a sector used in calculations self.sector_size = SECTOR_SIZE + self.native_sysroot = native_sysroot # calculate the real partition number, accounting for partitions not # in the partition table and logical partitions @@ -328,7 +332,7 @@ class PartitionedImage(): # sizes before we can add them and do the layout. part.prepare(imager, imager.workdir, imager.oe_builddir, imager.rootfs_dir, imager.bootimg_dir, - imager.kernel_dir) + imager.kernel_dir, imager.native_sysroot) # Converting kB to sectors for parted part.size_sec = part.disk_size * 1024 // self.sector_size @@ -439,7 +443,7 @@ class PartitionedImage(): cmd += " %s" % fstype cmd += " %d %d" % (start, end) - return exec_cmd(cmd) + return exec_native_cmd(cmd, self.native_sysroot) def create(self): logger.debug("Creating sparse file %s", self.path) @@ -447,8 +451,8 @@ class PartitionedImage(): os.ftruncate(sparse.fileno(), self.min_size) logger.debug("Initializing partition table for %s", self.path) - exec_cmd("parted -s %s mklabel %s" % - (self.path, self.ptable_format)) + exec_native_cmd("parted -s %s mklabel %s" % + (self.path, self.ptable_format), self.native_sysroot) logger.debug("Set disk identifier %x", self.identifier) with open(self.path, 'r+b') as img: @@ -504,30 +508,35 @@ class PartitionedImage(): if part.part_type: logger.debug("partition %d: set type UID to %s", part.num, part.part_type) - exec_cmd("sgdisk --typecode=%d:%s %s" % \ - (part.num, part.part_type, self.path)) + exec_native_cmd("sgdisk --typecode=%d:%s %s" % \ + (part.num, part.part_type, + self.path), self.native_sysroot) if part.uuid and self.ptable_format == "gpt": logger.debug("partition %d: set UUID to %s", part.num, part.uuid) - exec_cmd("sgdisk --partition-guid=%d:%s %s" % \ - (part.num, part.uuid, self.path)) + exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \ + (part.num, part.uuid, self.path), + self.native_sysroot) if part.label and self.ptable_format == "gpt": logger.debug("partition %d: set name to %s", part.num, part.label) - exec_cmd("parted -s %s name %d %s" % \ - (self.path, part.num, part.label)) + exec_native_cmd("parted -s %s name %d %s" % \ + (self.path, part.num, part.label), + self.native_sysroot) if part.active: flag_name = "legacy_boot" if self.ptable_format == 'gpt' else "boot" logger.debug("Set '%s' flag for partition '%s' on disk '%s'", flag_name, part.num, self.path) - exec_cmd("parted -s %s set %d %s on" % \ - (self.path, part.num, flag_name)) + exec_native_cmd("parted -s %s set %d %s on" % \ + (self.path, part.num, flag_name), + self.native_sysroot) if part.system_id: - exec_cmd("sfdisk --part-type %s %s %s" % \ - (self.path, part.num, part.system_id)) + exec_native_cmd("sfdisk --part-type %s %s %s" % \ + (self.path, part.num, part.system_id), + self.native_sysroot) def cleanup(self): # remove partition images diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 823a536..9879cb9 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -31,7 +31,8 @@ import shutil from wic import WicError from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.misc import (exec_cmd, get_bitbake_var, BOOTDD_EXTRA_SPACE) +from wic.utils.misc import (exec_cmd, exec_native_cmd, get_bitbake_var, + BOOTDD_EXTRA_SPACE) logger = logging.getLogger('wic') @@ -154,7 +155,8 @@ class BootimgEFIPlugin(SourcePlugin): @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir): + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Called before do_prepare_partition(), creates loader-specific config """ @@ -176,7 +178,8 @@ class BootimgEFIPlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, rootfs_dir): + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -238,10 +241,10 @@ class BootimgEFIPlugin(SourcePlugin): bootimg = "%s/boot.img" % cr_workdir dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks) - exec_cmd(dosfs_cmd) + exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) - exec_cmd(mcopy_cmd) + exec_native_cmd(mcopy_cmd, native_sysroot) chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py index a00dc44..13fddbd 100644 --- a/scripts/lib/wic/plugins/source/bootimg-partition.py +++ b/scripts/lib/wic/plugins/source/bootimg-partition.py @@ -45,7 +45,8 @@ class BootimgPartitionPlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, cr, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, rootfs_dir): + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -118,4 +119,5 @@ class BootimgPartitionPlugin(SourcePlugin): exec_cmd(install_cmd) logger.debug('Prepare boot partition using rootfs in %s', hdddir) - part.prepare_rootfs(cr_workdir, oe_builddir, hdddir) + part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, + native_sysroot) diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index b029c2f..5890c12 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py @@ -31,7 +31,8 @@ from wic import WicError from wic.engine import get_custom_config from wic.utils import runner from wic.pluginbase import SourcePlugin -from wic.utils.misc import (exec_cmd, get_bitbake_var, BOOTDD_EXTRA_SPACE) +from wic.utils.misc import (exec_cmd, exec_native_cmd, + get_bitbake_var, BOOTDD_EXTRA_SPACE) logger = logging.getLogger('wic') @@ -56,7 +57,7 @@ class BootimgPcbiosPlugin(SourcePlugin): @classmethod def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir): + bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a disk image. In this case, we install the MBR. @@ -81,11 +82,12 @@ class BootimgPcbiosPlugin(SourcePlugin): disk_name, full_path, disk.min_size) dd_cmd = "dd if=%s of=%s conv=notrunc" % (mbrfile, full_path) - exec_cmd(dd_cmd) + exec_cmd(dd_cmd, native_sysroot) @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir): + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Called before do_prepare_partition(), creates syslinux config """ @@ -142,7 +144,8 @@ class BootimgPcbiosPlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, rootfs_dir): + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -186,13 +189,13 @@ class BootimgPcbiosPlugin(SourcePlugin): bootimg = "%s/boot.img" % cr_workdir dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks) - exec_cmd(dosfs_cmd) + exec_native_cmd(dosfs_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) - exec_cmd(mcopy_cmd) + exec_native_cmd(mcopy_cmd, native_sysroot) syslinux_cmd = "syslinux %s" % bootimg - exec_cmd(syslinux_cmd) + exec_native_cmd(syslinux_cmd, native_sysroot) chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py index dcb6434..1ceba62 100644 --- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py +++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py @@ -29,7 +29,7 @@ import shutil from wic import WicError from wic.engine import get_custom_config from wic.pluginbase import SourcePlugin -from wic.utils.misc import exec_cmd, get_bitbake_var +from wic.utils.misc import exec_cmd, exec_native_cmd, get_bitbake_var logger = logging.getLogger('wic') @@ -199,7 +199,8 @@ class IsoImagePlugin(SourcePlugin): @classmethod def do_configure_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir): + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): """ Called before do_prepare_partition(), creates loader-specific config """ @@ -220,7 +221,8 @@ class IsoImagePlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, creator, cr_workdir, - oe_builddir, bootimg_dir, kernel_dir, rootfs_dir): + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -269,7 +271,8 @@ class IsoImagePlugin(SourcePlugin): part.size = int(out.split()[0]) part.extra_space = 0 part.overhead_factor = 1.2 - part.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir) + part.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, \ + native_sysroot) rootfs_img = part.source_file install_cmd = "install -m 0644 %s %s/rootfs.img" \ @@ -360,7 +363,7 @@ class IsoImagePlugin(SourcePlugin): grub_cmd += "reboot serial terminfo iso9660 loopback tar " grub_cmd += "memdisk ls search_fs_uuid udf btrfs xfs lvm " grub_cmd += "reiserfs ata " - exec_cmd(grub_cmd) + exec_native_cmd(grub_cmd, native_sysroot) else: raise WicError("unrecognized bootimg-efi loader: %s" % @@ -397,14 +400,14 @@ class IsoImagePlugin(SourcePlugin): dosfs_cmd = 'mkfs.vfat -n "EFIimg" -S 512 -C %s %d' \ % (bootimg, blocks) - exec_cmd(dosfs_cmd) + exec_native_cmd(dosfs_cmd, native_sysroot) mmd_cmd = "mmd -i %s ::/EFI" % bootimg - exec_cmd(mmd_cmd) + exec_native_cmd(mmd_cmd, native_sysroot) mcopy_cmd = "mcopy -i %s -s %s/EFI/* ::/EFI/" \ % (bootimg, isodir) - exec_cmd(mcopy_cmd) + exec_native_cmd(mcopy_cmd, native_sysroot) chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) @@ -453,7 +456,7 @@ class IsoImagePlugin(SourcePlugin): mkisofs_cmd += "-no-emul-boot %s " % isodir logger.debug("running command: %s", mkisofs_cmd) - exec_cmd(mkisofs_cmd) + exec_native_cmd(mkisofs_cmd, native_sysroot) shutil.rmtree(isodir) @@ -466,7 +469,7 @@ class IsoImagePlugin(SourcePlugin): @classmethod def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, - bootimg_dir, kernel_dir): + bootimg_dir, kernel_dir, native_sysroot): """ Called after all partitions have been prepared and assembled into a disk image. In this case, we insert/modify the MBR using isohybrid @@ -479,7 +482,7 @@ class IsoImagePlugin(SourcePlugin): isohybrid_cmd = "isohybrid -u %s" % iso_img logger.debug("running command: %s", isohybrid_cmd) - exec_cmd(isohybrid_cmd) + exec_native_cmd(isohybrid_cmd, native_sysroot) # Replace the image created by direct plugin with the one created by # mkisofs command. This is necessary because the iso image created by diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py index 392ae7e..e1c4f5e 100644 --- a/scripts/lib/wic/plugins/source/rawcopy.py +++ b/scripts/lib/wic/plugins/source/rawcopy.py @@ -35,7 +35,7 @@ class RawCopyPlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, - rootfs_dir): + rootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py index e6cdc88..f2e2ca8 100644 --- a/scripts/lib/wic/plugins/source/rootfs.py +++ b/scripts/lib/wic/plugins/source/rootfs.py @@ -60,7 +60,7 @@ class RootfsPlugin(SourcePlugin): @classmethod def do_prepare_partition(cls, part, source_params, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, - krootfs_dir): + krootfs_dir, native_sysroot): """ Called to do the actual content population for a partition i.e. it 'prepares' the partition to be incorporated into the image. @@ -122,4 +122,4 @@ class RootfsPlugin(SourcePlugin): part.rootfs_dir = real_rootfs_dir part.prepare_rootfs(cr_workdir, oe_builddir, - real_rootfs_dir) + real_rootfs_dir, native_sysroot) diff --git a/scripts/wic b/scripts/wic index 641dd2e..a5f2dbf 100755 --- a/scripts/wic +++ b/scripts/wic @@ -123,6 +123,9 @@ def wic_create_subcommand(args, usage_str): parser.add_option("-k", "--kernel-dir", dest="kernel_dir", help="path to the dir containing the kernel to use " "in the .wks bootimg") + parser.add_option("-n", "--native-sysroot", dest="native_sysroot", + help="path to the native sysroot containing the tools " + "to use to build the image") parser.add_option("-s", "--skip-build-check", dest="build_check", action="store_false", default=True, help="skip the build check") parser.add_option("-f", "--build-rootfs", action="store_true", help="build rootfs") @@ -149,7 +152,8 @@ def wic_create_subcommand(args, usage_str): missed = [] for val, opt in [(options.rootfs_dir, 'rootfs-dir'), (options.bootimg_dir, 'bootimg-dir'), - (options.kernel_dir, 'kernel-dir')]: + (options.kernel_dir, 'kernel-dir'), + (options.native_sysroot, 'native-sysroot')]: if not val: missed.append(opt) if missed: @@ -184,10 +188,23 @@ def wic_create_subcommand(args, usage_str): 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 = get_bitbake_var("RECIPE_SYSROOT_NATIVE", + options.image_name) #, cache=False) 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 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 to use") wks_file = args[0] @@ -204,18 +221,23 @@ def wic_create_subcommand(args, usage_str): 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?" @@ -233,7 +255,8 @@ def wic_create_subcommand(args, usage_str): 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, options) + engine.wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, + native_sysroot, options) def wic_list_subcommand(args, usage_str): -- 2.13.6