summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/rootfs.py
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo@ribalda.com>2020-03-04 15:49:36 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-06 16:45:11 +0100
commit242412656b8c7bd684ebca3da71a0d07cd69a830 (patch)
treee10056b9511ec1b845e639ee61b1d832b07ba2a0 /scripts/lib/wic/plugins/source/rootfs.py
parent6bac089383d725793485ab559209a1bbcaf2719e (diff)
downloadpoky-242412656b8c7bd684ebca3da71a0d07cd69a830.tar.gz
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>
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 40419a64b3..089aaea477 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -17,6 +17,7 @@ import shutil
17import sys 17import sys
18 18
19from oe.path import copyhardlinktree, copytree 19from oe.path import copyhardlinktree, copytree
20from pathlib import Path
20 21
21from wic import WicError 22from wic import WicError
22from wic.pluginbase import SourcePlugin 23from wic.pluginbase import SourcePlugin
@@ -80,7 +81,7 @@ class RootfsPlugin(SourcePlugin):
80 81
81 new_rootfs = None 82 new_rootfs = None
82 # Handle excluded paths. 83 # Handle excluded paths.
83 if part.exclude_path or part.include_path: 84 if part.exclude_path or part.include_path or part.embed_rootfs:
84 # We need a new rootfs directory we can delete files from. Copy to 85 # We need a new rootfs directory we can delete files from. Copy to
85 # workdir. 86 # workdir.
86 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) 87 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno))
@@ -100,6 +101,25 @@ class RootfsPlugin(SourcePlugin):
100 for path in part.include_path or []: 101 for path in part.include_path or []:
101 copyhardlinktree(path, new_rootfs) 102 copyhardlinktree(path, new_rootfs)
102 103
104 for embed in part.embed_rootfs or []:
105 [embed_rootfs, path] = embed
106 #we need to remove the initial / for os.path.join to work
107 if os.path.isabs(path):
108 path = path[1:]
109 if embed_rootfs in krootfs_dir:
110 embed_rootfs = krootfs_dir[embed_rootfs]
111 embed_rootfs = cls.__get_rootfs_dir(embed_rootfs)
112 tar_file = os.path.realpath(os.path.join(cr_workdir, "aux.tar"))
113 tar_cmd = "%s tar cpf %s -C %s ." % (cls.__get_pseudo(native_sysroot,
114 embed_rootfs), tar_file, embed_rootfs)
115 exec_native_cmd(tar_cmd, native_sysroot)
116 untar_cmd = "%s tar xf %s -C %s ." % (cls.__get_pseudo(native_sysroot, new_rootfs),
117 tar_file, os.path.join(new_rootfs, path))
118 Path(os.path.join(new_rootfs, path)).mkdir(parents=True, exist_ok=True)
119 exec_native_cmd(untar_cmd, native_sysroot,
120 cls.__get_pseudo(native_sysroot, new_rootfs))
121 os.remove(tar_file)
122
103 for orig_path in part.exclude_path or []: 123 for orig_path in part.exclude_path or []:
104 path = orig_path 124 path = orig_path
105 if os.path.isabs(path): 125 if os.path.isabs(path):