1
0
mirror of https://git.yoctoproject.org/poky synced 2026-07-27 19:37:10 +00:00

wic: Add --embed-rootfs argument

This option adds the content of a rootfs on a specific location on the
rootfs.

It is very useful for making a partition that contains the rootfs for a
host and a target Eg:

/ -> Roofs for the host
/export/ -> Rootfs for the target (which will netboot)

Although today we support making a partition for "/export" this might
not be compatible with some upgrade systems, or we might be limited by
the number of partitions.

With this patch we can use something like:

part / --source rootfs --embed-rootfs target-image /export --embed-rootfs target-image2 /export2

on the .wks file.

(From OE-Core rev: efdcf94801f6abe8e4099e324d9a3deccd8d4384)

Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ricardo Ribalda Delgado
2020-03-04 15:49:36 +01:00
committed by Richard Purdie
parent 6bac089383
commit 242412656b
4 changed files with 31 additions and 1 deletions
+8
View File
@@ -980,6 +980,14 @@ DESCRIPTION
copies. This option only has an effect with the rootfs copies. This option only has an effect with the rootfs
source plugin. source plugin.
--embed-rootfs: This option is specific to wic. It embeds a rootfs into
the given path to the resulting image. The option
contains two fields, the roofs and the path, separated
by a space. The rootfs follows the same logic as the
rootfs-dir argument. Multiple options can be provided
in order to embed multiple rootfs. This option only has
an effect with the rootfs source plugin.
--extra-space: This option is specific to wic. It adds extra --extra-space: This option is specific to wic. It adds extra
space after the space filled by the content space after the space filled by the content
of the partition. The final size can go of the partition. The final size can go
+1
View File
@@ -138,6 +138,7 @@ class KickStart():
part.add_argument('--align', type=int) part.add_argument('--align', type=int)
part.add_argument('--exclude-path', nargs='+') part.add_argument('--exclude-path', nargs='+')
part.add_argument('--include-path', nargs='+') part.add_argument('--include-path', nargs='+')
part.add_argument('--embed-rootfs', nargs=2, action='append')
part.add_argument("--extra-space", type=sizetype) part.add_argument("--extra-space", type=sizetype)
part.add_argument('--fsoptions', dest='fsopts') part.add_argument('--fsoptions', dest='fsopts')
part.add_argument('--fstype', default='vfat', part.add_argument('--fstype', default='vfat',
+1
View File
@@ -31,6 +31,7 @@ class Partition():
self.extra_space = args.extra_space self.extra_space = args.extra_space
self.exclude_path = args.exclude_path self.exclude_path = args.exclude_path
self.include_path = args.include_path self.include_path = args.include_path
self.embed_rootfs = args.embed_rootfs
self.fsopts = args.fsopts self.fsopts = args.fsopts
self.fstype = args.fstype self.fstype = args.fstype
self.label = args.label self.label = args.label
+21 -1
View File
@@ -17,6 +17,7 @@ import shutil
import sys import sys
from oe.path import copyhardlinktree, copytree from oe.path import copyhardlinktree, copytree
from pathlib import Path
from wic import WicError from wic import WicError
from wic.pluginbase import SourcePlugin from wic.pluginbase import SourcePlugin
@@ -80,7 +81,7 @@ class RootfsPlugin(SourcePlugin):
new_rootfs = None new_rootfs = None
# Handle excluded paths. # Handle excluded paths.
if part.exclude_path or part.include_path: if part.exclude_path or part.include_path or part.embed_rootfs:
# We need a new rootfs directory we can delete files from. Copy to # We need a new rootfs directory we can delete files from. Copy to
# workdir. # workdir.
new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
@@ -100,6 +101,25 @@ class RootfsPlugin(SourcePlugin):
for path in part.include_path or []: for path in part.include_path or []:
copyhardlinktree(path, new_rootfs) copyhardlinktree(path, new_rootfs)
for embed in part.embed_rootfs or []:
[embed_rootfs, path] = embed
#we need to remove the initial / for os.path.join to work
if os.path.isabs(path):
path = path[1:]
if embed_rootfs in krootfs_dir:
embed_rootfs = krootfs_dir[embed_rootfs]
embed_rootfs = cls.__get_rootfs_dir(embed_rootfs)
tar_file = os.path.realpath(os.path.join(cr_workdir, "aux.tar"))
tar_cmd = "%s tar cpf %s -C %s ." % (cls.__get_pseudo(native_sysroot,
embed_rootfs), tar_file, embed_rootfs)
exec_native_cmd(tar_cmd, native_sysroot)
untar_cmd = "%s tar xf %s -C %s ." % (cls.__get_pseudo(native_sysroot, new_rootfs),
tar_file, os.path.join(new_rootfs, path))
Path(os.path.join(new_rootfs, path)).mkdir(parents=True, exist_ok=True)
exec_native_cmd(untar_cmd, native_sysroot,
cls.__get_pseudo(native_sysroot, new_rootfs))
os.remove(tar_file)
for orig_path in part.exclude_path or []: for orig_path in part.exclude_path or []:
path = orig_path path = orig_path
if os.path.isabs(path): if os.path.isabs(path):