diff options
author | Khasim Mohammed <khasim.mohammed@arm.com> | 2020-07-23 15:21:50 +0530 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-07-25 15:11:05 +0100 |
commit | 801f07fc00d43d107cb6ae671dbbb57ee91cc6be (patch) | |
tree | 5df8e2218530d1e1940d499fb14903f4d97716c1 /scripts | |
parent | 3439ad86168937edfb90120f1e9c86886f03bd71 (diff) | |
download | poky-801f07fc00d43d107cb6ae671dbbb57ee91cc6be.tar.gz |
wic/bootimg-efi: Add support for IMAGE_BOOT_FILES
List of files defined using IMAGE_BOOT_FILES are installed into
the boot partition when preparing an image using the wic tool with
the bootimg-efi source plugin.
The code snippet introduced is taken as is from bootimg-partition.py
Change-Id: I8dbb6b4e7c24870f587a6f31e6ae4a87d7033782
Issue-Id: PLATFORMS-3134
(From OE-Core rev: a44ab3a4ee5b3c57812909c6194456f299d6ba7f)
Signed-off-by: Khasim Syed Mohammed <khasim.mohammed@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index 2cfdc10ecd..14c1723577 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -13,6 +13,9 @@ | |||
13 | import logging | 13 | import logging |
14 | import os | 14 | import os |
15 | import shutil | 15 | import shutil |
16 | import re | ||
17 | |||
18 | from glob import glob | ||
16 | 19 | ||
17 | from wic import WicError | 20 | from wic import WicError |
18 | from wic.engine import get_custom_config | 21 | from wic.engine import get_custom_config |
@@ -209,6 +212,57 @@ class BootimgEFIPlugin(SourcePlugin): | |||
209 | except KeyError: | 212 | except KeyError: |
210 | raise WicError("bootimg-efi requires a loader, none specified") | 213 | raise WicError("bootimg-efi requires a loader, none specified") |
211 | 214 | ||
215 | if get_bitbake_var("IMAGE_BOOT_FILES") is None: | ||
216 | logger.debug('No boot files defined in IMAGE_BOOT_FILES') | ||
217 | else: | ||
218 | boot_files = None | ||
219 | for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), (None, None)): | ||
220 | if fmt: | ||
221 | var = fmt % id | ||
222 | else: | ||
223 | var = "" | ||
224 | |||
225 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES" + var) | ||
226 | if boot_files: | ||
227 | break | ||
228 | |||
229 | logger.debug('Boot files: %s', boot_files) | ||
230 | |||
231 | # list of tuples (src_name, dst_name) | ||
232 | deploy_files = [] | ||
233 | for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files): | ||
234 | if ';' in src_entry: | ||
235 | dst_entry = tuple(src_entry.split(';')) | ||
236 | if not dst_entry[0] or not dst_entry[1]: | ||
237 | raise WicError('Malformed boot file entry: %s' % src_entry) | ||
238 | else: | ||
239 | dst_entry = (src_entry, src_entry) | ||
240 | |||
241 | logger.debug('Destination entry: %r', dst_entry) | ||
242 | deploy_files.append(dst_entry) | ||
243 | |||
244 | cls.install_task = []; | ||
245 | for deploy_entry in deploy_files: | ||
246 | src, dst = deploy_entry | ||
247 | if '*' in src: | ||
248 | # by default install files under their basename | ||
249 | entry_name_fn = os.path.basename | ||
250 | if dst != src: | ||
251 | # unless a target name was given, then treat name | ||
252 | # as a directory and append a basename | ||
253 | entry_name_fn = lambda name: \ | ||
254 | os.path.join(dst, | ||
255 | os.path.basename(name)) | ||
256 | |||
257 | srcs = glob(os.path.join(kernel_dir, src)) | ||
258 | |||
259 | logger.debug('Globbed sources: %s', ', '.join(srcs)) | ||
260 | for entry in srcs: | ||
261 | src = os.path.relpath(entry, kernel_dir) | ||
262 | entry_dst_name = entry_name_fn(entry) | ||
263 | cls.install_task.append((src, entry_dst_name)) | ||
264 | else: | ||
265 | cls.install_task.append((src, dst)) | ||
212 | 266 | ||
213 | @classmethod | 267 | @classmethod |
214 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, | 268 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
@@ -238,6 +292,12 @@ class BootimgEFIPlugin(SourcePlugin): | |||
238 | (staging_kernel_dir, kernel, hdddir, kernel) | 292 | (staging_kernel_dir, kernel, hdddir, kernel) |
239 | exec_cmd(install_cmd) | 293 | exec_cmd(install_cmd) |
240 | 294 | ||
295 | if get_bitbake_var("IMAGE_BOOT_FILES"): | ||
296 | for src_path, dst_path in cls.install_task: | ||
297 | install_cmd = "install -m 0644 -D %s %s" \ | ||
298 | % (os.path.join(kernel_dir, src_path), | ||
299 | os.path.join(hdddir, dst_path)) | ||
300 | exec_cmd(install_cmd) | ||
241 | 301 | ||
242 | try: | 302 | try: |
243 | if source_params['loader'] == 'grub-efi': | 303 | if source_params['loader'] == 'grub-efi': |