From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH 8/9] Revert "wic: Remove sysroot support"
Date: Wed, 31 Jan 2018 10:41:59 +0100 [thread overview]
Message-ID: <019be23d52b965a764b534b930ab9a47c5d57b41.1517390790.git.henning.schild@siemens.com> (raw)
In-Reply-To: <cover.1517390790.git.henning.schild@siemens.com>
In-Reply-To: <cover.1517390790.git.henning.schild@siemens.com>
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
next prev parent reply other threads:[~2018-01-31 9:42 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 9:41 [PATCH 0/9] first wic integration Henning Schild
2018-01-31 9:41 ` [PATCH 1/9] classes: image: introduce size measuring function, for before do_*_image Henning Schild
2018-01-31 9:41 ` [PATCH 2/9] images: new class wic-img for wic intregration Henning Schild
2018-02-13 14:44 ` Alexander Smirnov
2018-02-13 16:06 ` Henning Schild
2018-01-31 9:41 ` [PATCH 3/9] wic: add a bootimg-efi-isar plugin outside the wic tree Henning Schild
2018-02-12 17:48 ` Jan Kiszka
2018-01-31 9:41 ` [PATCH 4/9] Revert "wic: Make the bootimg-efi plugin generate usable images" Henning Schild
2018-01-31 9:41 ` [PATCH 5/9] Revert "wic: Introduce the `WicExecError` exception class" Henning Schild
2018-01-31 9:41 ` [PATCH 6/9] Revert "wic: Work around mcopy error" Henning Schild
2018-01-31 9:41 ` [PATCH 7/9] Revert "wic: Use sudo instead of pseudo" Henning Schild
2018-01-31 9:41 ` Henning Schild [this message]
2018-01-31 9:42 ` [PATCH 9/9] wic: now truly go for the wic version we claim to have Henning Schild
2018-01-31 10:11 ` Alexander Smirnov
2018-01-31 10:55 ` Jan Kiszka
2018-01-31 11:11 ` Alexander Smirnov
2018-01-31 11:43 ` Jan Kiszka
2018-01-31 11:53 ` Baurzhan Ismagulov
2018-01-31 12:01 ` Jan Kiszka
2018-01-31 12:28 ` Baurzhan Ismagulov
2018-01-31 13:53 ` Henning Schild
2018-01-31 14:01 ` Baurzhan Ismagulov
2018-01-31 14:21 ` Henning Schild
2018-01-31 10:02 ` [PATCH 0/9] first wic integration Alexander Smirnov
2018-01-31 10:12 ` Henning Schild
2018-01-31 11:24 ` Baurzhan Ismagulov
2018-01-31 11:47 ` Jan Kiszka
2018-01-31 12:02 ` Baurzhan Ismagulov
2018-01-31 12:15 ` Jan Kiszka
2018-01-31 13:30 ` Jan Kiszka
2018-01-31 13:41 ` Baurzhan Ismagulov
2018-01-31 14:01 ` Jan Kiszka
2018-01-31 15:21 ` Baurzhan Ismagulov
2018-01-31 15:46 ` Henning Schild
2018-01-31 16:13 ` Jan Kiszka
2018-01-31 13:35 ` Baurzhan Ismagulov
2018-01-31 13:47 ` Henning Schild
2018-01-31 14:00 ` Baurzhan Ismagulov
2018-01-31 13:46 ` Henning Schild
2018-01-31 13:36 ` Henning Schild
2018-01-31 13:40 ` Baurzhan Ismagulov
2018-01-31 13:05 ` Henning Schild
2018-02-01 12:41 ` [PATCH] images: wic: limit use of sudo and enable manual call again Henning Schild
2018-02-01 12:44 ` Henning Schild
2018-02-01 16:09 ` Baurzhan Ismagulov
2018-02-01 18:10 ` Henning Schild
2018-02-01 18:55 ` Henning Schild
2018-02-12 19:07 ` Henning Schild
2018-02-12 17:27 ` [PATCH 0/9] first wic integration Henning Schild
2018-02-12 18:21 ` Alexander Smirnov
2018-02-12 18:30 ` Henning Schild
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=019be23d52b965a764b534b930ab9a47c5d57b41.1517390790.git.henning.schild@siemens.com \
--to=henning.schild@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox